2013-09-16 17:49:36 -04:00
---
2013-09-26 19:22:28 -04:00
layout: doc_page
2013-09-16 17:49:36 -04:00
---
2013-11-01 20:17:57 -04:00
Druid uses [ZooKeeper ](http://zookeeper.apache.org/ ) (ZK) for management of current cluster state. The operations that happen over ZK are
2013-09-13 18:20:39 -04:00
2013-10-03 19:36:48 -04:00
1. [Coordinator ](Coordinator.html ) leader election
2. Segment "publishing" protocol from [Historical ](Historical.html ) and [Realtime ](Realtime.html )
3. Segment load/drop protocol between [Coordinator ](Coordinator.html ) and [Historical ](Historical.html )
2013-10-11 21:38:53 -04:00
4. [Overlord ](Indexing-Service.html ) leader election
5. [Indexing Service ](Indexing-Service.html ) task management
2013-09-13 18:20:39 -04:00
### Property Configuration
ZooKeeper paths are set via the `runtime.properties` configuration file. Druid will automatically create paths that do not exist, so typos in config files is a very easy way to become split-brained.
2013-09-27 20:08:34 -04:00
There is a prefix path that is required and can be used as the only (well, kinda, see the note below) path-related zookeeper configuration parameter (everything else will be a default based on the prefix):
2013-09-13 18:20:39 -04:00
2013-09-27 20:08:34 -04:00
```
druid.zk.paths.base
```
2013-09-13 18:20:39 -04:00
2013-09-27 20:08:34 -04:00
You can also override each individual path (defaults are shown below):
2013-09-13 18:20:39 -04:00
2013-09-27 20:08:34 -04:00
```
druid.zk.paths.propertiesPath=${druid.zk.paths.base}/properties
druid.zk.paths.announcementsPath=${druid.zk.paths.base}/announcements
druid.zk.paths.servedSegmentsPath=${druid.zk.paths.base}/servedSegments
druid.zk.paths.loadQueuePath=${druid.zk.paths.base}/loadQueue
2013-10-03 19:36:48 -04:00
druid.zk.paths.coordinatorPath=${druid.zk.paths.base}/coordinator
2013-09-27 20:08:34 -04:00
druid.zk.paths.indexer.announcementsPath=${druid.zk.paths.base}/indexer/announcements
druid.zk.paths.indexer.tasksPath=${druid.zk.paths.base}/indexer/tasks
druid.zk.paths.indexer.statusPath=${druid.zk.paths.base}/indexer/status
druid.zk.paths.indexer.leaderLatchPath=${druid.zk.paths.base}/indexer/leaderLatchPath
```
2013-09-13 18:20:39 -04:00
2013-10-11 21:38:53 -04:00
|Property|Description|Default|
|--------|-----------|-------|
|`druid.zk.paths.base`|Base Zookeeper path.|druid|
|`druid.zk.paths.propertiesPath`|Zookeeper properties path.|druid/properties|
|`druid.zk.paths.announcementsPath`|Druid node announcement path.|druid/announcements|
|`druid.zk.paths.servedSegmentsPath`|Legacy path for where Druid nodes announce their segments.|druid/servedSegments|
|`druid.zk.paths.liveSegmentsPath`|Current path for where Druid nodes announce their segments.|druid/segments|
|`druid.zk.paths.loadQueuePath`|Entries here cause historical nodes to load and drop segments.|druid/loadQueue|
|`druid.zk.paths.coordinatorPath`|Used by the coordinator for leader election.|druid/coordinator|
|`druid.zk.paths.indexer.announcementsPath`|Middle managers announce themselves here.|druid/indexer/announcements|
|`druid.zk.paths.indexer.tasksPath`|Used to assign tasks to middle managers.|druid/indexer/tasks|
|`druid.zk.paths.indexer.statusPath`|Parent path for announcement of task statuses.|druid/indexer/status|
|`druid.zk.paths.indexer.leaderLatchPath`|Used for Overlord leader election.|druid/indexer/leaderLatchPath|
2013-09-13 18:20:39 -04:00
NOTE: We also use Curator’ s service discovery module to expose some services via zookeeper. This also uses a zookeeper path, but this path is **not** affected by `druid.zk.paths.base` and **must** be specified separately. This property is
2013-09-27 20:08:34 -04:00
```
druid.zk.paths.discoveryPath
```
2013-09-13 18:20:39 -04:00
2013-10-03 19:36:48 -04:00
### Coordinator Leader Election
2013-09-13 18:20:39 -04:00
We use the Curator LeadershipLatch recipe to do leader election at path
2013-09-27 20:08:34 -04:00
```
2013-10-03 19:36:48 -04:00
${druid.zk.paths.coordinatorPath}/_COORDINATOR
2013-09-27 20:08:34 -04:00
```
2013-09-13 18:20:39 -04:00
2013-10-03 19:36:48 -04:00
### Segment "publishing" protocol from Historical and Realtime
2013-09-13 18:20:39 -04:00
The `announcementsPath` and `servedSegmentsPath` are used for this.
2013-10-03 19:36:48 -04:00
All [Historical ](Historical.html ) and [Realtime ](Realtime.html ) nodes publish themselves on the `announcementsPath` , specifically, they will create an ephemeral znode at
2013-09-13 18:20:39 -04:00
2013-09-27 20:08:34 -04:00
```
${druid.zk.paths.announcementsPath}/${druid.host}
```
2013-09-13 18:20:39 -04:00
Which signifies that they exist. They will also subsequently create a permanent znode at
2013-09-27 20:08:34 -04:00
```
${druid.zk.paths.servedSegmentsPath}/${druid.host}
```
2013-09-13 18:20:39 -04:00
And as they load up segments, they will attach ephemeral znodes that look like
2013-09-27 20:08:34 -04:00
```
${druid.zk.paths.servedSegmentsPath}/${druid.host}/_segment_identifier_
```
2013-09-13 18:20:39 -04:00
2013-10-03 19:36:48 -04:00
Nodes like the [Coordinator ](Coordinator.html ) and [Broker ](Broker.html ) can then watch these paths to see which nodes are currently serving which segments.
2013-09-13 18:20:39 -04:00
2013-10-03 19:36:48 -04:00
### Segment load/drop protocol between Coordinator and Historical
2013-09-13 18:20:39 -04:00
The `loadQueuePath` is used for this.
2013-10-03 19:36:48 -04:00
When the [Coordinator ](Coordinator.html ) decides that a [Historical ](Historical.html ) node should load or drop a segment, it writes an ephemeral znode to
2013-09-13 18:20:39 -04:00
2013-09-27 20:08:34 -04:00
```
2013-10-03 19:36:48 -04:00
${druid.zk.paths.loadQueuePath}/_host_of_historical_node/_segment_identifier
2013-09-27 20:08:34 -04:00
```
2013-09-13 18:20:39 -04:00
2013-10-03 19:36:48 -04:00
This node will contain a payload that indicates to the historical node what it should do with the given segment. When the historical node is done with the work, it will delete the znode in order to signify to the Coordinator that it is complete.