public interface LeaderElection<T> extends SyncPrimitive
LeaderElector provides the same functionality as AsyncLeaderElection with
the only difference that all its methods block until the corresponding operation completes.DEFAULT_OPERATION_TIMEOUT_MILLIS| Modifier and Type | Method and Description |
|---|---|
void |
addListener(LeadershipEventListener<T> listener)
Registers a listener to be notified of Leadership changes for all topics.
|
boolean |
anoint(T identifier)
Attempts to promote a node to leadership displacing the current leader.
|
AsyncLeaderElection<T> |
async()
Returns the underlying asynchronous primitive.
|
void |
evict(T identifier)
Attempts to evict a node from all leadership elections it is registered for.
|
Leadership<T> |
getLeadership()
Returns the
Leadership for the specified topic. |
boolean |
promote(T identifier)
Attempts to promote a node to top of candidate list.
|
void |
removeListener(LeadershipEventListener<T> listener)
Unregisters a previously registered change notification listener.
|
Leadership<T> |
run(T identifier)
Attempts to become leader for a topic.
|
void |
withdraw(T identifier)
Withdraws from leadership race for a topic.
|
close, deleteaddStateChangeListener, name, protocol, removeStateChangeListener, typeLeadership<T> run(T identifier)
identifier - candidate identifiervoid withdraw(T identifier)
identifier - identifier of the node to withdrawboolean anoint(T identifier)
identifier - identifier of the new leadertrue if leadership transfer was successfully executed; false if it failed.
This operation can return false if the node to be made new leader is not registered to
run for election for the topic.boolean promote(T identifier)
identifier - identifier of the new top candidatetrue if node is now the top candidate. This operation can fail (i.e. return
false) if the node is not registered to run for election for the topic.void evict(T identifier)
If the node the current leader for a topic, this call will force the next candidate (if one exists) to be promoted to leadership.
identifier - identifierLeadership<T> getLeadership()
Leadership for the specified topic.void addListener(LeadershipEventListener<T> listener)
listener - listener to addvoid removeListener(LeadershipEventListener<T> listener)
If the specified listener was not previously registered, this operation will be a noop.
listener - listener to removeAsyncLeaderElection<T> async()
SyncPrimitiveasync in interface SyncPrimitiveCopyright © 2013–2018. All rights reserved.