Interface LeaderElection
-
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
StandaloneLeaderElection
public interface LeaderElection extends AutoCloseable
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
close()
Closes theLeaderElection
by deregistering theLeaderContender
from the underlying leader election.void
confirmLeadership(UUID leaderSessionID, String leaderAddress)
Confirms that theLeaderContender
has accepted the leadership identified by the given leader session id.boolean
hasLeadership(UUID leaderSessionId)
Returnstrue
if the service'sLeaderContender
has the leadership under the given leader session ID acquired.void
startLeaderElection(LeaderContender contender)
Registers the passedLeaderContender
with the leader election process.
-
-
-
Method Detail
-
startLeaderElection
void startLeaderElection(LeaderContender contender) throws Exception
Registers the passedLeaderContender
with the leader election process.- Throws:
Exception
-
confirmLeadership
void confirmLeadership(UUID leaderSessionID, String leaderAddress)
Confirms that theLeaderContender
has accepted the leadership identified by the given leader session id. It also publishes the leader address under which the leader is reachable.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.- Parameters:
leaderSessionID
- The new leader session IDleaderAddress
- The address of the new leader
-
hasLeadership
boolean hasLeadership(UUID leaderSessionId)
Returnstrue
if the service'sLeaderContender
has the leadership under the given leader session ID acquired.- Parameters:
leaderSessionId
- identifying the current leader- Returns:
- true if the associated
LeaderContender
is the leader, otherwise false
-
close
void close() throws Exception
Closes theLeaderElection
by deregistering theLeaderContender
from the underlying leader election.LeaderContender.revokeLeadership()
will be called if the service still holds the leadership.- Specified by:
close
in interfaceAutoCloseable
- Throws:
Exception
-
-