Class StandaloneLeaderElection
java.lang.Object
org.apache.flink.runtime.leaderelection.StandaloneLeaderElection
- All Implemented Interfaces:
AutoCloseable,LeaderElection
StandaloneLeaderElection implements LeaderElection for non-HA cases. This
implementation can be used for testing, and for cluster setups that do not tolerate failures of
the main components (e.g. ResourceManager or Dispatcher).-
Constructor Summary
Constructors -
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.
-
Constructor Details
-
StandaloneLeaderElection
-
-
Method Details
-
startLeaderElection
Description copied from interface:LeaderElectionRegisters the passedLeaderContenderwith the leader election process.- Specified by:
startLeaderElectionin interfaceLeaderElection- Throws:
Exception
-
confirmLeadershipAsync
Description copied from interface:LeaderElectionConfirms 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.- Specified by:
confirmLeadershipAsyncin interfaceLeaderElection- Parameters:
leaderSessionID- The new leader session IDleaderAddress- The address of the new leader
-
hasLeadershipAsync
Description copied from interface:LeaderElectionReturnstrueif the service'sLeaderContenderhas the leadership under the given leader session ID acquired.- Specified by:
hasLeadershipAsyncin interfaceLeaderElection- Parameters:
leaderSessionId- identifying the current leader- Returns:
- true if the associated
LeaderContenderis the leader, otherwise false
-
close
Description copied from interface:LeaderElectionCloses theLeaderElectionby deregistering theLeaderContenderfrom the underlying leader election.LeaderContender.revokeLeadership()will be called if the service still holds the leadership.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceLeaderElection- Throws:
Exception
-