X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-remoterpc-connector%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fremote%2Frpc%2FOpsInvoker.java;h=9c47e68faa6a95bf5ba9a2861ad4295bedd219f8;hb=62468daa9029368b321b6e1e18fa9cfa0ae994b4;hp=5ccea6a423a3519c649dd4c56818e601c29247b7;hpb=ba6824307ad4b3c272abefe9682d623adc3b42d2;p=controller.git diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/OpsInvoker.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/OpsInvoker.java index 5ccea6a423..9c47e68faa 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/OpsInvoker.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/OpsInvoker.java @@ -29,10 +29,11 @@ import org.opendaylight.mdsal.dom.api.DOMActionService; import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier; import org.opendaylight.mdsal.dom.api.DOMRpcResult; import org.opendaylight.mdsal.dom.api.DOMRpcService; +import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.common.RpcError; import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; +import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute; /** * Actor receiving invocation requests from remote nodes, routing them to @@ -91,17 +92,17 @@ final class OpsInvoker extends AbstractUntypedActor { return; } - Futures.addCallback(future, new AbstractCallback(getSender(), msg.getType()) { + Futures.addCallback(future, new AbstractCallback(getSender(), msg.getType()) { @Override - Object nullResponse(final SchemaPath type) { + Object nullResponse(final QName type) { LOG.warn("Execution of {} resulted in null result", type); return new RpcResponse(null); } @Override - Object response(final SchemaPath type, final DOMRpcResult result) { - final Collection errors = result.getErrors(); - return errors.isEmpty() ? new RpcResponse(result.getResult()) + Object response(final QName type, final DOMRpcResult result) { + final Collection errors = result.errors(); + return errors.isEmpty() ? new RpcResponse(result.value()) // This is legacy (wrong) behavior, which ignores the fact that errors may be just warnings, // discarding any output : new Failure(new RpcErrorsException(String.format("Execution of rpc %s failed", type), @@ -125,14 +126,14 @@ final class OpsInvoker extends AbstractUntypedActor { return; } - Futures.addCallback(future, new AbstractCallback(getSender(), msg.getType()) { + Futures.addCallback(future, new AbstractCallback(getSender(), msg.getType()) { @Override - Object nullResponse(final SchemaPath type) { + Object nullResponse(final Absolute type) { throw new IllegalStateException("Null invocation result of action " + type); } @Override - Object response(final SchemaPath type, final DOMActionResult result) { + Object response(final Absolute type, final DOMActionResult result) { final Collection errors = result.getErrors(); return errors.isEmpty() ? new ActionResponse(result.getOutput(), result.getErrors()) // This is legacy (wrong) behavior, which ignores the fact that errors may be just warnings, @@ -143,17 +144,17 @@ final class OpsInvoker extends AbstractUntypedActor { }, MoreExecutors.directExecutor()); } - private abstract class AbstractCallback implements FutureCallback { + private abstract class AbstractCallback implements FutureCallback { private final ActorRef replyTo; - private final SchemaPath type; + private final T type; - AbstractCallback(final ActorRef replyTo, final SchemaPath type) { + AbstractCallback(final ActorRef replyTo, final T type) { this.replyTo = requireNonNull(replyTo); this.type = requireNonNull(type); } @Override - public final void onSuccess(final T result) { + public final void onSuccess(final R result) { final Object response; if (result == null) { // This shouldn't happen but the FutureCallback annotates the result param with Nullable so handle null @@ -175,8 +176,8 @@ final class OpsInvoker extends AbstractUntypedActor { replyTo.tell(new Failure(failure), self()); } - abstract @NonNull Object nullResponse(@NonNull SchemaPath type); + abstract @NonNull Object nullResponse(@NonNull T type); - abstract @NonNull Object response(@NonNull SchemaPath type, @NonNull T result); + abstract @NonNull Object response(@NonNull T type, @NonNull R result); } }