public class ZooKeeperLeaderElectionDriver extends Object implements LeaderElectionDriver, org.apache.flink.shaded.curator4.org.apache.curator.framework.recipes.leader.LeaderLatchListener, org.apache.flink.shaded.curator4.org.apache.curator.framework.recipes.cache.NodeCacheListener, org.apache.flink.shaded.curator4.org.apache.curator.framework.api.UnhandledErrorListener
LeaderElectionDriver implementation for Zookeeper. The leading JobManager is elected
using ZooKeeper. The current leader's address as well as its leader session ID is published via
ZooKeeper.| Constructor and Description |
|---|
ZooKeeperLeaderElectionDriver(org.apache.flink.shaded.curator4.org.apache.curator.framework.CuratorFramework client,
String latchPath,
String leaderPath,
LeaderElectionEventHandler leaderElectionEventHandler,
FatalErrorHandler fatalErrorHandler,
String leaderContenderDescription)
Creates a ZooKeeperLeaderElectionDriver object.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close the services used for leader election.
|
boolean |
hasLeadership()
Check whether the driver still have the leadership in the distributed coordination system.
|
void |
isLeader() |
void |
nodeChanged() |
void |
notLeader() |
String |
toString() |
void |
unhandledError(String message,
Throwable e) |
void |
writeLeaderInformation(LeaderInformation leaderInformation)
Writes the current leader's address as well the given leader session ID to ZooKeeper.
|
public ZooKeeperLeaderElectionDriver(org.apache.flink.shaded.curator4.org.apache.curator.framework.CuratorFramework client,
String latchPath,
String leaderPath,
LeaderElectionEventHandler leaderElectionEventHandler,
FatalErrorHandler fatalErrorHandler,
String leaderContenderDescription)
throws Exception
client - Client which is connected to the ZooKeeper quorumlatchPath - ZooKeeper node path for the leader election latchleaderPath - ZooKeeper node path for the node which stores the current leader
informationleaderElectionEventHandler - Event handler for processing leader change eventsfatalErrorHandler - Fatal error handlerleaderContenderDescription - Leader contender descriptionExceptionpublic void close()
throws Exception
LeaderElectionDriverclose in interface LeaderElectionDriverExceptionpublic boolean hasLeadership()
LeaderElectionDriverhasLeadership in interface LeaderElectionDriverpublic void isLeader()
isLeader in interface org.apache.flink.shaded.curator4.org.apache.curator.framework.recipes.leader.LeaderLatchListenerpublic void notLeader()
notLeader in interface org.apache.flink.shaded.curator4.org.apache.curator.framework.recipes.leader.LeaderLatchListenerpublic void nodeChanged()
throws Exception
nodeChanged in interface org.apache.flink.shaded.curator4.org.apache.curator.framework.recipes.cache.NodeCacheListenerExceptionpublic void writeLeaderInformation(LeaderInformation leaderInformation)
writeLeaderInformation in interface LeaderElectionDriverleaderInformation - current leader information. It could be LeaderInformation.empty(), which means the caller want to clear the leader information
on external storage. Please remember that the clear operation should only happen before a
new leader is elected and has written his leader information on the storage. Otherwise,
we may have a risk to wrongly update the storage with empty leader information.public void unhandledError(String message, Throwable e)
unhandledError in interface org.apache.flink.shaded.curator4.org.apache.curator.framework.api.UnhandledErrorListenerCopyright © 2014–2021 The Apache Software Foundation. All rights reserved.