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=dcb930e8ca3482c12d471625e7e62e4eb379591c;hb=HEAD;hp=4ac3867d67382fe00587378b4a37d1ed42c1d9d1;hpb=1d0370feb32b84119bf4c570b9e6e9abbe8d9511;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 4ac3867d67..2d2bd79338 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 @@ -24,7 +24,6 @@ import org.opendaylight.controller.remote.rpc.messages.ActionResponse; import org.opendaylight.controller.remote.rpc.messages.ExecuteAction; import org.opendaylight.controller.remote.rpc.messages.ExecuteRpc; import org.opendaylight.controller.remote.rpc.messages.RpcResponse; -import org.opendaylight.mdsal.dom.api.DOMActionResult; import org.opendaylight.mdsal.dom.api.DOMActionService; import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier; import org.opendaylight.mdsal.dom.api.DOMRpcResult; @@ -33,7 +32,6 @@ 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; /** @@ -69,11 +67,11 @@ final class OpsInvoker extends AbstractUntypedActor { @Override protected void handleReceive(final Object message) { - if (message instanceof ExecuteRpc) { + if (message instanceof ExecuteRpc executeRpc) { LOG.debug("Handling ExecuteOps Message"); - execute((ExecuteRpc) message); - } else if (message instanceof ExecuteAction) { - execute((ExecuteAction) message); + execute(executeRpc); + } else if (message instanceof ExecuteAction executeAction) { + execute(executeAction); } else { unknownMessage(message); } @@ -102,8 +100,8 @@ final class OpsInvoker extends AbstractUntypedActor { @Override Object response(final QName type, final DOMRpcResult result) { - final Collection errors = result.getErrors(); - return errors.isEmpty() ? new RpcResponse(result.getResult()) + 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), @@ -118,7 +116,7 @@ final class OpsInvoker extends AbstractUntypedActor { final ActorRef sender = getSender(); - final ListenableFuture future; + final ListenableFuture future; try { future = actionService.invokeAction(msg.getType(), msg.getPath(), msg.getInput()); } catch (final RuntimeException e) { @@ -127,16 +125,16 @@ 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 Absolute type) { throw new IllegalStateException("Null invocation result of action " + type); } @Override - Object response(final Absolute type, final DOMActionResult result) { - final Collection errors = result.getErrors(); - return errors.isEmpty() ? new ActionResponse(result.getOutput(), result.getErrors()) + Object response(final Absolute type, final DOMRpcResult result) { + final var errors = result.errors(); + return errors.isEmpty() ? new ActionResponse(result.value(), errors) // 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 action %s failed", type),