Zookeeper Client Threading Model
Zookeeper client library’s threading model
- When we start our application, the application’s start code in the
main()
method is executed on themain
thread. - When
Zookeeper
object is created, the object creates two additional threadsEvent Thread
- Manages Zookeeper
state change
events- Connection (
KeeperState.SyncConnected
) - Disconnection (
KeeperState.Disconnected
)
- Connection (
- Manages all the Znode Watchers and Triggers we subscribe to.
- All
events
coming from Zookeeper are executed on the Event Thread and they are executed in the order.
- Manages Zookeeper
IO Thread
- We don’t interact with this thread directly.
- This handles all the network communication between our application and the Zookeeper servers.
- This handles Zookeeper’s requests and responses.
- This responds to
pings from Zookeeper
. - This handles
Session Management
- This handles
Session Timeouts
- etc.