Class LeaderRetriever
java.lang.Object
org.apache.flink.runtime.webmonitor.retriever.LeaderRetriever
- All Implemented Interfaces:
LeaderRetrievalListener
- Direct Known Subclasses:
LeaderGatewayRetriever
Retrieves and stores the current leader address.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCompletableFuture<org.apache.flink.api.java.tuple.Tuple2<String,UUID>> Returns the current JobManagerGateway future.Returns the current leader information if available.voidhandleError(Exception exception) This method is called by theLeaderRetrievalServicein case of an exception.voidnotifyLeaderAddress(String leaderAddress, UUID leaderSessionID) This method is called by theLeaderRetrievalServicewhen a new leader is elected.protected voidnotifyNewLeaderAddress(CompletableFuture<org.apache.flink.api.java.tuple.Tuple2<String, UUID>> newLeaderAddressFuture)
-
Field Details
-
log
protected final org.slf4j.Logger log
-
-
Constructor Details
-
LeaderRetriever
public LeaderRetriever()
-
-
Method Details
-
getLeaderNow
public Optional<org.apache.flink.api.java.tuple.Tuple2<String,UUID>> getLeaderNow() throws ExceptionReturns the current leader information if available. Otherwise it returns an empty optional.- Returns:
- The current leader information if available. Otherwise it returns an empty optional.
- Throws:
Exception- if the leader future has been completed with an exception
-
getLeaderFuture
Returns the current JobManagerGateway future. -
notifyLeaderAddress
Description copied from interface:LeaderRetrievalListenerThis method is called by theLeaderRetrievalServicewhen a new leader is elected.If both arguments are null then it signals that leadership was revoked without a new leader having been elected.
- Specified by:
notifyLeaderAddressin interfaceLeaderRetrievalListener- Parameters:
leaderAddress- The address of the new leaderleaderSessionID- The new leader session ID
-
handleError
Description copied from interface:LeaderRetrievalListenerThis method is called by theLeaderRetrievalServicein case of an exception. This assures that theLeaderRetrievalListeneris aware of any problems occurring in theLeaderRetrievalServicethread.- Specified by:
handleErrorin interfaceLeaderRetrievalListener
-
notifyNewLeaderAddress
protected void notifyNewLeaderAddress(CompletableFuture<org.apache.flink.api.java.tuple.Tuple2<String, UUID>> newLeaderAddressFuture)
-