public class ZooKeeperLeaderRetrievalService extends Object implements LeaderRetrievalService, org.apache.curator.framework.recipes.cache.NodeCacheListener
ZooKeeperLeaderElectionService.
This implementation of the LeaderRetrievalService retrieves the current leader which has
been elected by the ZooKeeperLeaderElectionService.
The leader address as well as the current leader session ID is retrieved from ZooKeeper.| Constructor and Description |
|---|
ZooKeeperLeaderRetrievalService(org.apache.curator.framework.CuratorFramework client,
String retrievalPath)
Creates a leader retrieval service which uses ZooKeeper to retrieve the leader information.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
handleStateChange(org.apache.curator.framework.state.ConnectionState newState) |
void |
nodeChanged() |
void |
start(LeaderRetrievalListener listener)
Starts the leader retrieval service with the given listener to listen for new leaders.
|
void |
stop()
Stops the leader retrieval service.
|
public ZooKeeperLeaderRetrievalService(org.apache.curator.framework.CuratorFramework client,
String retrievalPath)
client - Client which constitutes the connection to the ZooKeeper quorumretrievalPath - Path of the ZooKeeper node which contains the leader informationpublic void start(LeaderRetrievalListener listener) throws Exception
LeaderRetrievalServicestart in interface LeaderRetrievalServicelistener - The leader retrieval listener which will be notified about new leaders.Exceptionpublic void stop()
throws Exception
LeaderRetrievalServicestop in interface LeaderRetrievalServiceExceptionpublic void nodeChanged()
throws Exception
nodeChanged in interface org.apache.curator.framework.recipes.cache.NodeCacheListenerExceptionprotected void handleStateChange(org.apache.curator.framework.state.ConnectionState newState)
Copyright © 2014–2016 The Apache Software Foundation. All rights reserved.