Do not use ClassToInstanceMap to register RPCs.
Change-Id: I205bc4b51459b771d61580dde8aac7d5da74c451
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Stopwatch;
-import com.google.common.collect.ImmutableClassToInstanceMap;
import com.google.common.net.InetAddresses;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.ListenableFuture;
import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.Rpc;
import org.opendaylight.yangtools.yang.binding.util.BindingMap;
import org.opendaylight.yangtools.yang.common.Empty;
import org.opendaylight.yangtools.yang.common.RpcResult;
.child(Tables.class, new TablesKey(Ipv4AddressFamily.VALUE, UnicastSubsequentAddressFamily.VALUE))
.child(Ipv4RoutesCase.class, Ipv4Routes.class);
rpcRegistration = rpcProviderRegistry.registerRpcImplementations(
- ImmutableClassToInstanceMap.<Rpc<?, ?>>builder()
- .put(AddPrefix.class, this::addPrefix)
- .put(DeletePrefix.class, this::deletePrefix)
- .build());
+ (AddPrefix) this::addPrefix,
+ (DeletePrefix) this::deletePrefix);
LOG.info("BGP Application Peer Benchmark Application started.");
}
import static org.opendaylight.protocol.util.CheckTestUtil.checkNotPresentConfiguration;
import static org.opendaylight.protocol.util.CheckTestUtil.readDataConfiguration;
-import com.google.common.collect.ClassToInstanceMap;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.odl.bgp.app.peer.benchmark.rev200120.output.Result;
import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.Rpc;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.common.Uint32;
@Before
public void setUp() {
- doReturn(registration).when(rpcRegistry).registerRpcImplementations(any(ClassToInstanceMap.class));
+ doReturn(registration).when(rpcRegistry).registerRpcImplementations(any(Rpc[].class));
doNothing().when(registration).close();
}
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
-import com.google.common.collect.ImmutableClassToInstanceMap;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.Notification;
-import org.opendaylight.yangtools.yang.binding.Rpc;
import org.opendaylight.yangtools.yang.common.Empty;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
if (rpcRegistry != null) {
final var bgpPeerHandler = new BgpPeerRpc(this, session, tables);
- rpcRegistration = rpcRegistry.registerRpcImplementations(
- ImmutableClassToInstanceMap.<Rpc<?, ?>>builder()
- .put(ResetSession.class, bgpPeerHandler::resetSession)
- .put(RestartGracefully.class, bgpPeerHandler::restartGracefully)
- .put(RouteRefreshRequest.class, bgpPeerHandler::routeRefreshRequest)
- .build(),
- ImmutableSet.of(rib.getInstanceIdentifier().child(
- org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.bgp.rib.rib
- .Peer.class, new PeerKey(peerId))));
+ rpcRegistration = rpcRegistry.registerRpcImplementations(List.of(
+ (ResetSession) bgpPeerHandler::resetSession,
+ (RestartGracefully) bgpPeerHandler::restartGracefully,
+ (RouteRefreshRequest) bgpPeerHandler::routeRefreshRequest), ImmutableSet.of(
+ rib.getInstanceIdentifier().child(
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.bgp.rib
+ .rib.Peer.class, new PeerKey(peerId))));
}
} else {
final Set<TablesKey> forwardingTables;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
-import com.google.common.collect.ImmutableClassToInstanceMap;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
+import java.util.List;
import java.util.Set;
import org.opendaylight.bgpcep.pcep.topology.spi.AbstractInstructionExecutor;
import org.opendaylight.bgpcep.programming.spi.InstructionScheduler;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey;
import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.Rpc;
import org.opendaylight.yangtools.yang.common.RpcResult;
final class TopologyProgramming {
Registration register(final RpcProviderService rpcProviderService,
final KeyedInstanceIdentifier<Topology, TopologyKey> path) {
- return rpcProviderService.registerRpcImplementations(ImmutableClassToInstanceMap.<Rpc<?, ?>>builder()
- .put(SubmitAddLsp.class, this::submitAddLsp)
- .put(SubmitRemoveLsp.class, this::submitRemoveLsp)
- .put(SubmitUpdateLsp.class, this::submitUpdateLsp)
- .put(SubmitEnsureLspOperational.class, this::submitEnsureLspOperational)
- .put(SubmitTriggerSync.class, this::submitTriggerSync)
- .build(), Set.of(path));
+ return rpcProviderService.registerRpcImplementations(List.of(
+ (SubmitAddLsp) this::submitAddLsp,
+ (SubmitRemoveLsp) this::submitRemoveLsp,
+ (SubmitUpdateLsp) this::submitUpdateLsp,
+ (SubmitEnsureLspOperational) this::submitEnsureLspOperational,
+ (SubmitTriggerSync) this::submitTriggerSync), Set.of(path));
}
@VisibleForTesting
import static java.util.Objects.requireNonNull;
import com.google.common.annotations.VisibleForTesting;
-import com.google.common.collect.ImmutableClassToInstanceMap;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
+import java.util.List;
import java.util.Set;
import org.opendaylight.bgpcep.programming.spi.SuccessfulRpcResult;
import org.opendaylight.mdsal.binding.api.RpcProviderService;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey;
import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.Rpc;
import org.opendaylight.yangtools.yang.common.RpcResult;
final class TopologyRPCs {
Registration register(final RpcProviderService rpcProviderService,
final KeyedInstanceIdentifier<Topology, TopologyKey> path) {
- return rpcProviderService.registerRpcImplementations(ImmutableClassToInstanceMap.<Rpc<?, ?>>builder()
- .put(AddLsp.class, this::addLsp)
- .put(RemoveLsp.class, this::removeLsp)
- .put(TriggerSync.class, this::triggerSync)
- .put(UpdateLsp.class, this::updateLsp)
- .put(EnsureLspOperational.class, this::ensureLspOperational)
- .put(TearDownSession.class, this::tearDownSession)
- .build(), Set.of(path));
+ return rpcProviderService.registerRpcImplementations(List.of(
+ (AddLsp) this::addLsp,
+ (RemoveLsp) this::removeLsp,
+ (TriggerSync) this::triggerSync,
+ (UpdateLsp) this::updateLsp,
+ (EnsureLspOperational) this::ensureLspOperational,
+ (TearDownSession) this::tearDownSession), Set.of(path));
}
@VisibleForTesting
import static java.util.Objects.requireNonNull;
import com.google.common.annotations.VisibleForTesting;
-import com.google.common.collect.ImmutableClassToInstanceMap;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
+import java.util.List;
import java.util.Set;
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.bgpcep.pcep.topology.spi.AbstractInstructionExecutor;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey;
import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.Rpc;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
}
Registration register(final KeyedInstanceIdentifier<Topology, TopologyKey> topologyPath) {
- return dependencies.getRpcProviderRegistry().registerRpcImplementations(
- ImmutableClassToInstanceMap.<Rpc<?, ?>>builder()
- .put(PcepCreateP2pTunnel.class, this::pcepCreateP2pTunnel)
- .put(PcepDestroyTunnel.class, this::pcepDestroyTunnel)
- .put(PcepUpdateTunnel.class, this::pcepUpdateTunnel)
- .build(), Set.of(topologyPath));
+ return dependencies.getRpcProviderRegistry().registerRpcImplementations(List.of(
+ (PcepCreateP2pTunnel) this::pcepCreateP2pTunnel,
+ (PcepDestroyTunnel) this::pcepDestroyTunnel,
+ (PcepUpdateTunnel) this::pcepUpdateTunnel), Set.of(topologyPath));
}
@VisibleForTesting
import static java.util.Objects.requireNonNull;
import com.google.common.annotations.VisibleForTesting;
-import com.google.common.collect.ImmutableClassToInstanceMap;
import com.google.common.util.concurrent.FluentFuture;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.Rpc;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Override
public synchronized void instantiateServiceInstance() {
LOG.info("Instruction Queue service {} instantiated", sgi.value());
- reg = rpcProviderRegistry.registerRpcImplementations(ImmutableClassToInstanceMap.<Rpc<?, ?>>builder()
- .put(CancelInstruction.class, this::cancelInstruction)
- .put(CleanInstructions.class, this::cleanInstructions)
- .build());
+ reg = rpcProviderRegistry.registerRpcImplementations(
+ (CancelInstruction) this::cancelInstruction,
+ (CleanInstructions) this::cleanInstructions);
final WriteTransaction wt = dataProvider.newWriteOnlyTransaction();
wt.put(LogicalDatastoreType.OPERATIONAL, qid, new InstructionsQueueBuilder()
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
-import com.google.common.collect.ClassToInstanceMap;
import org.junit.Before;
import org.mockito.Mock;
import org.opendaylight.mdsal.binding.api.RpcProviderService;
import org.opendaylight.mdsal.singleton.api.ClusterSingletonService;
import org.opendaylight.mdsal.singleton.api.ClusterSingletonServiceProvider;
import org.opendaylight.yangtools.concepts.Registration;
+import org.opendaylight.yangtools.yang.binding.Rpc;
abstract class AbstractProgrammingTest extends AbstractConcurrentDataBrokerTest {
@Mock
return null;
}).when(singletonServiceRegistration).close();
- doReturn(registration).when(rpcRegistry).registerRpcImplementations(any(ClassToInstanceMap.class));
+ doReturn(registration).when(rpcRegistry).registerRpcImplementations(any(Rpc[].class));
doNothing().when(registration).close();
}