@ThreadSafe public class AkkaRpcService extends Object implements RpcService
RpcService implementation. The RPC service starts an Akka actor to receive
RPC invocations from a RpcGateway.| Constructor and Description |
|---|
AkkaRpcService(akka.actor.ActorSystem actorSystem,
Time timeout) |
| Modifier and Type | Method and Description |
|---|---|
<C extends RpcGateway> |
connect(String address,
Class<C> clazz)
Connect to a remote rpc server under the provided address.
|
<T> Future<T> |
execute(Callable<T> callable)
Execute the given callable and return its result as a
Future. |
void |
execute(Runnable runnable)
Execute the given runnable in the executor of the RPC service.
|
String |
getAddress()
Return the hostname or host address under which the rpc service can be reached.
|
Executor |
getExecutor()
Gets the executor, provided by this RPC service.
|
ScheduledExecutor |
getScheduledExecutor()
Gets a scheduled executor from the RPC service.
|
Future<Void> |
getTerminationFuture()
Returns a future indicating when the RPC service has been shut down.
|
ScheduledFuture<?> |
scheduleRunnable(Runnable runnable,
long delay,
TimeUnit unit)
Execute the runnable in the execution context of this RPC Service, as returned by
RpcService.getExecutor(), after a scheduled delay. |
<C extends RpcGateway,S extends RpcEndpoint<C>> |
startServer(S rpcEndpoint)
Start a rpc server which forwards the remote procedure calls to the provided rpc endpoint.
|
void |
stopServer(RpcGateway selfGateway)
Stop the underlying rpc server of the provided self gateway.
|
void |
stopService()
Stop the rpc service shutting down all started rpc servers.
|
public AkkaRpcService(akka.actor.ActorSystem actorSystem,
Time timeout)
public String getAddress()
RpcServicegetAddress in interface RpcServicepublic <C extends RpcGateway> Future<C> connect(String address, Class<C> clazz)
RpcServiceRpcConnectionException.connect in interface RpcServiceC - Type of the rpc gateway to returnaddress - Address of the remote rpc serverclazz - Class of the rpc gateway to returnRpcConnectionException if the
connection attempt failedpublic <C extends RpcGateway,S extends RpcEndpoint<C>> C startServer(S rpcEndpoint)
RpcServicestartServer in interface RpcServiceC - Type of the self rpc gateway associated with the rpc serverS - Type of the rpc endpointrpcEndpoint - Rpc protocl to dispath the rpcs topublic void stopServer(RpcGateway selfGateway)
RpcServicestopServer in interface RpcServiceselfGateway - Self gateway describing the underlying rpc serverpublic void stopService()
RpcServicestopService in interface RpcServicepublic Future<Void> getTerminationFuture()
RpcServicegetTerminationFuture in interface RpcServicepublic Executor getExecutor()
RpcServicehandleAsync(...) or thenAcceptAsync(...) methods of futures.
IMPORTANT: This executor does not isolate the method invocations against
any concurrent invocations and is therefore not suitable to run completion methods of futures
that modify state of an RpcEndpoint. For such operations, one needs to use the
MainThreadExecutionContext of that
RpcEndpoint.
getExecutor in interface RpcServicepublic ScheduledExecutor getScheduledExecutor()
RpcServiceIMPORTANT: This executor does not isolate the method invocations against
any concurrent invocations and is therefore not suitable to run completion methods of futures
that modify state of an RpcEndpoint. For such operations, one needs to use the
MainThreadExecutionContext of that
RpcEndpoint.
getScheduledExecutor in interface RpcServicepublic ScheduledFuture<?> scheduleRunnable(Runnable runnable, long delay, TimeUnit unit)
RpcServiceRpcService.getExecutor(), after a scheduled delay.scheduleRunnable in interface RpcServicerunnable - Runnable to be executeddelay - The delay after which the runnable will be executedpublic void execute(Runnable runnable)
RpcServiceRpcEndpoint.
IMPORTANT: This executor does not isolate the method invocations against
any concurrent invocations and is therefore not suitable to run completion methods of futures
that modify state of an RpcEndpoint. For such operations, one needs to use the
MainThreadExecutionContext of that
RpcEndpoint.
execute in interface RpcServicerunnable - to executepublic <T> Future<T> execute(Callable<T> callable)
RpcServiceFuture. This method can be used
to run code outside of the main thread of a RpcEndpoint.
IMPORTANT: This executor does not isolate the method invocations against
any concurrent invocations and is therefore not suitable to run completion methods of futures
that modify state of an RpcEndpoint. For such operations, one needs to use the
MainThreadExecutionContext of that
RpcEndpoint.
execute in interface RpcServiceT - is the return value typecallable - to executeCopyright © 2014–2017 The Apache Software Foundation. All rights reserved.