public interface LeaderElectionService
Prior to using this service, it has to be started calling the start method. The start method takes the contender as a parameter. If there are multiple contenders, then each contender has to instantiate its own leader election service.
Once a contender has been granted leadership he has to confirm the received leader session ID
by calling the method confirmLeadership(UUID, String)
. This will notify the leader
election service, that the contender has accepted the leadership specified and that the leader
session id as well as the leader address can now be published for leader retrieval services.
Modifier and Type | Method and Description |
---|---|
void |
confirmLeadership(UUID leaderSessionID,
String leaderAddress)
Confirms that the
LeaderContender has accepted the leadership identified by the given
leader session id. |
boolean |
hasLeadership(UUID leaderSessionId)
Returns true if the
LeaderContender with which the service has been started owns
currently the leadership under the given leader session id. |
void |
start(LeaderContender contender)
Starts the leader election service.
|
void |
stop()
Stops the leader election service.
|
void start(LeaderContender contender) throws Exception
contender
- LeaderContender which applies for the leadershipException
void confirmLeadership(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 rational behind this method is to establish an order between setting the new leader
session ID in the LeaderContender
and publishing the new leader session ID as well as
the leader address to the leader retrieval services.
leaderSessionID
- The new leader session IDleaderAddress
- The address of the new leaderboolean hasLeadership(@Nonnull UUID leaderSessionId)
LeaderContender
with which the service has been started owns
currently the leadership under the given leader session id.leaderSessionId
- identifying the current leaderLeaderContender
is the leader, otherwise falseCopyright © 2014–2024 The Apache Software Foundation. All rights reserved.