public class ZooKeeperLeaderRetrievalService extends Object implements LeaderRetrievalService, org.apache.flink.shaded.curator4.org.apache.curator.framework.recipes.cache.NodeCacheListener, org.apache.flink.shaded.curator4.org.apache.curator.framework.api.UnhandledErrorListener
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.flink.shaded.curator4.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.flink.shaded.curator4.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.
|
void |
unhandledError(String s,
Throwable throwable) |
public ZooKeeperLeaderRetrievalService(org.apache.flink.shaded.curator4.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
public void nodeChanged()
nodeChanged
in interface org.apache.flink.shaded.curator4.org.apache.curator.framework.recipes.cache.NodeCacheListener
protected void handleStateChange(org.apache.flink.shaded.curator4.org.apache.curator.framework.state.ConnectionState newState)
Copyright © 2014–2021 The Apache Software Foundation. All rights reserved.