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)
ILeaderElector
Method guaranteed to be called as part of initialization of leader elector instance.
prepare
in interface ILeaderElector
conf
- configurationpublic void addToLeaderLockQueue() throws Exception
ILeaderElector
queue 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 ILeaderElector
Exception
public void removeFromLeaderLockQueue() throws Exception
ILeaderElector
Removes 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 ILeaderElector
Exception
public boolean isLeader() throws Exception
isLeader
in interface ILeaderElector
Exception
public NimbusInfo getLeader()
getLeader
in interface ILeaderElector
public List<NimbusInfo> getAllNimbuses() throws Exception
getAllNimbuses
in interface ILeaderElector
Exception
public void close()
ILeaderElector
Method called to allow for cleanup. once close this object can not be reused.
close
in interface Closeable
close
in interface AutoCloseable
close
in interface ILeaderElector
Copyright © 2022 The Apache Software Foundation. All Rights Reserved.