Search in sources :

Example 1 with DOMRpcIdentifier

use of org.opendaylight.mdsal.dom.api.DOMRpcIdentifier in project controller by opendaylight.

the class RoutedGetConstantService method registerNew.

public static DOMRpcImplementationRegistration<RoutedGetConstantService> registerNew(final BindingNormalizedNodeSerializer codec, final DOMRpcProviderService rpcProviderService, final String constant, final InstanceIdentifier<?> context) {
    LOG.debug("Registering get-contexted-constant on context: {}, with value: {}", context, constant);
    final YangInstanceIdentifier yid = codec.toYangInstanceIdentifier(context);
    final DOMRpcIdentifier id = DOMRpcIdentifier.create(GET_CONTEXTED_CONSTANT, yid);
    return rpcProviderService.registerRpcImplementation(new RoutedGetConstantService(constant), id);
}
Also used : DOMRpcIdentifier(org.opendaylight.mdsal.dom.api.DOMRpcIdentifier) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)

Example 2 with DOMRpcIdentifier

use of org.opendaylight.mdsal.dom.api.DOMRpcIdentifier in project controller by opendaylight.

the class RpcRegistryTest method testRpcAddedOnMultiNodes.

/**
 * Three node cluster. Register rpc on 2 nodes. Ensure 3rd gets updated.
 */
@Test
public void testRpcAddedOnMultiNodes() {
    final TestKit testKit = new TestKit(node3);
    // Add rpc on node 1
    List<DOMRpcIdentifier> addedRouteIds1 = createRouteIds();
    registry1.tell(new AddOrUpdateRoutes(addedRouteIds1), ActorRef.noSender());
    final UpdateRemoteEndpoints req1 = registrar3.expectMsgClass(Duration.ofSeconds(3), UpdateRemoteEndpoints.class);
    // Add rpc on node 2
    List<DOMRpcIdentifier> addedRouteIds2 = createRouteIds();
    registry2.tell(new AddOrUpdateRoutes(addedRouteIds2), ActorRef.noSender());
    final UpdateRemoteEndpoints req2 = registrar3.expectMsgClass(Duration.ofSeconds(3), UpdateRemoteEndpoints.class);
    Address node2Address = node2.provider().getDefaultAddress();
    Address node1Address = node1.provider().getDefaultAddress();
    Map<Address, Bucket<RoutingTable>> buckets = retrieveBuckets(registry3, testKit, node1Address, node2Address);
    verifyBucket(buckets.get(node1Address), addedRouteIds1);
    verifyBucket(buckets.get(node2Address), addedRouteIds2);
    Map<Address, Long> versions = retrieveVersions(registry3, testKit);
    assertEquals("Version for bucket " + node1Address, (Long) buckets.get(node1Address).getVersion(), versions.get(node1Address));
    assertEquals("Version for bucket " + node2Address, (Long) buckets.get(node2Address).getVersion(), versions.get(node2Address));
    assertEndpoints(req1, node1Address, invoker1);
    assertEndpoints(req2, node2Address, invoker2);
}
Also used : UniqueAddress(akka.cluster.UniqueAddress) Address(akka.actor.Address) AddOrUpdateRoutes(org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.AddOrUpdateRoutes) Bucket(org.opendaylight.controller.remote.rpc.registry.gossip.Bucket) DOMRpcIdentifier(org.opendaylight.mdsal.dom.api.DOMRpcIdentifier) TestKit(akka.testkit.javadsl.TestKit) UpdateRemoteEndpoints(org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.UpdateRemoteEndpoints) Test(org.junit.Test)

Example 3 with DOMRpcIdentifier

use of org.opendaylight.mdsal.dom.api.DOMRpcIdentifier in project controller by opendaylight.

the class RpcRegistryTest method createRouteIds.

private List<DOMRpcIdentifier> createRouteIds() {
    QName type = QName.create("/mockrpc", "mockrpc" + routeIdCounter++);
    List<DOMRpcIdentifier> routeIds = new ArrayList<>(1);
    routeIds.add(DOMRpcIdentifier.create(type));
    return routeIds;
}
Also used : QName(org.opendaylight.yangtools.yang.common.QName) ArrayList(java.util.ArrayList) DOMRpcIdentifier(org.opendaylight.mdsal.dom.api.DOMRpcIdentifier)

Example 4 with DOMRpcIdentifier

use of org.opendaylight.mdsal.dom.api.DOMRpcIdentifier in project controller by opendaylight.

the class RpcRegistryTest method testRpcAddRemoveInCluster.

/**
 * Three node cluster. 1. Register rpc on 1 node, ensure 2nd node gets updated 2. Remove rpc on
 * 1 node, ensure 2nd node gets updated
 */
