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 Duration
INF_DURATION
static Duration
INF_TIMEOUT
HACK: 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 RpcService
createRemoteRpcService(RpcSystem rpcSystem, 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 allRpcGateway
interfaces implemented by the given clazz.static String
getHostname(RpcService rpcService)
Returns the hostname onto which the givenRpcService
has been bound.static RpcSystem.ForkJoinExecutorConfiguration
getTestForkJoinExecutorConfiguration()
static void
terminateRpcEndpoint(RpcEndpoint... rpcEndpoints)
Shuts the givenRpcEndpoint
s down and awaits their termination.static void
terminateRpcService(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 anIllegalArgumentException
will be thrown during an RPC. Check the private methodcheckMaxDelay()
inLightArrayRevolverScheduler
.
-
INF_DURATION
public static final Duration INF_DURATION
-
-
Method Detail
-
extractImplementedRpcGateways
public static Set<Class<? extends RpcGateway>> extractImplementedRpcGateways(Class<?> clazz)
Extracts allRpcGateway
interfaces 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 givenRpcEndpoint
s 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 givenRpcService
has been bound. If theRpcService
has been started in local mode, then the hostname is"hostname"
.- Parameters:
rpcService
- to retrieve the hostname for- Returns:
- hostname onto which the given
RpcService
has been bound or localhost
-
getTestForkJoinExecutorConfiguration
public static RpcSystem.ForkJoinExecutorConfiguration getTestForkJoinExecutorConfiguration()
-
createRemoteRpcService
public static RpcService createRemoteRpcService(RpcSystem rpcSystem, 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)
-
-