F
- type of the fencing tokenpublic class FencedAkkaInvocationHandler<F extends Serializable> extends Object implements FencedMainThreadExecutable, FencedRpcGateway<F>
AkkaInvocationHandler
. This invocation handler will be used in combination
with the FencedRpcEndpoint
. The fencing is done by wrapping all messages in a FencedMessage
.Modifier and Type | Field and Description |
---|---|
protected boolean |
isLocal |
Constructor and Description |
---|
FencedAkkaInvocationHandler(String address,
String hostname,
akka.actor.ActorRef rpcEndpoint,
Time timeout,
long maximumFramesize,
CompletableFuture<Boolean> terminationFuture,
CompletableFuture<Void> internalTerminationFuture,
java.util.function.Supplier<F> fencingTokenSupplier) |
Modifier and Type | Method and Description |
---|---|
CompletableFuture<?> |
ask(Object message,
Time timeout)
Sends the message to the RPC endpoint and returns a future containing
its response.
|
<V> CompletableFuture<V> |
callAsync(Callable<V> callable,
Time callTimeout)
Execute the callable in the main thread of the underlying RPC endpoint and return a future for
the callable result.
|
<V> CompletableFuture<V> |
callAsyncWithoutFencing(Callable<V> callable,
Time timeout)
Run the given callable in the main thread without attaching a fencing token.
|
protected RpcInvocation |
createRpcInvocationMessage(String methodName,
Class<?>[] parameterTypes,
Object[] args)
Create the RpcInvocation message for the given RPC.
|
akka.actor.ActorRef |
getActorRef()
Returns the
ActorRef of the underlying RPC actor. |
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> |
getInternalTerminationFuture()
Returns the internal termination future.
|
CompletableFuture<Boolean> |
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 |
runAsyncWithoutFencing(Runnable runnable)
Run the given runnable in the main thread without attaching a fencing token.
|
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.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
callAsync, runAsync, scheduleRunAsync
getAddress, getHostname
public FencedAkkaInvocationHandler(String address, String hostname, akka.actor.ActorRef rpcEndpoint, Time timeout, long maximumFramesize, @Nullable CompletableFuture<Boolean> terminationFuture, @Nullable CompletableFuture<Void> internalTerminationFuture, java.util.function.Supplier<F> fencingTokenSupplier)
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
invoke
in interface InvocationHandler
Throwable
public void runAsyncWithoutFencing(Runnable runnable)
FencedMainThreadExecutable
runAsyncWithoutFencing
in interface FencedMainThreadExecutable
runnable
- to run in the main thread without validating the fencing token.public <V> CompletableFuture<V> callAsyncWithoutFencing(Callable<V> callable, Time timeout)
FencedMainThreadExecutable
callAsyncWithoutFencing
in interface FencedMainThreadExecutable
V
- type of the callable resultcallable
- to run in the main thread without validating the fencing token.timeout
- for the operationpublic void tell(Object message)
message
- to send to the RPC endpoint.public CompletableFuture<?> ask(Object message, Time timeout)
message
- to send to the RPC endpointtimeout
- time to wait until the response future is failed with a TimeoutException
public F getFencingToken()
FencedRpcGateway
getFencingToken
in interface FencedRpcGateway<F extends Serializable>
public akka.actor.ActorRef getActorRef()
ActorRef
of the underlying RPC actor.ActorRef
of the underlying RPC actorpublic void runAsync(Runnable runnable)
MainThreadExecutable
runAsync
in interface MainThreadExecutable
runnable
- Runnable to be executedpublic void scheduleRunAsync(Runnable runnable, long delayMillis)
MainThreadExecutable
scheduleRunAsync
in interface MainThreadExecutable
runnable
- Runnable to be executeddelayMillis
- The delay, in milliseconds, after which the runnable will be executedpublic <V> CompletableFuture<V> callAsync(Callable<V> callable, Time callTimeout)
MainThreadExecutable
TimeoutException
.callAsync
in interface MainThreadExecutable
V
- Return value of the callablecallable
- Callable to be executedcallTimeout
- Timeout for the future to completepublic void start()
StartStoppable
start
in interface StartStoppable
public void stop()
StartStoppable
stop
in interface StartStoppable
protected RpcInvocation createRpcInvocationMessage(String methodName, Class<?>[] parameterTypes, Object[] args) throws IOException
methodName
- of the RPCparameterTypes
- of the RPCargs
- of the RPCIOException
- if we cannot serialize the RPC invocation parameterspublic String getAddress()
RpcGateway
getAddress
in interface RpcGateway
public String getHostname()
RpcGateway
getHostname
in interface RpcGateway
public CompletableFuture<Boolean> getTerminationFuture()
RpcServer
getTerminationFuture
in interface RpcServer
public CompletableFuture<Void> getInternalTerminationFuture()
Copyright © 2014–2018 The Apache Software Foundation. All rights reserved.