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 tokenG- 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. ThisRegisteredRpcConnectionimplements 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 Summary
Fields Modifier and Type Field Description protected org.slf4j.LoggerlogThe logger for all log messages of this class.
-
Constructor Summary
Constructors Constructor Description RegisteredRpcConnection(org.slf4j.Logger log, String targetAddress, F fencingToken, Executor executor)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidclose()Close connection.protected abstract RetryingRegistration<F,G,S,R>generateRegistration()This method generate a specific Registration, for example TaskExecutor Registration at the ResourceManager.StringgetTargetAddress()GgetTargetGateway()Gets the RegisteredGateway.FgetTargetLeaderId()booleanisClosed()booleanisConnected()protected abstract voidonRegistrationFailure(Throwable failure)This method handle the Registration failure.protected abstract voidonRegistrationRejection(R rejection)This method handles the Registration rejection.protected abstract voidonRegistrationSuccess(S success)This method handle the Registration Response.voidstart()StringtoString()booleantryReconnect()Tries to reconnect to thetargetAddressby cancelling the pending registration and starting a new pending registration.
-
-
-
Method Detail
-
start
public void start()
-
tryReconnect
public boolean tryReconnect()
Tries to reconnect to thetargetAddressby cancelling the pending registration and starting a new pending registration.- Returns:
falseif the connection has been closed or a concurrent modification has happened; otherwisetrue
-
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()
-
-