public interface LeadershipService extends ListenerService<LeadershipEvent,LeadershipEventListener>
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.
| Modifier and Type | Method and Description |
|---|---|
default Map<String,List<NodeId>> |
getCandidates()
Deprecated.
1.6.0 Goldeneye release. Replace usages with
getLeadership(String) |
default List<NodeId> |
getCandidates(String topic)
Returns the candidate nodes for a given topic.
|
default NodeId |
getLeader(String topic)
Returns the
node identifier that is the current leader for a topic. |
Map<String,Leadership> |
getLeaderBoard()
Deprecated.
1.6.0 Goldeneye release. Replace usages with
getLeadership(String) |
Leadership |
getLeadership(String topic)
Returns the current
leadership for a topic. |
default Set<String> |
ownedTopics(NodeId nodeId)
Returns the set of topics owned by the specified
node. |
Leadership |
runForLeadership(String topic)
Enters a leadership contest.
|
void |
withdraw(String topic)
Withdraws from a leadership contest.
|
addListener, removeListenerdefault NodeId getLeader(String topic)
node identifier that is the current leader for a topic.topic - leadership topicnull if there is no leader for the topicLeadership getLeadership(String topic)
leadership for a topic.topic - leadership topicnull if no such topic existsdefault Set<String> ownedTopics(NodeId nodeId)
node.nodeId - node identifier.Leadership runForLeadership(String topic)
topic - leadership topicLeadership futurevoid withdraw(String topic)
topic - leadership topic@Deprecated Map<String,Leadership> getLeaderBoard()
getLeadership(String)@Deprecated default Map<String,List<NodeId>> getCandidates()
getLeadership(String)