Cache QNames obtained from binding classes 88/21788/1
authorRobert Varga <rovarga@cisco.com>
Wed, 3 Jun 2015 09:30:32 +0000 (11:30 +0200)
committerDana Kutenicsova <dkutenic@cisco.com>
Wed, 3 Jun 2015 14:55:56 +0000 (16:55 +0200)
Traces indicate we have a rogue QNameModule coming from this path, make
sure to squash it to a cached one.

Change-Id: I80f72ae0d4b80f35edc97060734fcc8df9c028c0
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit 9d9038bca661edf88e1aae971b4c6883983cfb47)

bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/LocRibWriter.java
bgp/rib-spi/src/main/java/org/opendaylight/protocol/bgp/rib/spi/AbstractRIBSupport.java

index c9e72fbba1d6cd9b46c03ff4621f50eb15c7c9b2..2bf49f2fe583f41972b1f1845ffb43d35c61411f 100644 (file)
@@ -58,6 +58,7 @@ final class LocRibWriter implements AutoCloseable, DOMDataTreeChangeListener {
     private static final Logger LOG = LoggerFactory.getLogger(LocRibWriter.class);
 
     private static final LeafNode<Boolean> ATTRIBUTES_UPTODATE_TRUE = ImmutableNodes.leafNode(QName.create(Attributes.QNAME, "uptodate"), Boolean.TRUE);
+    private static final NodeIdentifier ROUTES_IDENTIFIER = new NodeIdentifier(Routes.QNAME);
 
     private final Map<PathArgument, AbstractRouteEntry> routeEntries = new HashMap<>();
     private final YangInstanceIdentifier locRibTarget;
@@ -216,7 +217,7 @@ final class LocRibWriter implements AutoCloseable, DOMDataTreeChangeListener {
                     final RIBSupportContext ribCtx = this.registry.getRIBSupportContext(this.tableKey);
                     // FIXME: the table should be created for a peer only once
                     ribCtx.clearTable(tx, pid.getValue().node(AdjRibOut.QNAME).node(Tables.QNAME).node(this.tableKey));
-                    final YangInstanceIdentifier routeTarget = this.ribSupport.routePath(pid.getValue().node(AdjRibOut.QNAME).node(Tables.QNAME).node(this.tableKey).node(Routes.QNAME), key.getRouteId());
+                    final YangInstanceIdentifier routeTarget = this.ribSupport.routePath(pid.getValue().node(AdjRibOut.QNAME).node(Tables.QNAME).node(this.tableKey).node(ROUTES_IDENTIFIER), key.getRouteId());
                     if (effectiveAttributes != null && value != null && !peerId.equals(pid.getKey())) {
                         LOG.debug("Write route to AdjRibsOut {}", value);
                         tx.put(LogicalDatastoreType.OPERATIONAL, routeTarget, value);
index c14db983bbf19fb7bb503c58eb198b5940ac7c30..dac9d2a2df01d9df3d0865b0c46075e66740bc0a 100644 (file)
@@ -71,13 +71,13 @@ public abstract class AbstractRIBSupport implements RIBSupport {
      * @param listClass Binding class of the route list, nust not be null;
      */
     protected AbstractRIBSupport(final Class<? extends Routes> cazeClass, final Class<? extends DataObject> containerClass, final Class<? extends Route> listClass) {
-        final QName qname = BindingReflections.findQName(containerClass);
+        final QName qname = QName.cachedReference(BindingReflections.findQName(containerClass));
         this.routesContainerIdentifier = new NodeIdentifier(qname);
         this.routeAttributesIdentifier = new NodeIdentifier(QName.cachedReference(QName.create(qname, Attributes.QNAME.getLocalName())));
         this.cazeClass = Preconditions.checkNotNull(cazeClass);
         this.containerClass = Preconditions.checkNotNull(containerClass);
         this.listClass = Preconditions.checkNotNull(listClass);
-        this.routesListIdentifier = new NodeIdentifier(BindingReflections.findQName(listClass));
+        this.routesListIdentifier = new NodeIdentifier(QName.cachedReference(BindingReflections.findQName(listClass)));
     }
 
     @Override