Search in sources :

Example 11 with DOMRpcIdentifier

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

the class SingletonGetConstantService method instantiateServiceInstance.

@Override
public void instantiateServiceInstance() {
    LOG.debug("Gained ownership of get-singleton-constant, registering service into rpcService");
    final DOMRpcIdentifier id = DOMRpcIdentifier.create(GET_SINGLETON_CONSTANT);
    rpcRegistration = rpcProviderService.registerRpcImplementation(this, id);
}
Also used : DOMRpcIdentifier(org.opendaylight.mdsal.dom.api.DOMRpcIdentifier)

Example 12 with DOMRpcIdentifier

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

the class RpcRegistryTest method testAddRemoveRpcOnSameNode.

/**
 * One node cluster. 1. Register rpc, ensure router can be found 2. Then remove rpc, ensure its
 * deleted
 */
@Test
public void testAddRemoveRpcOnSameNode() {
    LOG.info("testAddRemoveRpcOnSameNode starting");
    Address nodeAddress = node1.provider().getDefaultAddress();
    // Add rpc on node 1
    List<DOMRpcIdentifier> addedRouteIds = createRouteIds();
    registry1.tell(new AddOrUpdateRoutes(addedRouteIds), ActorRef.noSender());
    // Bucket store should get an update bucket message. Updated bucket contains added rpc.
    final TestKit testKit = new TestKit(node1);
    Map<Address, Bucket<RoutingTable>> buckets = retrieveBuckets(registry1, testKit, nodeAddress);
    verifyBucket(buckets.get(nodeAddress), addedRouteIds);
    Map<Address, Long> versions = retrieveVersions(registry1, testKit);
    assertEquals("Version for bucket " + nodeAddress, (Long) buckets.get(nodeAddress).getVersion(), versions.get(nodeAddress));
    // Now remove rpc
    registry1.tell(new RemoveRoutes(addedRouteIds), ActorRef.noSender());
    // Bucket store should get an update bucket message. Rpc is removed in the updated bucket
    verifyEmptyBucket(testKit, registry1, nodeAddress);
    LOG.info("testAddRemoveRpcOnSameNode 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 13 with DOMRpcIdentifier

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

the class RpcRegistryTest method testAddRoutesConcurrency.

@Test
public void testAddRoutesConcurrency() {
    final TestKit testKit = new TestKit(node1);
    final int nRoutes = 500;
    final Collection<DOMRpcIdentifier> added = new ArrayList<>(nRoutes);
    for (int i = 0; i < nRoutes; i++) {
        final DOMRpcIdentifier routeId = DOMRpcIdentifier.create(QName.create("/mockrpc", "type" + i));
        added.add(routeId);
        // Uninterruptibles.sleepUninterruptibly(50, TimeUnit.MILLISECONDS);
        registry1.tell(new AddOrUpdateRoutes(Arrays.asList(routeId)), ActorRef.noSender());
    }
    int numTries = 0;
    while (true) {
        registry1.tell(GET_ALL_BUCKETS, testKit.getRef());
        @SuppressWarnings("unchecked") Map<Address, Bucket<RoutingTable>> buckets = testKit.expectMsgClass(Duration.ofSeconds(3), Map.class);
        Bucket<RoutingTable> localBucket = buckets.values().iterator().next();
        RoutingTable table = localBucket.getData();
        if (table != null && table.size() == nRoutes) {
            for (DOMRpcIdentifier r : added) {
                assertTrue("RoutingTable contains " + r, table.contains(r));
            }
            break;
        }
        if (++numTries >= 50) {
            fail("Expected # routes: " + nRoutes + ", Actual: " + table.size());
        }
        Uninterruptibles.sleepUninterruptibly(200, TimeUnit.MILLISECONDS);
    }
}
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) ArrayList(java.util.ArrayList) DOMRpcIdentifier(org.opendaylight.mdsal.dom.api.DOMRpcIdentifier) TestKit(akka.testkit.javadsl.TestKit) RemoteRpcEndpoint(org.opendaylight.controller.remote.rpc.registry.RpcRegistry.RemoteRpcEndpoint) Test(org.junit.Test)

Example 14 with DOMRpcIdentifier

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

the class RpcRegistryTest method verifyBucket.

private static void verifyBucket(final Bucket<RoutingTable> bucket, final List<DOMRpcIdentifier> expRouteIds) {
    RoutingTable table = bucket.getData();
    assertNotNull("Bucket RoutingTable is null", table);
    for (DOMRpcIdentifier r : expRouteIds) {
        if (!table.contains(r)) {
            fail("RoutingTable does not contain " + r + ". Actual: " + table);
        }
    }
    assertEquals("RoutingTable size", expRouteIds.size(), table.size());
}
Also used : DOMRpcIdentifier(org.opendaylight.mdsal.dom.api.DOMRpcIdentifier)

Example 15 with DOMRpcIdentifier

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

the class AbstractInvokableServiceMetadata method onRpcsAvailable.

protected final void onRpcsAvailable(final Collection<DOMRpcIdentifier> rpcs) {
    for (DOMRpcIdentifier identifier : rpcs) {
        if (rpcSchemaPaths.contains(identifier.getType())) {
            log.debug("{}: onRpcsAvailable - found SchemaPath {}", logName(), identifier.getType());
            setSatisfied();
            break;
        }
    }
}
Also used : DOMRpcIdentifier(org.opendaylight.mdsal.dom.api.DOMRpcIdentifier)

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