use of org.opendaylight.mdsal.dom.api.DOMActionInstance in project controller by opendaylight.
the class RemoteActionRegistryMXBeanImpl method getActionMemberMapByName.
/**
* Search if the routing table route type contains name.
*/
private static Map<String, String> getActionMemberMapByName(final ActionRoutingTable table, final String name, final String address) {
Collection<DOMActionInstance> routes = table.getItems();
Map<String, String> actionMap = new HashMap<>(routes.size());
for (DOMActionInstance route : routes) {
final YangInstanceIdentifier actionPath = YangInstanceIdentifier.create(new NodeIdentifier(route.getType().lastNodeIdentifier()));
if (!actionPath.isEmpty()) {
String type = route.getType().toString();
if (type.contains(name)) {
actionMap.put(ROUTE_CONSTANT + actionPath + NAME_CONSTANT + type, address);
}
}
}
return actionMap;
}
use of org.opendaylight.mdsal.dom.api.DOMActionInstance in project controller by opendaylight.
the class ActionRegistryTest method verifyBucket.
private static void verifyBucket(final Bucket<ActionRoutingTable> bucket, final List<DOMActionInstance> expRouteIds) {
ActionRoutingTable table = bucket.getData();
assertNotNull("Bucket ActionRoutingTable is null", table);
for (DOMActionInstance r : expRouteIds) {
if (!table.contains(r)) {
fail("ActionRoutingTable does not contain " + r + ". Actual: " + table);
}
}
assertEquals("ActionRoutingTable size", expRouteIds.size(), table.size());
}
use of org.opendaylight.mdsal.dom.api.DOMActionInstance in project controller by opendaylight.
the class ActionRegistryTest method testActionAddRemoveInCluster.
/**
* Three node cluster. 1. Register action on 1 node, ensure 2nd node gets updated 2. Remove action on
* 1 node, ensure 2nd node gets updated
*/
@Test
public void testActionAddRemoveInCluster() {
LOG.info("testActionAddRemoveInCluster starting");
List<DOMActionInstance> addedRouteIds = createRouteIds();
Address node1Address = node1.provider().getDefaultAddress();
// Add action on node 1
registry1.tell(new UpdateActions(addedRouteIds, Collections.emptyList()), 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<ActionRoutingTable>> buckets = retrieveBuckets(registry2, testKit, node1Address);
verifyBucket(buckets.get(node1Address), addedRouteIds);
// Now remove
registry1.tell(new UpdateActions(Collections.emptyList(), 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("testActionAddRemoveInCluster ending");
}
use of org.opendaylight.mdsal.dom.api.DOMActionInstance in project controller by opendaylight.
the class RemoteActionRegistryMXBeanImplTest method setUp.
@Before
public void setUp() {
system = ActorSystem.create("test", ConfigFactory.load().getConfig("unit-test"));
final DOMActionInstance emptyActionIdentifier = DOMActionInstance.of(REMOTE_SCHEMA_PATH, LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.empty());
final DOMActionInstance localActionIdentifier = DOMActionInstance.of(LOCAL_SCHEMA_PATH, LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.of(LOCAL_QNAME));
buckets = Lists.newArrayList(emptyActionIdentifier, localActionIdentifier);
final RemoteOpsProviderConfig config = new RemoteOpsProviderConfig.Builder("system").build();
final TestKit invoker = new TestKit(system);
final TestKit registrar = new TestKit(system);
final TestKit supervisor = new TestKit(system);
final Props props = ActionRegistry.props(config, invoker.getRef(), registrar.getRef()).withDispatcher(Dispatchers.DefaultDispatcherId());
testActor = new TestActorRef<>(system, props, supervisor.getRef(), "testActor");
final Timeout timeout = Timeout.apply(10, TimeUnit.SECONDS);
mxBean = new RemoteActionRegistryMXBeanImpl(new BucketStoreAccess(testActor, system.dispatcher(), timeout), timeout);
}
use of org.opendaylight.mdsal.dom.api.DOMActionInstance in project controller by opendaylight.
the class RemoteActionRegistryMXBeanImpl method getActionMemberMapByAction.
/**
* Search if the routing table route String contains routeName.
*/
private static Map<String, String> getActionMemberMapByAction(final ActionRoutingTable table, final String routeName, final String address) {
Collection<DOMActionInstance> routes = table.getItems();
Map<String, String> actionMap = new HashMap<>(routes.size());
for (DOMActionInstance route : routes) {
final YangInstanceIdentifier actionPath = YangInstanceIdentifier.create(new NodeIdentifier(route.getType().lastNodeIdentifier()));
if (!actionPath.isEmpty()) {
String routeString = actionPath.toString();
if (routeString.contains(routeName)) {
actionMap.put(ROUTE_CONSTANT + routeString + NAME_CONSTANT + route.getType(), address);
}
}
}
return actionMap;
}
Aggregations