BUG-2383: optimize locRibTarget 10/17910/1
authorRobert Varga <rovarga@cisco.com>
Wed, 8 Apr 2015 10:56:49 +0000 (12:56 +0200)
committerRobert Varga <rovarga@cisco.com>
Wed, 8 Apr 2015 10:56:49 +0000 (12:56 +0200)
Since we will be using this instance identifier extensively, make sure
it is compacted, speeding up operations on it. Also remove unneeded
method.

Change-Id: I2b92c1bed21b4c7b0a78eb1c7e2c363b429642ab
Signed-off-by: Robert Varga <rovarga@cisco.com>
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/LocRibWriter.java

index 5e1311aeeae05bf06b900cc580622ebd7c12a3cc..59202fac9e460d2a75add482761be8764c2deffd 100644 (file)
@@ -41,7 +41,6 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodes;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.ModificationType;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -61,7 +60,7 @@ final class LocRibWriter implements AutoCloseable, DOMDataTreeChangeListener {
     LocRibWriter(final RIBSupport ribSupport, final DOMTransactionChain chain, final YangInstanceIdentifier target, final Long ourAs,
         final DOMDataTreeChangeService service, final PolicyDatabase pd, final TablesKey tablesKey) {
         this.chain = Preconditions.checkNotNull(chain);
-        this.locRibTarget = Preconditions.checkNotNull(target).node(LocRib.QNAME).node(Tables.QNAME).node(RibSupportUtils.toYangTablesKey(tablesKey)).node(Routes.QNAME);
+        this.locRibTarget = YangInstanceIdentifier.create(target.node(LocRib.QNAME).node(Tables.QNAME).node(RibSupportUtils.toYangTablesKey(tablesKey)).node(Routes.QNAME).getPathArguments());
         this.ourAs = Preconditions.checkNotNull(ourAs);
         this.attributesIdentifier = ribSupport.routeAttributesIdentifier();
         this.peerPolicyTracker = new ExportPolicyPeerTracker(service, target, pd);
@@ -85,19 +84,6 @@ final class LocRibWriter implements AutoCloseable, DOMDataTreeChangeListener {
         this.peerPolicyTracker.close();
     }
 
-    private static void printChildren(final DataTreeCandidateNode root) {
-        LOG.debug("Candidate node {} type {} identifier {}", root, root.getModificationType(), root.getIdentifier());
-        if (ModificationType.WRITE.equals(root.getModificationType())) {
-            LOG.debug("Data after {}", root.getDataAfter());
-        }
-        if (root.getChildNodes().isEmpty()) {
-            return;
-        }
-        for (final DataTreeCandidateNode child : root.getChildNodes()) {
-            printChildren(child);
-        }
-    }
-
     @Override
     public void onDataTreeChanged(final Collection<DataTreeCandidate> changes) {
         final DOMDataWriteTransaction tx = this.chain.newWriteOnlyTransaction();
@@ -154,6 +140,7 @@ final class LocRibWriter implements AutoCloseable, DOMDataTreeChangeListener {
             } else {
                 value = null;
             }
+
             final YangInstanceIdentifier writePath = this.ribSupport.routePath(this.locRibTarget, e.getKey().getRouteId());
             if (value != null) {
                 LOG.debug("Write route to LocRib {}", value);