Search in sources :

Example 1 with RpcRoutingStrategy

use of org.opendaylight.controller.md.sal.dom.broker.spi.rpc.RpcRoutingStrategy in project controller by opendaylight.

the class RpcUtil method decomposeRpcService.

static Collection<SchemaPath> decomposeRpcService(final Class<RpcService> service, final SchemaContext schemaContext, final Predicate<RpcRoutingStrategy> filter) {
    final QNameModule moduleName = BindingReflections.getQNameModule(service);
    final Module module = schemaContext.findModule(moduleName).get();
    LOG.debug("Resolved service {} to module {}", service, module);
    final Collection<RpcDefinition> rpcs = module.getRpcs();
    final Collection<SchemaPath> ret = new ArrayList<>(rpcs.size());
    for (RpcDefinition rpc : rpcs) {
        final RpcRoutingStrategy strategy = RpcRoutingStrategy.from(rpc);
        if (filter.test(strategy)) {
            ret.add(rpc.getPath());
        }
    }
    return ret;
}
Also used : RpcRoutingStrategy(org.opendaylight.controller.md.sal.dom.broker.spi.rpc.RpcRoutingStrategy) RpcDefinition(org.opendaylight.yangtools.yang.model.api.RpcDefinition) SchemaPath(org.opendaylight.yangtools.yang.model.api.SchemaPath) 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 2 with RpcRoutingStrategy

use of org.opendaylight.controller.md.sal.dom.broker.spi.rpc.RpcRoutingStrategy in project controller by opendaylight.

the class DOMRpcRoutingTable method createRpcEntry.

private static AbstractDOMRpcRoutingTableEntry createRpcEntry(final SchemaContext context, final SchemaPath 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.controller.md.sal.dom.broker.spi.rpc.RpcRoutingStrategy) RpcDefinition(org.opendaylight.yangtools.yang.model.api.RpcDefinition)

Aggregations

RpcRoutingStrategy (org.opendaylight.controller.md.sal.dom.broker.spi.rpc.RpcRoutingStrategy)2 RpcDefinition (org.opendaylight.yangtools.yang.model.api.RpcDefinition)2 ArrayList (java.util.ArrayList)1 QNameModule (org.opendaylight.yangtools.yang.common.QNameModule)1 Module (org.opendaylight.yangtools.yang.model.api.Module)1 SchemaPath (org.opendaylight.yangtools.yang.model.api.SchemaPath)1