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 |
---|---|
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
LeaderRetrievalService
start
in interface LeaderRetrievalService
listener
- The leader retrieval listener which will be notified about new leaders.Exception
public void stop() throws Exception
LeaderRetrievalService
stop
in interface LeaderRetrievalService
Exception
Copyright © 2014–2017 The Apache Software Foundation. All rights reserved.