Make logging conditional. 00/21900/2
authorDana Kutenicsova <dkutenic@cisco.com>
Thu, 4 Jun 2015 18:50:35 +0000 (20:50 +0200)
committerGerrit Code Review <gerrit@opendaylight.org>
Fri, 5 Jun 2015 13:40:05 +0000 (13:40 +0000)
When dealing with a lot of routes, logging
in this class becomes a memory burden. Get rid of it
when logging is not enabled.

Change-Id: I3ea2d88c7515172e35689cf1c59698962cf9b0e4
Signed-off-by: Dana Kutenicsova <dkutenic@cisco.com>
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/AbstractRouteEntry.java

index c38c4c64d91e729b61b10a1aac9abdbcb61003f5..91092a69ac09a787ac011b942816bdcaa0f6e373 100644 (file)
@@ -48,7 +48,9 @@ abstract class AbstractRouteEntry {
         }
 
         this.offsets.setValue(this.values, offset, attributes);
-        LOG.trace("Added route from {} attributes {}", routerId, attributes);
+        if (LOG.isTraceEnabled()) {
+            LOG.trace("Added route from {} attributes {}", routerId, attributes);
+        }
         return offset;
     }
 
@@ -80,14 +82,18 @@ abstract class AbstractRouteEntry {
         for (int i = 0; i < this.offsets.size(); ++i) {
             final UnsignedInteger routerId = this.offsets.getRouterId(i);
             final ContainerNode attributes = this.offsets.getValue(this.values, i);
-            LOG.trace("Processing router id {} attributes {}", routerId, attributes);
+            if (LOG.isTraceEnabled()) {
+                LOG.trace("Processing router id {} attributes {}", routerId, attributes);
+            }
             selector.processPath(routerId, attributes);
         }
 
         // Get the newly-selected best path.
         final BestPath newBestPath = selector.result();
         final boolean ret = !newBestPath.equals(this.bestPath);
-        LOG.trace("Previous best {}, current best {}, result {}", this.bestPath, newBestPath, ret);
+        if (LOG.isTraceEnabled()) {
+            LOG.trace("Previous best {}, current best {}, result {}", this.bestPath, newBestPath, ret);
+        }
         this.bestPath = newBestPath;
         return ret;
     }