public class LeaderElectorImp extends Object implements ILeaderElector
| Constructor and Description |
|---|
LeaderElectorImp(Map conf,
List<String> servers,
org.apache.curator.framework.CuratorFramework zk,
String leaderlockPath,
String id,
AtomicReference<org.apache.curator.framework.recipes.leader.LeaderLatch> leaderLatch,
AtomicReference<org.apache.curator.framework.recipes.leader.LeaderLatchListener> leaderLatchListener,
BlobStore blobStore) |
| Modifier and Type | Method and Description |
|---|---|
void |
addToLeaderLockQueue()
queue up for leadership lock.
|
void |
close()
Method called to allow for cleanup.
|
List<NimbusInfo> |
getAllNimbuses() |
NimbusInfo |
getLeader() |
boolean |
isLeader() |
void |
prepare(Map conf)
Method guaranteed to be called as part of initialization of leader elector instance.
|
void |
removeFromLeaderLockQueue()
Removes the caller from the leader lock queue.
|
public LeaderElectorImp(Map conf, List<String> servers, org.apache.curator.framework.CuratorFramework zk, String leaderlockPath, String id, AtomicReference<org.apache.curator.framework.recipes.leader.LeaderLatch> leaderLatch, AtomicReference<org.apache.curator.framework.recipes.leader.LeaderLatchListener> leaderLatchListener, BlobStore blobStore)
public void prepare(Map conf)
ILeaderElectorMethod guaranteed to be called as part of initialization of leader elector instance.
prepare in interface ILeaderElectorconf - configurationpublic void addToLeaderLockQueue()
throws Exception
ILeaderElectorqueue up for leadership lock. The call returns immediately and the caller must check isLeader() to perform any leadership action. This method can be called multiple times so it needs to be idempotent.
addToLeaderLockQueue in interface ILeaderElectorExceptionpublic void removeFromLeaderLockQueue()
throws Exception
ILeaderElectorRemoves the caller from the leader lock queue. If the caller is leader also releases the lock. This method can be called multiple times so it needs to be idempotent.
removeFromLeaderLockQueue in interface ILeaderElectorExceptionpublic boolean isLeader()
throws Exception
isLeader in interface ILeaderElectorExceptionpublic NimbusInfo getLeader()
getLeader in interface ILeaderElectorpublic List<NimbusInfo> getAllNimbuses() throws Exception
getAllNimbuses in interface ILeaderElectorExceptionpublic void close()
ILeaderElectorMethod called to allow for cleanup. once close this object can not be reused.
close in interface Closeableclose in interface AutoCloseableclose in interface ILeaderElectorCopyright © 2019 The Apache Software Foundation. All Rights Reserved.