Search in sources :

Example 16 with DOMRpcIdentifier

use of org.opendaylight.mdsal.dom.api.DOMRpcIdentifier in project controller by opendaylight.

the class RemoteRpcRegistryMXBeanImpl method getRpcMemberMapByName.

/**
 * Search if the routing table route type contains name.
 */
private static Map<String, String> getRpcMemberMapByName(final RoutingTable table, final String name, final String address) {
    Set<DOMRpcIdentifier> routes = table.getItems();
    Map<String, String> rpcMap = new HashMap<>(routes.size());
    for (DOMRpcIdentifier route : routes) {
        if (!route.getContextReference().isEmpty()) {
            String type = route.getType().toString();
            if (type.contains(name)) {
                rpcMap.put(ROUTE_CONSTANT + route.getContextReference() + NAME_CONSTANT + type, address);
            }
        }
    }
    return rpcMap;
}
Also used : HashMap(java.util.HashMap) DOMRpcIdentifier(org.opendaylight.mdsal.dom.api.DOMRpcIdentifier)

Example 17 with DOMRpcIdentifier

use of org.opendaylight.mdsal.dom.api.DOMRpcIdentifier in project controller by opendaylight.

the class OpsRegistrarTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    system = ActorSystem.create("test");
    final TestKit testKit = new TestKit(system);
    final RemoteOpsProviderConfig config = new RemoteOpsProviderConfig.Builder("system").build();
    final Props props = OpsRegistrar.props(config, rpcService, actionService);
    testActorRef = new TestActorRef<>(system, props, testKit.getRef(), "actorRef");
    endpointAddress = new Address("http", "local");
    final DOMRpcIdentifier firstEndpointId = DOMRpcIdentifier.create(QName.create("first:identifier", "foo"));
    final DOMRpcIdentifier secondEndpointId = DOMRpcIdentifier.create(QName.create("second:identifier", "bar"));
    final QName firstActionQName = QName.create("first:actionIdentifier", "fooAction");
    final DOMActionInstance firstActionInstance = DOMActionInstance.of(Absolute.of(firstActionQName), LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.create(new YangInstanceIdentifier.NodeIdentifier(firstActionQName)));
    final DOMActionInstance secondActionInstance = DOMActionInstance.of(Absolute.of(firstActionQName), LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.create(new YangInstanceIdentifier.NodeIdentifier(firstActionQName)));
    final TestKit senderKit = new TestKit(system);
    firstEndpoint = new RemoteRpcEndpoint(senderKit.getRef(), Collections.singletonList(firstEndpointId));
    secondEndpoint = new RemoteRpcEndpoint(senderKit.getRef(), Collections.singletonList(secondEndpointId));
    firstActionEndpoint = new RemoteActionEndpoint(senderKit.getRef(), Collections.singletonList(firstActionInstance));
    secondActionEndpoint = new RemoteActionEndpoint(senderKit.getRef(), Collections.singletonList(secondActionInstance));
    doReturn(oldReg).when(rpcService).registerRpcImplementation(any(RemoteRpcImplementation.class), eq(firstEndpoint.getRpcs()));
    doReturn(newReg).when(rpcService).registerRpcImplementation(any(RemoteRpcImplementation.class), eq(secondEndpoint.getRpcs()));
    doReturn(oldActionReg).when(actionService).registerActionImplementation(any(RemoteActionImplementation.class), eq(secondActionEndpoint.getActions()));
    doReturn(oldActionReg).when(actionService).registerActionImplementation(any(RemoteActionImplementation.class), eq(secondActionEndpoint.getActions()));
    opsRegistrar = testActorRef.underlyingActor();
}
Also used : Address(akka.actor.Address) QName(org.opendaylight.yangtools.yang.common.QName) RemoteRpcEndpoint(org.opendaylight.controller.remote.rpc.registry.RpcRegistry.RemoteRpcEndpoint) DOMRpcIdentifier(org.opendaylight.mdsal.dom.api.DOMRpcIdentifier) TestKit(akka.testkit.javadsl.TestKit) Props(akka.actor.Props) DOMActionInstance(org.opendaylight.mdsal.dom.api.DOMActionInstance) RemoteActionEndpoint(org.opendaylight.controller.remote.rpc.registry.ActionRegistry.RemoteActionEndpoint) Before(org.junit.Before)

Example 18 with DOMRpcIdentifier

use of org.opendaylight.mdsal.dom.api.DOMRpcIdentifier in project mdsal by opendaylight.

the class ForwardingDOMRpcImplementationTest method basicTest.

@Test
public void basicTest() throws Exception {
    final DOMRpcIdentifier domRpcIdentifier = mock(DOMRpcIdentifier.class);
    doReturn(null).when(domRpcImplementation).invokeRpc(domRpcIdentifier, null);
    this.invokeRpc(domRpcIdentifier, null);
    verify(domRpcImplementation).invokeRpc(domRpcIdentifier, null);
}
Also used : DOMRpcIdentifier(org.opendaylight.mdsal.dom.api.DOMRpcIdentifier) Test(org.junit.Test)

Aggregations

DOMRpcIdentifier (org.opendaylight.mdsal.dom.api.DOMRpcIdentifier)18 TestKit (akka.testkit.javadsl.TestKit)6 Test (org.junit.Test)6 Address (akka.actor.Address)5 UniqueAddress (akka.cluster.UniqueAddress)4 AddOrUpdateRoutes (org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.AddOrUpdateRoutes)4 Bucket (org.opendaylight.controller.remote.rpc.registry.gossip.Bucket)4 QName (org.opendaylight.yangtools.yang.common.QName)3 Props (akka.actor.Props)2 ArrayList (java.util.ArrayList)2 Collection (java.util.Collection)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Before (org.junit.Before)2 RoutingTable (org.opendaylight.controller.remote.rpc.registry.RoutingTable)2 RemoveRoutes (org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.RemoveRoutes)2 RemoteRpcEndpoint (org.opendaylight.controller.remote.rpc.registry.RpcRegistry.RemoteRpcEndpoint)2 Timeout (akka.util.Timeout)1 Collections2 (com.google.common.collect.Collections2)1 ImmutableSet (com.google.common.collect.ImmutableSet)1