2 * Copyright (c) 2019 PANTHEON.tech, s.r.o. and others. All rights reserved.
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
8 package org.opendaylight.controller.remote.rpc;
10 import static java.util.Objects.requireNonNull;
12 import akka.actor.ActorRef;
13 import akka.pattern.Patterns;
14 import akka.util.Timeout;
15 import org.opendaylight.controller.remote.rpc.messages.AbstractExecute;
16 import scala.concurrent.Future;
19 * An abstract base class for remote RPC/action implementations.
21 abstract class AbstractRemoteImplementation<T extends AbstractExecute<?, ?>> {
22 // 0 for local, 1 for binding, 2 for remote
23 static final long COST = 2;
25 private final ActorRef remoteInvoker;
26 private final Timeout askDuration;
28 AbstractRemoteImplementation(final ActorRef remoteInvoker, final RemoteOpsProviderConfig config) {
29 this.remoteInvoker = requireNonNull(remoteInvoker);
30 this.askDuration = config.getAskDuration();
33 final Future<Object> ask(final T message) {
34 return Patterns.ask(remoteInvoker, requireNonNull(message), askDuration);