-
Notifications
You must be signed in to change notification settings - Fork 138
Brooklin Architecture
Brooklin is a Java server application that is typically deployed to a cluster of machines. Each machine can host one or more instances of Brooklin, each of which offers the exact same set of capabilities.
- The most fundamental concept in Brooklin is a
Datastream. - A
Datastreamis a description of a data pipe between two systems; a source system from which data is consumed and a destination system to which this data is produced. - Brooklin allows you to create as many
Datastreamsas you need to set up different data pipes between various source and destination systems. - To support high scalability, Brooklin expects the data streamed between source and destination systems to be partitioned. If the data is not partitioned, it is treated as a stream with a single partition.
- Likewise, Brooklin breaks every partitioned
Datastreaminto multipleDatastreamTasks, each of which is limited to a subset of the total partitions, that are all processed concurrently for higher throughput.
-
Connectoris the abstraction representing modules that consume data from source systems. - Different
Connectorimplementations can be written to support consuming data from different source systems. - Every
Connectoris associated with anAssignmentStrategythat determines (a) howDatastreamsare broken intoDatastreamTasksand (b) how theseDatastreamTasksare distributed among the different instances of Brooklin server app. - An example
Connectorimplementation isKafkaConnector, which is intended for consuming data from Kafka.
-
TransportProvideris the abstraction representing modules that produce data to destination systems. - Different
TransportProviderimplementations can be written to support producing data to different destination systems. - An example
TransportProviderimplementation isKafkaTransportProvider, which is intended for producing data to Kafka.
- Brooklin
Coordinatoris the module responsible for managing the differentConnectorimplementations. - There is only a single
Coordinatorobject in every Brooklin server app instance. - A
Coordinatorcan either be a leader or non-leader. - In a Brooklin cluster, only one
Coordinatoris designated as the leader while the rest are non-leaders. - Brooklin employs the ZooKeeper election recipe for electing the leader
Coordinator. - In addition to managing
Connectors, the leaderCoordinatoris responsible for dividing the work among all theCoordinatorsin the cluster (including itself). - The leader
Coordinatoruses theAssignmentStrategyimplementation specified in the relevantConnectorto break down the work required for everyDatastreaminto one or moreDatastreamTasks. - An example
AssignmentStrategyoffered by Brooklin is theLoadbalancingStrategy, which evenly distributes all the availableDatastreamTasksacross allCoordinatorinstances.
- Brooklin server application is typically deployed to one or more machines, all using ZooKeeper as the source of truth for
DatastreamandDatastreamTaskmetadata. - Information about the different instances of Brooklin server app as well as their
DatastreamTaskassignments is also stored in ZooKeeper. - Every Brooklin instance exposes a REST endpoint — aka
Datastream Management Service (DMS)— that offers CRUD operations onDatastreamsover HTTP.
A good way to understand the architecture of Brooklin is to go through the workflow of creating a new Datastream.
The figure below illustrates the main steps involved in Datastream creation.
-
A Brooklin client sends a
Datastreamcreation request to a Brooklin cluster. -
The request is routed to the
Datastream Management ServiceREST endpoint of any instance of the Brooklin server app. -
The
Datastreamdata is verified and written to ZooKeeper under a certain znode that the leaderCoordinatoris watching for changes. -
The leader
Coordinatorgets notified of the newDatastreamznode creation. -
The leader
Coordinatorreads the metadata of the newly createdDatastream, and uses theAssignmentStrategyassociated with the relevantConnectorto break down theDatastreaminto one or moreDatastreamTasks. It assigns theseDatastreamTasksto the availableCoordinatorinstances by writing the breakdown and assignment info to ZooKeeper. -
The affected
Coordinatorsget notified of the newDatastreamTaskassignments created under their respective znodes, which they read and process immediately using the relevantConnectors(i.e. consume from source, produce to destination).
In addition to leader Coordinator election, Brooklin maintains the following pieces of info in ZooKeeper:
- Registered
Connectortypes -
DatastreamandDatastreamTasksmetadata -
DatastreamTaskstate information (e.g. offsets/checkpoints, processing errors) - Brooklin app instances
-
DatastreamTaskassignments of Brooklin app instances
The figure below illustrates the overall structure of the data Brooklin maintains in ZooKeeper.
- Each Brooklin cluster is mapped to one top-level znode.
-
/dmsis where the definitions of individualDatastreamsare persisted (in JSON) -
/connectors- A sub-znode for every registered
Connectortype in this cluster is created under this znode. -
/connectors/<connector-type>/is where the definitions of all theDatastreamTaskshandled by thisConnectortype are located, one znode perDatastreamTask. - There are two child nodes under every
/connectors/<connector-type>/<datastreamtask>znode:configandstate. -
configstores the definitions of theDatastreamTasks -
statestores the progress info of theConnectors(offsets/checkpoints)
- A sub-znode for every registered
-
/liveinstances- This is where the different Brooklin instances create ephemeral znodes with incremental sequence numbers (created using the EPHEMERAL_SEQUENTIAL mode) for the purposes of leader
Coordinatorelection. - The value associated with each sub-znode is the hostname of the corresponding Brooklin instance.
- This is where the different Brooklin instances create ephemeral znodes with incremental sequence numbers (created using the EPHEMERAL_SEQUENTIAL mode) for the purposes of leader
-
/instances- This is where every Brooklin instance creates a persistent znode for itself. Each znode has a name composed of the concatenation of the instance hostname and its unique sequence number under
/liveinstances. - Two sub-znodes are created under each Brooklin instance znode —
assignmentsanderrors. -
assignmentscontains the names of all theDatastreamTasksassigned to this Brooklin instance. -
errorsis where messages about errors encountered by this Brooklin instance are persisted.
- This is where every Brooklin instance creates a persistent znode for itself. Each znode has a name composed of the concatenation of the instance hostname and its unique sequence number under
- The leader
Coordinatorwatches the/dmsznode for changes in order to get notified whenDatastreamsare created, deleted, or altered. - Leader or not, every
Coorindatorwatches its corresponding znode under/instancesin order to get notified when changes are made to itsassignmentschild znode. - The leader
CoordinatorassignsDatastreamTasksto individual Brooklin instances by changing theassignmentznode under/instances/<instance-name>.
Brooklin uses Rest.li to expose three REST endpoints:
-
Datastream Management Service(DMS)In addition to basic CRUD operations, this endpoint offers some advanced operations on
Datastreams, e.g.- batch operations (e.g.
get_all,batch_update) -
pauseandresumeoperations on entireDatastreamsas well as individual partitions (in case of partitionedDatastreams)
- batch operations (e.g.
-
Health Monitoring
This endpoint offers information about the overall health of a single Brooklin instance, e.g.
- Instance name
- Brooklin cluster name
- All
Connectorsregistered on the instance - All
DatastreamTasksassigned to the instance - All
DatastreamTaskstatus (e.g. good, faulty, paused ... etc.) - Source and Destination info for all
DatastreamTasksassigned to the instance - The number of partitions of every
DatastreamTask
-
Diagnostics
-
This endpoint offers a greater level of detail about individual Brooklin components. For example, it can be queried for detailed status of an individual
ConnectororDatastream. -
Furthermore, this endpoint can provide a diagnostic digest aggregated from all Brooklin instances in the same cluster, sparing administrators the trouble of querying every instance individually and aggregating the stats externally.
-
Please refer to the REST Endpoints wiki page for detailed information about the options offered by these endpoints.
Brooklin uses the Metrics library to emit metrics about various aspects of its operation. These metrics are emitted through JMX (using JmxReporter), and exported to CSV files (using CsvReporter) if a valid file path is provided to Brooklin through configuration.
- Home
- Brooklin Architecture
- Production Use Cases
- Developer Guide
- Documentation
- REST Endpoints
- Connectors
- Transport Providers
- Brooklin Configuration
- Test Driving Brooklin