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
1 /*
2  * Copyright (c) 2014, 2017 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.controller.remote.rpc;
9
10 import akka.actor.ActorRef;
11 import com.google.common.util.concurrent.ListenableFuture;
12 import org.opendaylight.controller.remote.rpc.messages.ExecuteRpc;
13 import org.opendaylight.mdsal.dom.api.DOMRpcIdentifier;
14 import org.opendaylight.mdsal.dom.api.DOMRpcImplementation;
15 import org.opendaylight.mdsal.dom.api.DOMRpcResult;
16 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
17
18 /**
19  * A {@link DOMRpcImplementation} which routes invocation requests to a remote invoker actor.
20  *
21  * @author Robert Varga
22  */
23 final class RemoteRpcImplementation extends AbstractRemoteImplementation<ExecuteRpc> implements DOMRpcImplementation {
24     RemoteRpcImplementation(final ActorRef remoteInvoker, final RemoteOpsProviderConfig config) {
25         super(remoteInvoker, config);
26     }
27
28     @Override
29     public ListenableFuture<DOMRpcResult> invokeRpc(final DOMRpcIdentifier rpc,
30             final NormalizedNode<?, ?> input) {
31         return new RemoteDOMRpcFuture(rpc.getType(), ask(ExecuteRpc.from(rpc, input)));
32     }
33
34     @Override
35     public long invocationCost() {
36         return COST;
37     }
38 }

©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.