@Nullable @Override public DOMRpcException apply(@Nullable final Exception e) { // FIXME what other possible exceptions are there ? return new DOMRpcImplementationNotAvailableException(e, "Unable to invoke rpc %s", type); } });
UnknownDOMRpcRoutingTableEntry(final SchemaPath schemaPath, final Map<YangInstanceIdentifier, List<DOMRpcImplementation>> impls) { super(schemaPath, impls); unknownRpc = Futures.<DOMRpcResult, DOMRpcException>immediateFailedCheckedFuture( new DOMRpcImplementationNotAvailableException("SchemaPath %s is not resolved to an RPC", schemaPath)); }
@Override protected DOMRpcException newWithCause(String message, Throwable cause) { return cause instanceof DOMRpcException ? (DOMRpcException)cause : cause instanceof org.opendaylight.mdsal.dom.api.DOMRpcImplementationNotAvailableException ? new DOMRpcImplementationNotAvailableException(cause.getMessage(), cause.getCause()) : new DefaultDOMRpcException("RPC failed", cause); } };
@Override @Nonnull public CompletionStage invoke(@Nonnull final SchemaPath schemaPath, @Nullable final DataObject request) { final RpcService rpcService = services.get(schemaPath); if (rpcService == null) { LOG.error("Missing Rpc service for schemaPath: {}", schemaPath); final CompletableFuture<DataObject> result = new CompletableFuture<>(); result.completeExceptionally( new DOMRpcImplementationNotAvailableException("Service not found: %s", schemaPath)); return result; } LOG.debug("Delegating rpcRequest: {} to rpcService: {}", request, rpcService); return rpcService.invoke(request); } }
CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(final SchemaPath type, final NormalizedNode<?, ?> input) { final AbstractDOMRpcRoutingTableEntry entry = rpcs.get(type); if (entry == null) { return Futures.<DOMRpcResult, DOMRpcException>immediateFailedCheckedFuture(new DOMRpcImplementationNotAvailableException("No implementation of RPC %s available", type)); } return entry.invokeRpc(input); }
LOG.warn("Rpc {} was removed during execution or there is loop present. Failing received rpc.", rpc); return Futures .<DOMRpcResult, DOMRpcException>immediateFailedCheckedFuture(new DOMRpcImplementationNotAvailableException( "Rpc implementation for {} was removed during processing.", rpc)); final List<Pair<ActorRef, Long>> routePairs = routes.getRouterWithUpdateTime(); if (routePairs == null || routePairs.isEmpty()) { frontEndFuture.failNow(new DOMRpcImplementationNotAvailableException( "No local or remote implementation available for rpc %s", rpc.getType(), error)); } else {
return impls.get(0).invokeRpc(globalRpcId, input); } else { return Futures.<DOMRpcResult, DOMRpcException>immediateFailedCheckedFuture(new DOMRpcImplementationNotAvailableException("No implementation of RPC %s available", getSchemaPath()));
@Override public void onComplete(final Throwable error, final FindRoutersReply routes) throws Throwable { if (error != null) { frontEndFuture.failNow(error); } else { final List<Pair<ActorRef, Long>> routePairs = routes.getRouterWithUpdateTime(); if (routePairs == null || routePairs.isEmpty()) { frontEndFuture.failNow(new DOMRpcImplementationNotAvailableException( "No local or remote implementation available for rpc %s", rpc.getType(), error)); } else { final ActorRef remoteImplRef = new LatestEntryRoutingLogic(routePairs).select(); final Object executeRpcMessage = ExecuteRpc.from(rpc, input); LOG.debug("Found remote actor {} for rpc {} - sending {}", remoteImplRef, rpc.getType(), executeRpcMessage); frontEndFuture.completeWith(ask(remoteImplRef, executeRpcMessage, config.getAskDuration())); } } } }, ExecutionContext.Implicits$.MODULE$.global());