Search in sources :

Example 6 with DOMRpcIdentifier

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

the class ActionProviderBean method registerFallback.

private void registerFallback(final Class<RpcService> interfaceClass) {
    final Collection<QName> paths = RpcUtil.decomposeRpcService(interfaceClass, schemaService.getGlobalContext(), RpcRoutingStrategy::isContextBasedRouted);
    if (paths.isEmpty()) {
        LOG.warn("{}: interface {} has no actions defined", ACTION_PROVIDER, interfaceClass);
        return;
    }
    final Set<DOMRpcIdentifier> rpcs = ImmutableSet.copyOf(Collections2.transform(paths, DOMRpcIdentifier::create));
    reg = domRpcProvider.registerRpcImplementation((rpc, input) -> FluentFutures.immediateFailedFluentFuture(new DOMRpcImplementationNotAvailableException("Action %s has no instance matching %s", rpc, input)), rpcs);
    LOG.debug("Registered provider for {}", interfaceName);
}
Also used : ImmutableSet(com.google.common.collect.ImmutableSet) Logger(org.slf4j.Logger) Collection(java.util.Collection) LoggerFactory(org.slf4j.LoggerFactory) Set(java.util.Set) Collections2(com.google.common.collect.Collections2) DOMRpcIdentifier(org.opendaylight.mdsal.dom.api.DOMRpcIdentifier) FluentFutures(org.opendaylight.yangtools.util.concurrent.FluentFutures) QName(org.opendaylight.yangtools.yang.common.QName) DOMRpcImplementationNotAvailableException(org.opendaylight.mdsal.dom.api.DOMRpcImplementationNotAvailableException) RpcProviderService(org.opendaylight.mdsal.binding.api.RpcProviderService) RpcService(org.opendaylight.yangtools.yang.binding.RpcService) DOMRpcProviderService(org.opendaylight.mdsal.dom.api.DOMRpcProviderService) Registration(org.opendaylight.yangtools.concepts.Registration) DOMSchemaService(org.opendaylight.mdsal.dom.api.DOMSchemaService) Bundle(org.osgi.framework.Bundle) RpcRoutingStrategy(org.opendaylight.mdsal.dom.spi.RpcRoutingStrategy) ComponentDefinitionException(org.osgi.service.blueprint.container.ComponentDefinitionException) RpcRoutingStrategy(org.opendaylight.mdsal.dom.spi.RpcRoutingStrategy) QName(org.opendaylight.yangtools.yang.common.QName) DOMRpcImplementationNotAvailableException(org.opendaylight.mdsal.dom.api.DOMRpcImplementationNotAvailableException) DOMRpcIdentifier(org.opendaylight.mdsal.dom.api.DOMRpcIdentifier)

Example 7 with DOMRpcIdentifier

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

the class RemoteRpcRegistryMXBeanImpl method getGlobalRpc.

@Override
public Set<String> getGlobalRpc() {
    RoutingTable table = localData();
    Set<String> globalRpc = new HashSet<>(table.getItems().size());
    for (DOMRpcIdentifier route : table.getItems()) {
        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.mdsal.dom.api.DOMRpcIdentifier) HashSet(java.util.HashSet)

Example 8 with DOMRpcIdentifier

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

the class RemoteRpcRegistryMXBeanImpl method getLocalRegisteredRoutedRpc.

@Override
public Set<String> getLocalRegisteredRoutedRpc() {
    RoutingTable table = localData();
    Set<String> routedRpc = new HashSet<>(table.getItems().size());
    for (DOMRpcIdentifier route : table.getItems()) {
        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.mdsal.dom.api.DOMRpcIdentifier) HashSet(java.util.HashSet)

Example 9 with DOMRpcIdentifier

use of org.opendaylight.mdsal.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.getItems();
    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.mdsal.dom.api.DOMRpcIdentifier)

Example 10 with DOMRpcIdentifier

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

the class NetconfDeviceRpcTest method testRegisterRpcListener.

@Test
public void testRegisterRpcListener() throws Exception {
    ArgumentCaptor<Collection> argument = ArgumentCaptor.forClass(Collection.class);
    rpc.registerRpcListener(listener);
    verify(listener).onRpcAvailable(argument.capture());
    final Collection<DOMRpcIdentifier> argValue = argument.getValue();
    final Collection<? extends RpcDefinition> operations = SCHEMA_CONTEXT.getOperations();
    assertEquals(argValue.size(), operations.size());
    for (RpcDefinition operation : operations) {
        final DOMRpcIdentifier domRpcIdentifier = DOMRpcIdentifier.create(operation.getQName());
        assertTrue(argValue.contains(domRpcIdentifier));
    }
}
Also used : RpcDefinition(org.opendaylight.yangtools.yang.model.api.RpcDefinition) Collection(java.util.Collection) DOMRpcIdentifier(org.opendaylight.mdsal.dom.api.DOMRpcIdentifier) AbstractBaseSchemasTest(org.opendaylight.netconf.sal.connect.netconf.AbstractBaseSchemasTest) 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