public class StandaloneLeaderElectionService extends Object implements LeaderElectionService
LeaderElectionService interface. The standalone
implementation assumes that there is only a single LeaderContender and thus directly
grants him the leadership upon start up. Furthermore, there is no communication needed between
multiple standalone leader election services.| Constructor and Description |
|---|
StandaloneLeaderElectionService() |
| Modifier and Type | Method and Description |
|---|---|
void |
confirmLeaderSessionID(UUID leaderSessionID)
Confirms that the new leader session ID has been successfully received by the new leader.
|
boolean |
hasLeadership()
Returns true if the
LeaderContender with which the service has been started owns
currently the leadership. |
void |
start(LeaderContender newContender)
Starts the leader election service.
|
void |
stop()
Stops the leader election service.
|
public void start(LeaderContender newContender) throws Exception
LeaderElectionServicestart in interface LeaderElectionServicenewContender - LeaderContender which applies for the leadershipExceptionpublic void stop()
LeaderElectionServicestop in interface LeaderElectionServicepublic void confirmLeaderSessionID(UUID leaderSessionID)
LeaderElectionServiceLeaderContender.
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 to the
leader retrieval services.confirmLeaderSessionID in interface LeaderElectionServiceleaderSessionID - The new leader session IDpublic boolean hasLeadership()
LeaderElectionServiceLeaderContender with which the service has been started owns
currently the leadership.hasLeadership in interface LeaderElectionServiceLeaderContender is the leader, otherwise falseCopyright © 2014–2016 The Apache Software Foundation. All rights reserved.