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.Logger
log
-
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.void
handleError(Exception exception)
This method is called by theLeaderRetrievalService
in case of an exception.void
notifyLeaderAddress(String leaderAddress, UUID leaderSessionID)
This method is called by theLeaderRetrievalService
when a new leader is elected.protected void
notifyNewLeaderAddress(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:LeaderRetrievalListener
This method is called by theLeaderRetrievalService
when 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:
notifyLeaderAddress
in interfaceLeaderRetrievalListener
- Parameters:
leaderAddress
- The address of the new leaderleaderSessionID
- The new leader session ID
-
handleError
public void handleError(Exception exception)
Description copied from interface:LeaderRetrievalListener
This method is called by theLeaderRetrievalService
in case of an exception. This assures that theLeaderRetrievalListener
is aware of any problems occurring in theLeaderRetrievalService
thread.- Specified by:
handleError
in interfaceLeaderRetrievalListener
-
notifyNewLeaderAddress
protected void notifyNewLeaderAddress(CompletableFuture<org.apache.flink.api.java.tuple.Tuple2<String,UUID>> newLeaderAddressFuture)
-
-