public interface RpcService extends AutoCloseableAsync
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.
|
<F extends Serializable,C extends FencedRpcGateway<F>> |
connect(String address,
F fencingToken,
Class<C> clazz)
Connect to a remote fenced rpc server under the provided address.
|
String |
getAddress()
Return the hostname or host address under which the rpc service can be reached.
|
int |
getPort()
Return the port under which the rpc service is reachable.
|
ScheduledExecutor |
getScheduledExecutor()
Gets a scheduled executor from the RPC service.
|
<C extends RpcGateway> |
getSelfGateway(Class<C> selfGatewayType,
RpcServer rpcServer)
Returns a self gateway of the specified type which can be used to issue asynchronous calls
against the RpcEndpoint.
|
<C extends RpcEndpoint & RpcGateway> |
startServer(C rpcEndpoint,
Map<String,String> loggingContext)
Start a rpc server which forwards the remote procedure calls to the provided rpc endpoint.
|
void |
stopServer(RpcServer selfGateway)
Stop the underlying rpc server of the provided self gateway.
|
close, closeAsync
String getAddress()
int getPort()
<C extends RpcGateway> C getSelfGateway(Class<C> selfGatewayType, RpcServer rpcServer)
IMPORTANT: The self gateway type must be implemented by the RpcEndpoint. Otherwise the method will fail.
C
- type of the self gateway to createselfGatewayType
- class of the self gateway type<C extends RpcGateway> CompletableFuture<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<F extends Serializable,C extends FencedRpcGateway<F>> CompletableFuture<C> connect(String address, F fencingToken, Class<C> clazz)
RpcConnectionException
.F
- Type of the fencing tokenC
- Type of the rpc gateway to returnaddress
- Address of the remote rpc serverfencingToken
- Fencing token to be used when communicating with the serverclazz
- Class of the rpc gateway to returnRpcConnectionException
if the
connection attempt failed<C extends RpcEndpoint & RpcGateway> RpcServer startServer(C rpcEndpoint, Map<String,String> loggingContext)
C
- Type of the rpc endpointrpcEndpoint
- Rpc protocol to dispatch the rpcs tologgingContext
- void stopServer(RpcServer selfGateway)
selfGateway
- Self gateway describing the underlying rpc serverScheduledExecutor 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
.
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.