public interface RpcService
RpcEndpoint.
Connecting to a rpc server will return a RpcGateway which can be used to call remote
procedures.| 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
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.
|
<C extends RpcGateway> |
stopServer(C selfGateway)
Stop the underlying rpc server of the provided self gateway.
|
void |
stopService()
Stop the rpc service shutting down all started rpc servers.
|
String getAddress()
<C extends RpcGateway> Future<C> connect(String address, Class<C> clazz)
RpcConnectionException.C - Type of the rpc gateway to returnaddress - Address of the remote rpc serverclazz - Class of the rpc gateway to returnRpcConnectionException if the
connection attempt failed<C extends RpcGateway,S extends RpcEndpoint<C>> C startServer(S rpcEndpoint)
S - Type of the rpc endpointC - Type of the self rpc gateway associated with the rpc serverrpcEndpoint - Rpc protocl to dispath the rpcs to<C extends RpcGateway> void stopServer(C selfGateway)
C - Type of the rpc gatewayselfGateway - Self gateway describing the underlying rpc servervoid stopService()
Future<Void> getTerminationFuture()
Executor getExecutor()
handleAsync(...) 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.
ScheduledExecutor getScheduledExecutor()
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.
ScheduledFuture<?> scheduleRunnable(Runnable runnable, long delay, TimeUnit unit)
getExecutor(), after a scheduled delay.runnable - Runnable to be executeddelay - The delay after which the runnable will be executedvoid execute(Runnable runnable)
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.
runnable - to execute<T> Future<T> execute(Callable<T> callable)
Future. 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.
T - is the return value typecallable - to executeCopyright © 2014–2017 The Apache Software Foundation. All rights reserved.