public interface LeadershipService
| Modifier and Type | Method and Description |
|---|---|
void |
addListener(LeadershipEventListener listener)
Registers a event listener to be notified of leadership events.
|
Map<String,List<NodeId>> |
getCandidates()
Returns the candidates for all known topics.
|
List<NodeId> |
getCandidates(String path)
Returns the candidates for a given topic.
|
NodeId |
getLeader(String path)
Returns the current leader for the topic.
|
Map<String,Leadership> |
getLeaderBoard()
Returns the current leader board.
|
Leadership |
getLeadership(String path)
Returns the current leadership info for the topic.
|
boolean |
makeTopCandidate(String path,
NodeId nodeId)
Moves the specified nodeId to the top of the candidates list for the topic.
|
Set<String> |
ownedTopics(NodeId nodeId)
Returns the set of topics owned by the specified node.
|
void |
removeListener(LeadershipEventListener listener)
Unregisters a event listener for leadership events.
|
CompletableFuture<Leadership> |
runForLeadership(String path)
Joins the leadership contest.
|
boolean |
stepdown(String path)
If the local nodeId is the leader for specified topic, this method causes it to
step down temporarily from leadership.
|
CompletableFuture<Void> |
withdraw(String path)
Withdraws from a leadership contest.
|
NodeId getLeader(String path)
path - topicLeadership getLeadership(String path)
path - topicSet<String> ownedTopics(NodeId nodeId)
nodeId - node Id.CompletableFuture<Leadership> runForLeadership(String path)
path - topic for which this controller node wishes to be a leaderLeadership futureCompletableFuture<Void> withdraw(String path)
path - topic for which this controller node no longer wishes to be a leaderboolean stepdown(String path)
The node will continue to be in contention for leadership and can potentially become the leader again if and when it becomes the highest priority candidate
If the local nodeId is not the leader, this method will make no changes and simply return false.
path - topic for which this controller node should give up leadershipboolean makeTopCandidate(String path, NodeId nodeId)
If the node is not a candidate for this topic, this method will be a noop.
path - leadership topicnodeId - nodeId to make the top candidateMap<String,Leadership> getLeaderBoard()
Map<String,List<NodeId>> getCandidates()
List<NodeId> getCandidates(String path)
path - topicvoid addListener(LeadershipEventListener listener)
listener - listener that will asynchronously notified of leadership events.void removeListener(LeadershipEventListener listener)
listener - listener to be removed.Copyright © 2015. All rights reserved.