Class LeaderRetriever
- java.lang.Object
-
- org.apache.flink.runtime.webmonitor.retriever.LeaderRetriever
-
- All Implemented Interfaces:
LeaderRetrievalListener
- Direct Known Subclasses:
LeaderGatewayRetriever
public class LeaderRetriever extends Object implements LeaderRetrievalListener
Retrieves and stores the current leader address.
-
-
Field Summary
Fields Modifier and Type Field Description protected org.slf4j.Loggerlog
-
Constructor Summary
Constructors Constructor Description LeaderRetriever()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CompletableFuture<org.apache.flink.api.java.tuple.Tuple2<String,UUID>>getLeaderFuture()Returns the current JobManagerGateway future.Optional<org.apache.flink.api.java.tuple.Tuple2<String,UUID>>getLeaderNow()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)
-
-
-
Method Detail
-
getLeaderNow
public Optional<org.apache.flink.api.java.tuple.Tuple2<String,UUID>> getLeaderNow() throws Exception
Returns 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
public CompletableFuture<org.apache.flink.api.java.tuple.Tuple2<String,UUID>> getLeaderFuture()
Returns the current JobManagerGateway future.
-
notifyLeaderAddress
public void notifyLeaderAddress(String leaderAddress, UUID leaderSessionID)
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
public void handleError(Exception exception)
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)
-
-