BUG-3128: do not open-code routed RPC identification 34/50734/4
authorRobert Varga <rovarga@cisco.com>
Fri, 20 Jan 2017 12:15:04 +0000 (13:15 +0100)
committerTom Pantelis <tpanteli@brocade.com>
Tue, 24 Jan 2017 03:29:08 +0000 (03:29 +0000)
Identification of routed RPCs is available via RpcRoutingStrategy.
Use that code to identify routed RPC instead of duplicating same
logic in multiple places.

Change-Id: I5a12b8fd891cb41f805b2a4e7ae465d4004aca39
Signed-off-by: Robert Varga <rovarga@cisco.com>
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMRpcRoutingTable.java

index 22e3305..a32b538 100644 (file)
@@ -28,20 +28,16 @@ import org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementation;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementationNotAvailableException;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
+import org.opendaylight.controller.md.sal.dom.broker.spi.rpc.RpcRoutingStrategy;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
 
 final class DOMRpcRoutingTable {
-    private static final QName CONTEXT_REFERENCE = QName.create("urn:opendaylight:yang:extension:yang-ext",
-        "2013-07-09", "context-reference").intern();
 
     static final DOMRpcRoutingTable EMPTY = new DOMRpcRoutingTable(ImmutableMap.of(), null);
 
@@ -161,16 +157,11 @@ final class DOMRpcRoutingTable {
             return new UnknownDOMRpcRoutingTableEntry(key, implementations);
         }
 
-        final ContainerSchemaNode input = rpcDef.getInput();
-        if (input != null) {
-            for (DataSchemaNode c : input.getChildNodes()) {
-                for (UnknownSchemaNode extension : c.getUnknownSchemaNodes()) {
-                    if (CONTEXT_REFERENCE.equals(extension.getNodeType())) {
-                        final YangInstanceIdentifier keyId = YangInstanceIdentifier.of(c.getQName());
-                        return new RoutedDOMRpcRoutingTableEntry(rpcDef, keyId, implementations);
-                    }
-                }
-            }
+        final RpcRoutingStrategy strategy = RpcRoutingStrategy.from(rpcDef);
+        if (strategy.isContextBasedRouted()) {
+            return new RoutedDOMRpcRoutingTableEntry(rpcDef, YangInstanceIdentifier.of(strategy.getLeaf()),
+                implementations);
+
         }
 
         return new GlobalDOMRpcRoutingTableEntry(rpcDef, implementations);

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.