Search in sources :

Example 11 with DOMRpcIdentifier

use of org.opendaylight.controller.md.sal.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.controller.md.sal.dom.api.DOMRpcIdentifier)

Example 12 with DOMRpcIdentifier

use of org.opendaylight.controller.md.sal.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(SchemaPath.create(true, GET_SINGLETON_CONSTANT));
    rpcRegistration = rpcProviderService.registerRpcImplementation(this, id);
}
Also used : DOMRpcIdentifier(org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier)

Example 13 with DOMRpcIdentifier

use of org.opendaylight.controller.md.sal.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(SchemaPath.create(true, QName.create(URI.create("/mockrpc"), "type" + i)));
        added.add(routeId);
        // Uninterruptibles.sleepUninterruptibly(50, TimeUnit.MILLISECONDS);
        registry1.tell(new AddOrUpdateRoutes(Arrays.asList(routeId)), ActorRef.noSender());
    }
    FiniteDuration duration = Duration.create(3, TimeUnit.SECONDS);
    int numTries = 0;
    while (true) {
        registry1.tell(GET_ALL_BUCKETS, testKit.getRef());
        @SuppressWarnings("unchecked") Map<Address, Bucket<RoutingTable>> buckets = testKit.expectMsgClass(duration, Map.class);
        Bucket<RoutingTable> localBucket = buckets.values().iterator().next();
        RoutingTable table = localBucket.getData();
        if (table != null && table.size() == nRoutes) {
            for (DOMRpcIdentifier r : added) {
                Assert.assertTrue("RoutingTable contains " + r, table.contains(r));
            }
            break;
        }
        if (++numTries >= 50) {
            Assert.fail("Expected # routes: " + nRoutes + ", Actual: " + table.size());
        }
        Uninterruptibles.sleepUninterruptibly(200, TimeUnit.MILLISECONDS);
    }
}
Also used : UniqueAddress(akka.cluster.UniqueAddress) Address(akka.actor.Address) ArrayList(java.util.ArrayList) FiniteDuration(scala.concurrent.duration.FiniteDuration) DOMRpcIdentifier(org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier) TestKit(akka.testkit.javadsl.TestKit) RemoteRpcEndpoint(org.opendaylight.controller.remote.rpc.registry.RpcRegistry.RemoteRpcEndpoint) AddOrUpdateRoutes(org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.AddOrUpdateRoutes) Bucket(org.opendaylight.controller.remote.rpc.registry.gossip.Bucket) Test(org.junit.Test)

Example 14 with DOMRpcIdentifier

use of org.opendaylight.controller.md.sal.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();
    Assert.assertNotNull("Bucket RoutingTable is null", table);
    for (DOMRpcIdentifier r : expRouteIds) {
        if (!table.contains(r)) {
            Assert.fail("RoutingTable does not contain " + r + ". Actual: " + table);
        }
    }
    Assert.assertEquals("RoutingTable size", expRouteIds.size(), table.size());
}
Also used : DOMRpcIdentifier(org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier)

Example 15 with DOMRpcIdentifier

use of org.opendaylight.controller.md.sal.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() throws Exception {
    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);
    Assert.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.controller.md.sal.dom.api.DOMRpcIdentifier) TestKit(akka.testkit.javadsl.TestKit) RemoveRoutes(org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.RemoveRoutes) Test(org.junit.Test)

Aggregations

DOMRpcIdentifier (org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier)17 Address (akka.actor.Address)6 TestKit (akka.testkit.javadsl.TestKit)6 Bucket (org.opendaylight.controller.remote.rpc.registry.gossip.Bucket)5 UniqueAddress (akka.cluster.UniqueAddress)4 Test (org.junit.Test)4 AddOrUpdateRoutes (org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.AddOrUpdateRoutes)4 HashMap (java.util.HashMap)3 Props (akka.actor.Props)2 ArrayList (java.util.ArrayList)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 UpdateRemoteEndpoints (org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.UpdateRemoteEndpoints)2 RemoteRpcEndpoint (org.opendaylight.controller.remote.rpc.registry.RpcRegistry.RemoteRpcEndpoint)2 Timeout (akka.util.Timeout)1 Optional (java.util.Optional)1 RemoteRpcProviderConfig (org.opendaylight.controller.remote.rpc.RemoteRpcProviderConfig)1 BucketStoreAccess (org.opendaylight.controller.remote.rpc.registry.gossip.BucketStoreAccess)1