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