@ThreadSafe public class PekkoRpcService extends Object implements RpcService
RpcService
implementation. The RPC service starts an actor to receive RPC
invocations from a RpcGateway
.Constructor and Description |
---|
PekkoRpcService(org.apache.pekko.actor.ActorSystem actorSystem,
PekkoRpcServiceConfiguration configuration) |
Modifier and Type | Method and Description |
---|---|
CompletableFuture<Void> |
closeAsync()
Trigger the closing of the resource and return the corresponding close future.
|
<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.
|
org.apache.pekko.actor.ActorSystem |
getActorSystem() |
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.
|
protected int |
getVersion() |
<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.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
close
@VisibleForTesting public PekkoRpcService(org.apache.pekko.actor.ActorSystem actorSystem, PekkoRpcServiceConfiguration configuration)
public org.apache.pekko.actor.ActorSystem getActorSystem()
protected int getVersion()
public String getAddress()
RpcService
getAddress
in interface RpcService
public int getPort()
RpcService
getPort
in interface RpcService
public <C extends RpcGateway> C getSelfGateway(Class<C> selfGatewayType, RpcServer rpcServer)
RpcService
IMPORTANT: The self gateway type must be implemented by the RpcEndpoint. Otherwise the method will fail.
getSelfGateway
in interface RpcService
C
- type of the self gateway to createselfGatewayType
- class of the self gateway typepublic <C extends RpcGateway> CompletableFuture<C> connect(String address, Class<C> clazz)
RpcService
RpcConnectionException
.connect
in interface RpcService
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 failedpublic <F extends Serializable,C extends FencedRpcGateway<F>> CompletableFuture<C> connect(String address, F fencingToken, Class<C> clazz)
RpcService
RpcConnectionException
.connect
in interface RpcService
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 failedpublic <C extends RpcEndpoint & RpcGateway> RpcServer startServer(C rpcEndpoint, Map<String,String> loggingContext)
RpcService
startServer
in interface RpcService
C
- Type of the rpc endpointrpcEndpoint
- Rpc protocol to dispatch the rpcs topublic void stopServer(RpcServer selfGateway)
RpcService
stopServer
in interface RpcService
selfGateway
- Self gateway describing the underlying rpc serverpublic CompletableFuture<Void> closeAsync()
AutoCloseableAsync
closeAsync
in interface AutoCloseableAsync
public ScheduledExecutor getScheduledExecutor()
RpcService
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
.
getScheduledExecutor
in interface RpcService
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.