Package org.onosproject.cluster
Interface LeadershipService
- 
- All Superinterfaces:
 ListenerService<LeadershipEvent,LeadershipEventListener>
public interface LeadershipService extends ListenerService<LeadershipEvent,LeadershipEventListener>
Service for leader election.Leadership contests are organized around topics. A instance can join the leadership race for a topic or withdraw from a race it has previously joined.
Listeners can be added to receive notifications asynchronously for various leadership contests.
When a node gets elected as a leader for a topic, all nodes receive notifications indicating a change in leadership.
 
- 
- 
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default List<NodeId>getCandidates(String topic)Returns the candidate nodes for a given topic.default NodeIdgetLeader(String topic)Returns thenode identifierthat is the current leader for a topic.LeadershipgetLeadership(String topic)Returns the currentleadershipfor a topic.Set<String>ownedTopics(NodeId nodeId)Returns the set of topics owned by the specifiednode.LeadershiprunForLeadership(String topic)Enters a leadership contest.voidwithdraw(String topic)Withdraws from a leadership contest.- 
Methods inherited from interface org.onosproject.event.ListenerService
addListener, removeListener 
 - 
 
 - 
 
- 
- 
Method Detail
- 
getLeader
default NodeId getLeader(String topic)
Returns thenode identifierthat is the current leader for a topic.- Parameters:
 topic- leadership topic- Returns:
 - node identifier of the current leader; 
nullif there is no leader for the topic 
 
- 
getLeadership
Leadership getLeadership(String topic)
Returns the currentleadershipfor a topic.- Parameters:
 topic- leadership topic- Returns:
 - leadership or 
nullif no such topic exists 
 
- 
ownedTopics
Set<String> ownedTopics(NodeId nodeId)
Returns the set of topics owned by the specifiednode.- Parameters:
 nodeId- node identifier.- Returns:
 - set of topics for which this node is the current leader.
 
 
- 
runForLeadership
Leadership runForLeadership(String topic)
Enters a leadership contest.- Parameters:
 topic- leadership topic- Returns:
 Leadershipfuture
 
- 
withdraw
void withdraw(String topic)
Withdraws from a leadership contest.- Parameters:
 topic- leadership topic
 
 - 
 
 -