Teach sal-remoterpc-connector to route actions
[controller.git] / opendaylight / md-sal / sal-remoterpc-connector / src / main / java / org / opendaylight / controller / remote / rpc / RemoteRpcImplementation.java
index 71b2759..a737049 100644 (file)
@@ -7,11 +7,7 @@
  */
 package org.opendaylight.controller.remote.rpc;
 
-import static java.util.Objects.requireNonNull;
-
 import akka.actor.ActorRef;
-import akka.pattern.Patterns;
-import akka.util.Timeout;
 import com.google.common.util.concurrent.ListenableFuture;
 import org.opendaylight.controller.remote.rpc.messages.ExecuteRpc;
 import org.opendaylight.mdsal.dom.api.DOMRpcIdentifier;
@@ -24,24 +20,15 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
  *
  * @author Robert Varga
  */
-final class RemoteRpcImplementation implements DOMRpcImplementation {
-    // 0 for local, 1 for binding, 2 for remote
-    private static final long COST = 2;
-
-    private final ActorRef remoteInvoker;
-    private final Timeout askDuration;
-
-    RemoteRpcImplementation(final ActorRef remoteInvoker, final RemoteRpcProviderConfig config) {
-        this.remoteInvoker = requireNonNull(remoteInvoker);
-        this.askDuration = config.getAskDuration();
+final class RemoteRpcImplementation extends AbstractRemoteImplementation<ExecuteRpc> implements DOMRpcImplementation {
+    RemoteRpcImplementation(final ActorRef remoteInvoker, final RemoteOpsProviderConfig config) {
+        super(remoteInvoker, config);
     }
 
     @Override
     public ListenableFuture<DOMRpcResult> invokeRpc(final DOMRpcIdentifier rpc,
             final NormalizedNode<?, ?> input) {
-        final RemoteDOMRpcFuture ret = RemoteDOMRpcFuture.create(rpc.getType().getLastComponent());
-        ret.completeWith(Patterns.ask(remoteInvoker, ExecuteRpc.from(rpc, input), askDuration));
-        return ret;
+        return new RemoteDOMRpcFuture(rpc.getType(), ask(ExecuteRpc.from(rpc, input)));
     }
 
     @Override

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.