public class ExecutingAsyncLeaderElector extends ExecutingDistributedPrimitive implements AsyncLeaderElector
AsyncLeaderElector that executes asynchronous callbacks on a user provided
Executor.DistributedPrimitive.Status, DistributedPrimitive.TypeDEFAULT_OPERTATION_TIMEOUT_MILLIS| Constructor and Description |
|---|
ExecutingAsyncLeaderElector(AsyncLeaderElector delegateElector,
Executor orderedExecutor,
Executor threadPoolExecutor) |
| Modifier and Type | Method and Description |
|---|---|
CompletableFuture<Void> |
addChangeListener(Consumer<Change<Leadership>> listener)
Registers a listener to be notified of Leadership changes for all topics.
|
CompletableFuture<Boolean> |
anoint(String topic,
NodeId nodeId)
Attempts to promote a node to leadership displacing the current leader.
|
CompletableFuture<Void> |
evict(NodeId nodeId)
Attempts to evict a node from all leadership elections it is registered for.
|
CompletableFuture<Leadership> |
getLeadership(String topic)
Returns the
Leadership for the specified topic. |
CompletableFuture<Map<String,Leadership>> |
getLeaderships()
Returns the current
Leaderships for all topics. |
CompletableFuture<Boolean> |
promote(String topic,
NodeId nodeId)
Attempts to promote a node to top of candidate list without displacing the current leader.
|
CompletableFuture<Void> |
removeChangeListener(Consumer<Change<Leadership>> listener)
Unregisters a previously registered change notification listener.
|
CompletableFuture<Leadership> |
run(String topic,
NodeId nodeId)
Attempts to become leader for a topic.
|
CompletableFuture<Void> |
withdraw(String topic)
Withdraws from leadership race for a topic.
|
addStatusChangeListener, asyncFuture, destroy, removeStatusChangeListenerapplicationId, equals, hashCode, name, primitiveType, statusChangeListeners, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitasLeaderElector, asLeaderElector, primitiveTypeaddStatusChangeListener, applicationId, destroy, name, removeStatusChangeListener, statusChangeListenerspublic ExecutingAsyncLeaderElector(AsyncLeaderElector delegateElector, Executor orderedExecutor, Executor threadPoolExecutor)
public CompletableFuture<Leadership> run(String topic, NodeId nodeId)
AsyncLeaderElectorrun in interface AsyncLeaderElectortopic - leadership topicnodeId - instance identifier of the nodepublic CompletableFuture<Void> withdraw(String topic)
AsyncLeaderElectorwithdraw in interface AsyncLeaderElectortopic - leadership topicpublic CompletableFuture<Boolean> anoint(String topic, NodeId nodeId)
AsyncLeaderElectoranoint in interface AsyncLeaderElectortopic - leadership topicnodeId - instance identifier of the new leaderpublic CompletableFuture<Void> evict(NodeId nodeId)
AsyncLeaderElectorIf the node is the current leader for a topic, this call will promote the next top candidate (if one exists) to leadership.
evict in interface AsyncLeaderElectornodeId - node instance identifierpublic CompletableFuture<Boolean> promote(String topic, NodeId nodeId)
AsyncLeaderElectorpromote in interface AsyncLeaderElectortopic - leadership topicnodeId - instance identifier of the new top candidatepublic CompletableFuture<Leadership> getLeadership(String topic)
AsyncLeaderElectorLeadership for the specified topic.getLeadership in interface AsyncLeaderElectortopic - leadership topicpublic CompletableFuture<Map<String,Leadership>> getLeaderships()
AsyncLeaderElectorLeaderships for all topics.getLeaderships in interface AsyncLeaderElectorpublic CompletableFuture<Void> addChangeListener(Consumer<Change<Leadership>> listener)
AsyncLeaderElectoraddChangeListener in interface AsyncLeaderElectorlistener - listener to notifypublic CompletableFuture<Void> removeChangeListener(Consumer<Change<Leadership>> listener)
AsyncLeaderElectorIf the specified listener was not previously registered, this operation will be a noop.
removeChangeListener in interface AsyncLeaderElectorlistener - listener to remove