Interface LeaderElection
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
StandaloneLeaderElection
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes theLeaderElectionby deregistering theLeaderContenderfrom the underlying leader election.confirmLeadershipAsync(UUID leaderSessionID, String leaderAddress) Confirms that theLeaderContenderhas accepted the leadership identified by the given leader session id.hasLeadershipAsync(UUID leaderSessionId) Returnstrueif the service'sLeaderContenderhas the leadership under the given leader session ID acquired.voidstartLeaderElection(LeaderContender contender) Registers the passedLeaderContenderwith the leader election process.
-
Method Details
-
startLeaderElection
Registers the passedLeaderContenderwith the leader election process.- Throws:
Exception
-
confirmLeadershipAsync
Confirms that theLeaderContenderhas accepted the leadership identified by the given leader session id. It also publishes the leader address under which the leader is reachable.The data is only confirmed if the leadership is still acquired.
The intention of this method is to establish an order between setting the new leader session ID in the
LeaderContenderand publishing the new leader session ID and the related leader address to the leader retrieval services.- Parameters:
leaderSessionID- The new leader session IDleaderAddress- The address of the new leader
-
hasLeadershipAsync
Returnstrueif the service'sLeaderContenderhas the leadership under the given leader session ID acquired.- Parameters:
leaderSessionId- identifying the current leader- Returns:
- true if the associated
LeaderContenderis the leader, otherwise false
-
close
Closes theLeaderElectionby deregistering theLeaderContenderfrom the underlying leader election.LeaderContender.revokeLeadership()will be called if the service still holds the leadership.- Specified by:
closein interfaceAutoCloseable- Throws:
Exception
-