Class RegisteredRpcConnection<F extends Serializable,G extends org.apache.flink.runtime.rpc.RpcGateway,S extends RegistrationResponse.Success,R extends RegistrationResponse.Rejection>

java.lang.Object
org.apache.flink.runtime.registration.RegisteredRpcConnection<F,G,S,R>
Type Parameters:
F - The type of the fencing token
G - The type of the gateway to connect to.
S - The type of the successful registration responses.
R - The type of the registration rejection responses.
Direct Known Subclasses:
TaskExecutorToResourceManagerConnection

public abstract class RegisteredRpcConnection<F extends Serializable,G extends org.apache.flink.runtime.rpc.RpcGateway,S extends RegistrationResponse.Success,R extends RegistrationResponse.Rejection> extends Object
This utility class implements the basis of RPC connecting from one component to another component, for example the RPC connection from TaskExecutor to ResourceManager. This RegisteredRpcConnection implements registration and get target gateway.

The registration gives access to a future that is completed upon successful registration. The RPC connection can be closed, for example when the target where it tries to register loses leader status.

  • Field Details

    • log

      protected final org.slf4j.Logger log
      The logger for all log messages of this class.
  • Constructor Details

    • RegisteredRpcConnection

      public RegisteredRpcConnection(org.slf4j.Logger log, String targetAddress, F fencingToken, Executor executor)
  • Method Details

    • start

      public void start()
    • tryReconnect

      public boolean tryReconnect()
      Tries to reconnect to the targetAddress by cancelling the pending registration and starting a new pending registration.
      Returns:
      false if the connection has been closed or a concurrent modification has happened; otherwise true
    • generateRegistration

      protected abstract RetryingRegistration<F,G,S,R> generateRegistration()
      This method generate a specific Registration, for example TaskExecutor Registration at the ResourceManager.
    • onRegistrationSuccess

      protected abstract void onRegistrationSuccess(S success)
      This method handle the Registration Response.
    • onRegistrationRejection

      protected abstract void onRegistrationRejection(R rejection)
      This method handles the Registration rejection.
      Parameters:
      rejection - rejection containing additional information about the rejection
    • onRegistrationFailure

      protected abstract void onRegistrationFailure(Throwable failure)
      This method handle the Registration failure.
    • close

      public void close()
      Close connection.
    • isClosed

      public boolean isClosed()
    • getTargetLeaderId

      public F getTargetLeaderId()
    • getTargetAddress

      public String getTargetAddress()
    • getTargetGateway

      public G getTargetGateway()
      Gets the RegisteredGateway. This returns null until the registration is completed.
    • isConnected

      public boolean isConnected()
    • toString

      public String toString()
      Overrides:
      toString in class Object