Search in sources :

Example 1 with RpcRoutingStrategy

use of org.opendaylight.mdsal.dom.spi.RpcRoutingStrategy 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 2 with RpcRoutingStrategy

use of org.opendaylight.mdsal.dom.spi.RpcRoutingStrategy in project controller by opendaylight.

the class RpcUtil method decomposeRpcService.

static Collection<QName> decomposeRpcService(final Class<RpcService> service, final SchemaContext schemaContext, final Predicate<RpcRoutingStrategy> filter) {
    final QNameModule moduleName = BindingReflections.getQNameModule(service);
    final Module module = schemaContext.findModule(moduleName).orElseThrow(() -> new IllegalArgumentException("Module not found in SchemaContext: " + moduleName + "; service: " + service));
    LOG.debug("Resolved service {} to module {}", service, module);
    final Collection<? extends RpcDefinition> rpcs = module.getRpcs();
    final Collection<QName> ret = new ArrayList<>(rpcs.size());
    for (RpcDefinition rpc : rpcs) {
        final RpcRoutingStrategy strategy = RpcRoutingStrategy.from(rpc);
        if (filter.test(strategy)) {
            ret.add(rpc.getQName());
        }
    }
    return ret;
}
Also used : RpcRoutingStrategy(org.opendaylight.mdsal.dom.spi.RpcRoutingStrategy) RpcDefinition(org.opendaylight.yangtools.yang.model.api.RpcDefinition) QName(org.opendaylight.yangtools.yang.common.QName) ArrayList(java.util.ArrayList) QNameModule(org.opendaylight.yangtools.yang.common.QNameModule) Module(org.opendaylight.yangtools.yang.model.api.Module) QNameModule(org.opendaylight.yangtools.yang.common.QNameModule)

Example 3 with RpcRoutingStrategy

use of org.opendaylight.mdsal.dom.spi.RpcRoutingStrategy in project mdsal by opendaylight.

the class RpcServiceAdapter method createStrategy.

private RpcInvocationStrategy createStrategy(final Method method, final RpcDefinition schema) {
    final QName rpcType = schema.getQName();
    final RpcRoutingStrategy strategy = RpcRoutingStrategy.from(schema);
    return strategy.isContextBasedRouted() ? new RoutedStrategy(rpcType, method, strategy.getLeaf()) : new NonRoutedStrategy(rpcType);
}
Also used : RpcRoutingStrategy(org.opendaylight.mdsal.dom.spi.RpcRoutingStrategy) QName(org.opendaylight.yangtools.yang.common.QName)

Example 4 with RpcRoutingStrategy

use of org.opendaylight.mdsal.dom.spi.RpcRoutingStrategy in project mdsal by opendaylight.

the class DOMRpcRoutingTable method createOperationEntry.

@Override
AbstractDOMRpcRoutingTableEntry createOperationEntry(final EffectiveModelContext context, final QName key, final Map<YangInstanceIdentifier, List<DOMRpcImplementation>> implementations) {
    final RpcDefinition rpcDef = findRpcDefinition(context, key);
    if (rpcDef == null) {
        return new UnknownDOMRpcRoutingTableEntry(key, implementations);
    }
    final RpcRoutingStrategy strategy = RpcRoutingStrategy.from(rpcDef);
    if (strategy.isContextBasedRouted()) {
        return new RoutedDOMRpcRoutingTableEntry(rpcDef, YangInstanceIdentifier.of(strategy.getLeaf()), implementations);
    }
    return new GlobalDOMRpcRoutingTableEntry(rpcDef, implementations);
}
Also used : RpcRoutingStrategy(org.opendaylight.mdsal.dom.spi.RpcRoutingStrategy) RpcDefinition(org.opendaylight.yangtools.yang.model.api.RpcDefinition)

Aggregations

RpcRoutingStrategy (org.opendaylight.mdsal.dom.spi.RpcRoutingStrategy)4 QName (org.opendaylight.yangtools.yang.common.QName)3 RpcDefinition (org.opendaylight.yangtools.yang.model.api.RpcDefinition)2 Collections2 (com.google.common.collect.Collections2)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Set (java.util.Set)1 RpcProviderService (org.opendaylight.mdsal.binding.api.RpcProviderService)1 DOMRpcIdentifier (org.opendaylight.mdsal.dom.api.DOMRpcIdentifier)1 DOMRpcImplementationNotAvailableException (org.opendaylight.mdsal.dom.api.DOMRpcImplementationNotAvailableException)1 DOMRpcProviderService (org.opendaylight.mdsal.dom.api.DOMRpcProviderService)1 DOMSchemaService (org.opendaylight.mdsal.dom.api.DOMSchemaService)1 Registration (org.opendaylight.yangtools.concepts.Registration)1 FluentFutures (org.opendaylight.yangtools.util.concurrent.FluentFutures)1 RpcService (org.opendaylight.yangtools.yang.binding.RpcService)1 QNameModule (org.opendaylight.yangtools.yang.common.QNameModule)1 Module (org.opendaylight.yangtools.yang.model.api.Module)1 Bundle (org.osgi.framework.Bundle)1 ComponentDefinitionException (org.osgi.service.blueprint.container.ComponentDefinitionException)1