Search in sources :

Example 6 with DOMRpcIdentifier

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

the class RemoteRpcRegistryMXBeanImplTest method setUp.

@Before
public void setUp() throws Exception {
    system = ActorSystem.create("test");
    final DOMRpcIdentifier emptyRpcIdentifier = DOMRpcIdentifier.create(EMPTY_SCHEMA_PATH, YangInstanceIdentifier.EMPTY);
    final DOMRpcIdentifier localRpcIdentifier = DOMRpcIdentifier.create(LOCAL_SCHEMA_PATH, YangInstanceIdentifier.of(LOCAL_QNAME));
    buckets = Lists.newArrayList(emptyRpcIdentifier, localRpcIdentifier);
    final RemoteRpcProviderConfig config = new RemoteRpcProviderConfig.Builder("system").build();
    final TestKit invoker = new TestKit(system);
    final TestKit registrar = new TestKit(system);
    final TestKit supervisor = new TestKit(system);
    final Props props = RpcRegistry.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 RemoteRpcRegistryMXBeanImpl(new BucketStoreAccess(testActor, system.dispatcher(), timeout), timeout);
}
Also used : Timeout(akka.util.Timeout) DOMRpcIdentifier(org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier) TestKit(akka.testkit.javadsl.TestKit) RemoteRpcProviderConfig(org.opendaylight.controller.remote.rpc.RemoteRpcProviderConfig) Props(akka.actor.Props) BucketStoreAccess(org.opendaylight.controller.remote.rpc.registry.gossip.BucketStoreAccess) Before(org.junit.Before)

Example 7 with DOMRpcIdentifier

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

the class RemoteRpcRegistryMXBeanImpl method getRpcMemberMapByRoute.

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

Example 8 with DOMRpcIdentifier

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

the class RemoteRpcRegistryMXBeanImpl method getGlobalRpc.

@Override
public Set<String> getGlobalRpc() {
    RoutingTable table = getLocalData();
    Set<String> globalRpc = new HashSet<>(table.getRoutes().size());
    for (DOMRpcIdentifier route : table.getRoutes()) {
        if (route.getContextReference().isEmpty()) {
            globalRpc.add(route.getType().toString());
        }
    }
    log.debug("Locally registered global RPCs {}", globalRpc);
    return globalRpc;
}
Also used : RoutingTable(org.opendaylight.controller.remote.rpc.registry.RoutingTable) DOMRpcIdentifier(org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier) HashSet(java.util.HashSet)

Example 9 with DOMRpcIdentifier

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

the class RemoteRpcRegistryMXBeanImpl method getLocalRegisteredRoutedRpc.

@Override
public Set<String> getLocalRegisteredRoutedRpc() {
    RoutingTable table = getLocalData();
    Set<String> routedRpc = new HashSet<>(table.getRoutes().size());
    for (DOMRpcIdentifier route : table.getRoutes()) {
        if (!route.getContextReference().isEmpty()) {
            routedRpc.add(ROUTE_CONSTANT + route.getContextReference() + NAME_CONSTANT + route.getType());
        }
    }
    log.debug("Locally registered routed RPCs {}", routedRpc);
    return routedRpc;
}
Also used : RoutingTable(org.opendaylight.controller.remote.rpc.registry.RoutingTable) DOMRpcIdentifier(org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier) HashSet(java.util.HashSet)

Example 10 with DOMRpcIdentifier

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

the class GetConstantService method registerNew.

public static DOMRpcImplementationRegistration<GetConstantService> registerNew(final DOMRpcProviderService rpcProviderService, final String constant) {
    LOG.debug("Registering get-constant service, constant value: {}", constant);
    final DOMRpcIdentifier id = DOMRpcIdentifier.create(SchemaPath.create(true, GET_CONSTANT));
    return rpcProviderService.registerRpcImplementation(new GetConstantService(constant), id);
}
Also used : DOMRpcIdentifier(org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier)

Aggregations

DOMRpcIdentifier (org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier)17 Address (akka.actor.Address)6 TestKit (akka.testkit.javadsl.TestKit)6 Bucket (org.opendaylight.controller.remote.rpc.registry.gossip.Bucket)5 UniqueAddress (akka.cluster.UniqueAddress)4 Test (org.junit.Test)4 AddOrUpdateRoutes (org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.AddOrUpdateRoutes)4 HashMap (java.util.HashMap)3 Props (akka.actor.Props)2 ArrayList (java.util.ArrayList)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 UpdateRemoteEndpoints (org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.UpdateRemoteEndpoints)2 RemoteRpcEndpoint (org.opendaylight.controller.remote.rpc.registry.RpcRegistry.RemoteRpcEndpoint)2 Timeout (akka.util.Timeout)1 Optional (java.util.Optional)1 RemoteRpcProviderConfig (org.opendaylight.controller.remote.rpc.RemoteRpcProviderConfig)1 BucketStoreAccess (org.opendaylight.controller.remote.rpc.registry.gossip.BucketStoreAccess)1