Search in sources :

Example 1 with RemoveRoutes

use of org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.RemoveRoutes 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() throws Exception {
    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.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)

Example 2 with RemoveRoutes

use of org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.RemoveRoutes in project controller by opendaylight.

the class RpcListener method onRpcUnavailable.

@Override
public void onRpcUnavailable(@Nonnull final Collection<DOMRpcIdentifier> rpcs) {
    Preconditions.checkArgument(rpcs != null, "Input Collection of DOMRpcIdentifier can not be null.");
    LOG.debug("Removing registration for [{}]", rpcs);
    rpcRegistry.tell(new RemoveRoutes(rpcs), ActorRef.noSender());
}
Also used : RemoveRoutes(org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.RemoveRoutes)

Example 3 with RemoveRoutes

use of org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.RemoveRoutes 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

RemoveRoutes (org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.RemoveRoutes)3 Address (akka.actor.Address)2 UniqueAddress (akka.cluster.UniqueAddress)2 TestKit (akka.testkit.javadsl.TestKit)2 Test (org.junit.Test)2 DOMRpcIdentifier (org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier)2 AddOrUpdateRoutes (org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.AddOrUpdateRoutes)2 Bucket (org.opendaylight.controller.remote.rpc.registry.gossip.Bucket)2