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