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 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 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 the LeaderRetrievalService 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 interface LeaderRetrievalListener
      Parameters:
      leaderAddress - The address of the new leader
      leaderSessionID - The new leader session ID
    • handleError

      public void handleError(Exception exception)
      Description copied from interface: LeaderRetrievalListener
      This method is called by the LeaderRetrievalService in case of an exception. This assures that the LeaderRetrievalListener is aware of any problems occurring in the LeaderRetrievalService thread.
      Specified by:
      handleError in interface LeaderRetrievalListener
    • notifyNewLeaderAddress

      protected void notifyNewLeaderAddress(CompletableFuture<org.apache.flink.api.java.tuple.Tuple2<String,UUID>> newLeaderAddressFuture)