public interface LeaderElection extends AutoCloseable
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the
LeaderElection by deregistering the LeaderContender from the
underlying leader election. |
CompletableFuture<Void> |
confirmLeadershipAsync(UUID leaderSessionID,
String leaderAddress)
Confirms that the
LeaderContender has accepted the leadership identified by the given
leader session id. |
CompletableFuture<Boolean> |
hasLeadershipAsync(UUID leaderSessionId)
Returns
true if the service's LeaderContender has the leadership under the
given leader session ID acquired. |
void |
startLeaderElection(LeaderContender contender)
Registers the passed
LeaderContender with the leader election process. |
void startLeaderElection(LeaderContender contender) throws Exception
LeaderContender with the leader election process.ExceptionCompletableFuture<Void> confirmLeadershipAsync(UUID leaderSessionID, String leaderAddress)
LeaderContender has 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 LeaderContender and publishing the new leader session ID and the
related leader address to the leader retrieval services.
leaderSessionID - The new leader session IDleaderAddress - The address of the new leaderCompletableFuture<Boolean> hasLeadershipAsync(UUID leaderSessionId)
true if the service's LeaderContender has the leadership under the
given leader session ID acquired.leaderSessionId - identifying the current leaderLeaderContender is the leader, otherwise falsevoid close()
throws Exception
LeaderElection by deregistering the LeaderContender from the
underlying leader election. LeaderContender.revokeLeadership() will be called if the
service still holds the leadership.close in interface AutoCloseableExceptionCopyright © 2014–2025 The Apache Software Foundation. All rights reserved.