Class FencedPekkoInvocationHandler<F extends Serializable>
- java.lang.Object
-
- org.apache.flink.runtime.rpc.pekko.FencedPekkoInvocationHandler<F>
-
- Type Parameters:
F
- type of the fencing token
- All Implemented Interfaces:
InvocationHandler
,FencedRpcGateway<F>
,MainThreadExecutable
,RpcGateway
,RpcServer
,StartStoppable
public class FencedPekkoInvocationHandler<F extends Serializable> extends Object implements MainThreadExecutable, FencedRpcGateway<F>
Fenced extension of thePekkoInvocationHandler
. This invocation handler will be used in combination with theFencedRpcEndpoint
. The fencing is done by wrapping all messages in aFencedMessage
.
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
forceRpcInvocationSerialization
protected boolean
isLocal
-
Constructor Summary
Constructors Constructor Description FencedPekkoInvocationHandler(String address, String hostname, org.apache.pekko.actor.ActorRef rpcEndpoint, Duration timeout, long maximumFramesize, boolean forceRpcInvocationSerialization, CompletableFuture<Void> terminationFuture, Supplier<F> fencingTokenSupplier, boolean captureAskCallStacks, ClassLoader flinkClassLoader)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CompletableFuture<?>
ask(Object message, Duration timeout)
Sends the message to the RPC endpoint and returns a future containing its response.<V> CompletableFuture<V>
callAsync(Callable<V> callable, Duration callTimeout)
Execute the callable in the main thread of the underlying RPC endpoint and return a future for the callable result.org.apache.pekko.actor.ActorRef
getActorRef()
String
getAddress()
Returns the fully qualified address under which the associated rpc endpoint is reachable.F
getFencingToken()
Get the current fencing token.String
getHostname()
Returns the fully qualified hostname under which the associated rpc endpoint is reachable.CompletableFuture<Void>
getTerminationFuture()
Return a future which is completed when the rpc endpoint has been terminated.Object
invoke(Object proxy, Method method, Object[] args)
void
runAsync(Runnable runnable)
Execute the runnable in the main thread of the underlying RPC endpoint.void
scheduleRunAsync(Runnable runnable, long delayMillis)
Execute the runnable in the main thread of the underlying RPC endpoint, with a delay of the given number of milliseconds.void
start()
Starts the processing of remote procedure calls.void
stop()
Stops the processing of remote procedure calls.void
tell(Object message)
Sends the message to the RPC endpoint.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.flink.runtime.rpc.MainThreadExecutable
callAsync, runAsync, scheduleRunAsync
-
Methods inherited from interface org.apache.flink.runtime.rpc.RpcGateway
getAddress, getHostname
-
-
-
-
Constructor Detail
-
FencedPekkoInvocationHandler
public FencedPekkoInvocationHandler(String address, String hostname, org.apache.pekko.actor.ActorRef rpcEndpoint, Duration timeout, long maximumFramesize, boolean forceRpcInvocationSerialization, @Nullable CompletableFuture<Void> terminationFuture, Supplier<F> fencingTokenSupplier, boolean captureAskCallStacks, ClassLoader flinkClassLoader)
-
-
Method Detail
-
invoke
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
- Specified by:
invoke
in interfaceInvocationHandler
- Throws:
Throwable
-
tell
public void tell(Object message)
Sends the message to the RPC endpoint.- Parameters:
message
- to send to the RPC endpoint.
-
ask
public CompletableFuture<?> ask(Object message, Duration timeout)
Sends the message to the RPC endpoint and returns a future containing its response.- Parameters:
message
- to send to the RPC endpointtimeout
- time to wait until the response future is failed with aTimeoutException
- Returns:
- Response future
-
getFencingToken
public F getFencingToken()
Description copied from interface:FencedRpcGateway
Get the current fencing token.- Specified by:
getFencingToken
in interfaceFencedRpcGateway<F extends Serializable>
- Returns:
- current fencing token
-
getActorRef
public org.apache.pekko.actor.ActorRef getActorRef()
-
runAsync
public void runAsync(Runnable runnable)
Description copied from interface:MainThreadExecutable
Execute the runnable in the main thread of the underlying RPC endpoint.- Specified by:
runAsync
in interfaceMainThreadExecutable
- Parameters:
runnable
- Runnable to be executed
-
scheduleRunAsync
public void scheduleRunAsync(Runnable runnable, long delayMillis)
Description copied from interface:MainThreadExecutable
Execute the runnable in the main thread of the underlying RPC endpoint, with a delay of the given number of milliseconds.- Specified by:
scheduleRunAsync
in interfaceMainThreadExecutable
- Parameters:
runnable
- Runnable to be executeddelayMillis
- The delay, in milliseconds, after which the runnable will be executed
-
callAsync
public <V> CompletableFuture<V> callAsync(Callable<V> callable, Duration callTimeout)
Description copied from interface:MainThreadExecutable
Execute the callable in the main thread of the underlying RPC endpoint and return a future for the callable result. If the future is not completed within the given timeout, the returned future will throw aTimeoutException
.- Specified by:
callAsync
in interfaceMainThreadExecutable
- Type Parameters:
V
- Return value of the callable- Parameters:
callable
- Callable to be executedcallTimeout
- Timeout for the future to complete- Returns:
- Future of the callable result
-
start
public void start()
Description copied from interface:StartStoppable
Starts the processing of remote procedure calls.- Specified by:
start
in interfaceStartStoppable
-
stop
public void stop()
Description copied from interface:StartStoppable
Stops the processing of remote procedure calls.- Specified by:
stop
in interfaceStartStoppable
-
getAddress
public String getAddress()
Description copied from interface:RpcGateway
Returns the fully qualified address under which the associated rpc endpoint is reachable.- Specified by:
getAddress
in interfaceRpcGateway
- Returns:
- Fully qualified (RPC) address under which the associated rpc endpoint is reachable
-
getHostname
public String getHostname()
Description copied from interface:RpcGateway
Returns the fully qualified hostname under which the associated rpc endpoint is reachable.- Specified by:
getHostname
in interfaceRpcGateway
- Returns:
- Fully qualified hostname under which the associated rpc endpoint is reachable
-
getTerminationFuture
public CompletableFuture<Void> getTerminationFuture()
Description copied from interface:RpcServer
Return a future which is completed when the rpc endpoint has been terminated.- Specified by:
getTerminationFuture
in interfaceRpcServer
- Returns:
- Future indicating when the rpc endpoint has been terminated
-
-