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