public interface RpcConsumerRegistry extends BindingService
RPC implementations are registered using the RpcProviderService
.
Modifier and Type | Method and Description |
---|---|
<T extends RpcService> |
getRpcService(@NonNull Class<T> serviceInterface)
Returns an implementation of a requested RPC service.
|
<T extends RpcService> T getRpcService(@NonNull Class<T> serviceInterface)
The returned instance is not an actual implementation of the RPC service interface, but a proxy implementation of the interface that forwards to an actual implementation, if any.
The following describes the behavior of the proxy when invoking RPC methods:
IllegalStateException
.IllegalArgumentException
is thrown.
The generated RPC method APIs require implementors to return a
Future
instance that wraps the
RpcResult
. Since RPC methods may be
implemented asynchronously, callers should avoid blocking on the
Future
result. Instead, it is recommended to use
JdkFutureAdapters.listenInPoolThread(java.util.concurrent.Future)
or
JdkFutureAdapters.listenInPoolThread(java.util.concurrent.Future,
java.util.concurrent.Executor)
to listen for Rpc Result. This will asynchronously listen for future result
in executor and will not block current thread.
final Future<RpcResult<SomeRpcOutput>> future = someRpcService.someRpc( ... ); Futures.addCallback(JdkFutureAdapters.listenInThreadPool(future), new FutureCallback<RpcResult< SomeRpcOutput>>() { public void onSuccess(RpcResult<SomeRpcOutput> result) { // process result ... } public void onFailure(Throwable t) { // RPC failed } );
serviceInterface
- the interface of the RPC Service. Typically this is an interface
generated from a YANG model.Copyright © 2019 OpenDaylight. All rights reserved.