@Test
public void testRpcAddRemoveInCluster() {
    LOG.info("testRpcAddRemoveInCluster starting");
    List<DOMRpcIdentifier> addedRouteIds = createRouteIds();
    Address node1Address = node1.provider().getDefaultAddress();
    // Add rpc on node 1
    registry1.tell(new AddOrUpdateRoutes(addedRouteIds), ActorRef.noSender());
    // Bucket store on node2 should get a message to update its local copy of remote buckets
    final TestKit testKit = new TestKit(node2);
    Map<Address, Bucket<RoutingTable>> buckets = retrieveBuckets(registry2, testKit, node1Address);
    verifyBucket(buckets.get(node1Address), addedRouteIds);
    // Now remove
    registry1.tell(new RemoveRoutes(addedRouteIds), ActorRef.noSender());
    // Bucket store on node2 should get a message to update its local copy of remote buckets.
    // Wait for the bucket for node1 to be empty.
    verifyEmptyBucket(testKit, registry2, node1Address);
    LOG.info("testRpcAddRemoveInCluster ending");
}
Also used : UniqueAddress(akka.cluster.UniqueAddress) Address(akka.actor.Address) AddOrUpdateRoutes(org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.AddOrUpdateRoutes) Bucket(org.opendaylight.controller.remote.rpc.registry.gossip.Bucket) DOMRpcIdentifier(org.opendaylight.mdsal.dom.api.DOMRpcIdentifier) TestKit(akka.testkit.javadsl.TestKit) RemoveRoutes(org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.RemoveRoutes) Test(org.junit.Test)

Example 5 with DOMRpcIdentifier

use of org.opendaylight.mdsal.dom.api.DOMRpcIdentifier in project controller by opendaylight.

the class RemoteRpcRegistryMXBeanImplTest method setUp.

@Before
public void setUp() {
    system = ActorSystem.create("test", ConfigFactory.load().getConfig("unit-test"));
    final DOMRpcIdentifier emptyRpcIdentifier = DOMRpcIdentifier.create(REMOTE_QNAME, YangInstanceIdentifier.empty());
    final DOMRpcIdentifier localRpcIdentifier = DOMRpcIdentifier.create(LOCAL_QNAME, YangInstanceIdentifier.of(LOCAL_QNAME));
    buckets = Lists.newArrayList(emptyRpcIdentifier, localRpcIdentifier);
    final RemoteOpsProviderConfig config = new RemoteOpsProviderConfig.Builder("system").build();
    final TestKit invoker = new TestKit(system);
    final TestKit registrar = new TestKit(system);
    final TestKit supervisor = new TestKit(system);
    final Props props = RpcRegistry.props(config, invoker.getRef(), registrar.getRef()).withDispatcher(Dispatchers.DefaultDispatcherId());
    testActor = new TestActorRef<>(system, props, supervisor.getRef(), "testActor");
    final Timeout timeout = Timeout.apply(10, TimeUnit.SECONDS);
    mxBean = new RemoteRpcRegistryMXBeanImpl(new BucketStoreAccess(testActor, system.dispatcher(), timeout), timeout);
}
Also used : Timeout(akka.util.Timeout) RemoteOpsProviderConfig(org.opendaylight.controller.remote.rpc.RemoteOpsProviderConfig) DOMRpcIdentifier(org.opendaylight.mdsal.dom.api.DOMRpcIdentifier) TestKit(akka.testkit.javadsl.TestKit) Props(akka.actor.Props) BucketStoreAccess(org.opendaylight.controller.remote.rpc.registry.gossip.BucketStoreAccess) Before(org.junit.Before)

Aggregations

DOMRpcIdentifier (org.opendaylight.mdsal.dom.api.DOMRpcIdentifier)18 TestKit (akka.testkit.javadsl.TestKit)6 Test (org.junit.Test)6 Address (akka.actor.Address)5 UniqueAddress (akka.cluster.UniqueAddress)4 AddOrUpdateRoutes (org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.AddOrUpdateRoutes)4 Bucket (org.opendaylight.controller.remote.rpc.registry.gossip.Bucket)4 QName (org.opendaylight.yangtools.yang.common.QName)3 Props (akka.actor.Props)2 ArrayList (java.util.ArrayList)2 Collection (java.util.Collection)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Before (org.junit.Before)2 RoutingTable (org.opendaylight.controller.remote.rpc.registry.RoutingTable)2 RemoveRoutes (org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.RemoveRoutes)2 RemoteRpcEndpoint (org.opendaylight.controller.remote.rpc.registry.RpcRegistry.RemoteRpcEndpoint)2 Timeout (akka.util.Timeout)1 Collections2 (com.google.common.collect.Collections2)1 ImmutableSet (com.google.common.collect.ImmutableSet)1