Package org.apache.flink.runtime.rpc
Class RpcUtils
- java.lang.Object
-
- org.apache.flink.runtime.rpc.RpcUtils
-
public class RpcUtils extends Object
Utility functions for Flink's RPC implementation.
-
-
Field Summary
Fields Modifier and Type Field Description static DurationINF_DURATIONstatic DurationINF_TIMEOUTHACK: Set to 21474835 seconds, Pekko's maximum delay (Akka 2.4.20).
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static RpcServicecreateRemoteRpcService(RpcSystem rpcSystem, org.apache.flink.configuration.Configuration configuration, String externalAddress, String externalPortRange, String bindAddress, Optional<Integer> bindPort)Convenient shortcut for constructing a remote RPC Service that takes care of checking for null and empty optionals.static Set<Class<? extends RpcGateway>>extractImplementedRpcGateways(Class<?> clazz)Extracts allRpcGatewayinterfaces implemented by the given clazz.static StringgetHostname(RpcService rpcService)Returns the hostname onto which the givenRpcServicehas been bound.static RpcSystem.ForkJoinExecutorConfigurationgetTestForkJoinExecutorConfiguration()static voidterminateRpcEndpoint(RpcEndpoint... rpcEndpoints)Shuts the givenRpcEndpoints down and awaits their termination.static voidterminateRpcService(RpcService... rpcServices)Shuts the given rpc services down and waits for their termination.
-
-
-
Field Detail
-
INF_TIMEOUT
public static final Duration INF_TIMEOUT
HACK: Set to 21474835 seconds, Pekko's maximum delay (Akka 2.4.20). The value cannot be higher or anIllegalArgumentExceptionwill be thrown during an RPC. Check the private methodcheckMaxDelay()inorg.apache.pekko.actor.LightArrayRevolverScheduler.
-
INF_DURATION
public static final Duration INF_DURATION
-
-
Method Detail
-
extractImplementedRpcGateways
public static Set<Class<? extends RpcGateway>> extractImplementedRpcGateways(Class<?> clazz)
Extracts allRpcGatewayinterfaces implemented by the given clazz.- Parameters:
clazz- from which to extract the implemented RpcGateway interfaces- Returns:
- A set of all implemented RpcGateway interfaces
-
terminateRpcEndpoint
@VisibleForTesting public static void terminateRpcEndpoint(RpcEndpoint... rpcEndpoints) throws ExecutionException, InterruptedException
Shuts the givenRpcEndpoints down and awaits their termination.- Parameters:
rpcEndpoints- to terminate- Throws:
ExecutionException- if a problem occurredInterruptedException- if the operation has been interrupted
-
terminateRpcService
@VisibleForTesting public static void terminateRpcService(RpcService... rpcServices) throws InterruptedException, ExecutionException
Shuts the given rpc services down and waits for their termination.- Parameters:
rpcServices- to shut down- Throws:
InterruptedException- if the operation has been interruptedExecutionException- if a problem occurred
-
getHostname
public static String getHostname(RpcService rpcService)
Returns the hostname onto which the givenRpcServicehas been bound. If theRpcServicehas been started in local mode, then the hostname is"hostname".- Parameters:
rpcService- to retrieve the hostname for- Returns:
- hostname onto which the given
RpcServicehas been bound or localhost
-
getTestForkJoinExecutorConfiguration
public static RpcSystem.ForkJoinExecutorConfiguration getTestForkJoinExecutorConfiguration()
-
createRemoteRpcService
public static RpcService createRemoteRpcService(RpcSystem rpcSystem, org.apache.flink.configuration.Configuration configuration, @Nullable String externalAddress, String externalPortRange, @Nullable String bindAddress, Optional<Integer> bindPort) throws Exception
Convenient shortcut for constructing a remote RPC Service that takes care of checking for null and empty optionals.- Throws:
Exception- See Also:
RpcSystem.remoteServiceBuilder(Configuration, String, String)
-
-