Package org.onosproject.store.service
Interface LeaderElector
- 
- All Superinterfaces:
- DistributedPrimitive
 - All Known Implementing Classes:
- DefaultLeaderElector
 
 public interface LeaderElector extends DistributedPrimitive LeaderElectorprovides the same functionality asAsyncLeaderElectorwith the only difference that all its methods block until the corresponding operation completes.
- 
- 
Nested Class Summary- 
Nested classes/interfaces inherited from interface org.onosproject.store.service.DistributedPrimitiveDistributedPrimitive.Status, DistributedPrimitive.Type
 
- 
 - 
Field Summary- 
Fields inherited from interface org.onosproject.store.service.DistributedPrimitiveDEFAULT_OPERATION_TIMEOUT_MILLIS
 
- 
 - 
Method SummaryAll Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidaddChangeListener(java.util.function.Consumer<Change<Leadership>> consumer)Registers a listener to be notified of Leadership changes for all topics.booleananoint(java.lang.String topic, NodeId nodeId)Attempts to promote a node to leadership displacing the current leader.voidevict(NodeId nodeId)Attempts to evict a node from all leadership elections it is registered for.LeadershipgetLeadership(java.lang.String topic)Returns theLeadershipfor the specified topic.java.util.Map<java.lang.String,Leadership>getLeaderships()Returns the currentLeaderships for all topics.default DistributedPrimitive.TypeprimitiveType()Returns the type of primitive.booleanpromote(java.lang.String topic, NodeId nodeId)Attempts to promote a node to top of candidate list.voidremoveChangeListener(java.util.function.Consumer<Change<Leadership>> consumer)Unregisters a previously registered change notification listener.Leadershiprun(java.lang.String topic, NodeId nodeId)Attempts to become leader for a topic.voidwithdraw(java.lang.String topic)Withdraws from leadership race for a topic.- 
Methods inherited from interface org.onosproject.store.service.DistributedPrimitiveaddStatusChangeListener, applicationId, destroy, name, removeStatusChangeListener, statusChangeListeners
 
- 
 
- 
- 
- 
Method Detail- 
primitiveTypedefault DistributedPrimitive.Type primitiveType() Description copied from interface:DistributedPrimitiveReturns the type of primitive.- Specified by:
- primitiveTypein interface- DistributedPrimitive
- Returns:
- primitive type
 
 - 
runLeadership run(java.lang.String topic, NodeId nodeId) Attempts to become leader for a topic.- Parameters:
- topic- leadership topic
- nodeId- instance identifier of the node
- Returns:
- current Leadership state of the topic
 
 - 
withdrawvoid withdraw(java.lang.String topic) Withdraws from leadership race for a topic.- Parameters:
- topic- leadership topic
 
 - 
anointboolean anoint(java.lang.String topic, NodeId nodeId)Attempts to promote a node to leadership displacing the current leader.- Parameters:
- topic- leadership topic
- nodeId- instance identifier of the new leader
- Returns:
- trueif leadership transfer was successfully executed;- falseif it failed. This operation can return- falseif the node to be made new leader is not registered to run for election for the topic.
 
 - 
promoteboolean promote(java.lang.String topic, NodeId nodeId)Attempts to promote a node to top of candidate list.- Parameters:
- topic- leadership topic
- nodeId- instance identifier of the new top candidate
- Returns:
- trueif 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.
 
 - 
evictvoid evict(NodeId nodeId) Attempts to evict a node from all leadership elections it is registered for.If the node the current leader for a topic, this call will force the next candidate (if one exists) to be promoted to leadership. - Parameters:
- nodeId- node instance identifier
 
 - 
getLeadershipLeadership getLeadership(java.lang.String topic) Returns theLeadershipfor the specified topic.- Parameters:
- topic- leadership topic
- Returns:
- current Leadership state of the topic
 
 - 
getLeadershipsjava.util.Map<java.lang.String,Leadership> getLeaderships() Returns the currentLeaderships for all topics.- Returns:
- topic name to Leadership mapping
 
 - 
addChangeListenervoid addChangeListener(java.util.function.Consumer<Change<Leadership>> consumer) Registers a listener to be notified of Leadership changes for all topics.- Parameters:
- consumer- listener to add
 
 - 
removeChangeListenervoid removeChangeListener(java.util.function.Consumer<Change<Leadership>> consumer) Unregisters a previously registered change notification listener.If the specified listener was not previously registered, this operation will be a noop. - Parameters:
- consumer- listener to remove
 
 
- 
 
-