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");
}
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());
}
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");
}
Aggregations