public class ZkLeaderElection extends Object implements LeaderElection
| Constructor and Description |
|---|
ZkLeaderElection(ZkConnectionManager zkConnectionManager,
String electionPath,
String baseCandidateName,
Encodable candidatePayload,
LeaderElectionCallback leaderElectionCallback) |
ZkLeaderElection(ZkConnectionManager zkConnectionManager,
String electionPath,
String baseCandidateName,
Encodable candidatePayload,
LeaderElectionCallback leaderElectionCallback,
ExecutorService watchExecutor) |
| Modifier and Type | Method and Description |
|---|---|
void |
cycle()
Relinquishes the candidate's current standing (possibly as the leader) and
demotes the candidate to the last position.
|
void |
enter()
Adds the current host to the election if it is not there already.
|
String |
getLeader()
Gets the name of the candidate that is currently the leader
|
void |
withdraw()
Completely removes the candidate from the election.
|
public ZkLeaderElection(ZkConnectionManager zkConnectionManager, String electionPath, String baseCandidateName, Encodable candidatePayload, LeaderElectionCallback leaderElectionCallback, ExecutorService watchExecutor)
public ZkLeaderElection(ZkConnectionManager zkConnectionManager, String electionPath, String baseCandidateName, Encodable candidatePayload, LeaderElectionCallback leaderElectionCallback)
public void enter()
throws InterruptedException,
org.apache.zookeeper.KeeperException
LeaderElectionenter in interface LeaderElectionInterruptedExceptionorg.apache.zookeeper.KeeperExceptionpublic void withdraw()
throws InterruptedException,
org.apache.zookeeper.KeeperException
LeaderElectionwithdraw in interface LeaderElectionInterruptedExceptionorg.apache.zookeeper.KeeperExceptionpublic void cycle()
throws InterruptedException,
org.apache.zookeeper.KeeperException
LeaderElectioncycle in interface LeaderElectionInterruptedExceptionorg.apache.zookeeper.KeeperExceptionpublic String getLeader() throws InterruptedException, org.apache.zookeeper.KeeperException
LeaderElectionObservergetLeader in interface LeaderElectionObserverInterruptedExceptionorg.apache.zookeeper.KeeperExceptionCopyright © 2012–2015 Facebook, Inc.. All rights reserved.