Bug 8424: Don't output data tree and tree candidates wih debug 80/56880/5
authorTom Pantelis <tompantelis@gmail.com>
Thu, 11 May 2017 16:31:27 +0000 (12:31 -0400)
committerRobert Varga <nite@hq.sk>
Fri, 12 May 2017 07:47:57 +0000 (07:47 +0000)
Data trees and tree candidates can get quite large and fill up the
log files when debug is on and, worst case, cause OOM errors. For
debug logging, only print the whole tree/candidate with trace logging.
In cases where an Optional data tree is outputted via toString, only
output if the data tree is present or not.

Change-Id: I6cb5f9a5da9e3cc3218c83bb103b673db0fb1d80
Signed-off-by: Tom Pantelis <tompantelis@gmail.com>
opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/commands/ConnectClientSuccess.java
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/ConnectClientSuccessTest.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/ShardBackendInfo.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/CompositeDataTreeCohort.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DefaultShardDataTreeChangeListenerPublisher.java

index c813605..90eff1b 100644 (file)
@@ -94,7 +94,7 @@ public final class ConnectClientSuccess extends RequestSuccess<ClientIdentifier,
 
     @Override
     protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
-        return super.addToStringAttributes(toStringHelper).add("alternates", alternates).add("dataTree", dataTree)
-                .add("maxMessages", maxMessages);
+        return super.addToStringAttributes(toStringHelper).add("alternates", alternates)
+                .add("dataTree present", getDataTree().isPresent()).add("maxMessages", maxMessages);
     }
 }
index ea346e8..daaae4f 100644 (file)
@@ -78,11 +78,9 @@ public class ConnectClientSuccessTest extends AbstractRequestSuccessTest<Connect
     }
 
     @Test
-    public void addToStringAttributes() throws Exception {
-        final MoreObjects.ToStringHelper result = OBJECT.addToStringAttributes(MoreObjects.toStringHelper(OBJECT));
-        Assert.assertTrue(result.toString().contains("alternates=" + ALTERNATES));
-        Assert.assertTrue(result.toString().contains("dataTree=" + TREE));
-        Assert.assertTrue(result.toString().contains("maxMessages=" + MAX_MESSAGES));
+    public void addToStringAttributes() {
+        // Just verify it doesn't throw an exception.
+        OBJECT.addToStringAttributes(MoreObjects.toStringHelper(OBJECT));
     }
 
     @Override
index c906e1a..86acd1b 100644 (file)
@@ -58,6 +58,6 @@ final class ShardBackendInfo extends BackendInfo {
     @Override
     protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
         return super.addToStringAttributes(toStringHelper).add("cookie", cookie).add("shard", shardName)
-                .add("dataTree", dataTree.orElse(null));
+                .add("dataTree present", getDataTree().isPresent());
     }
 }
index a84fa46..338ae64 100644 (file)
@@ -134,7 +134,11 @@ class CompositeDataTreeCohort {
     }
 
     void canCommit(final DataTreeCandidate tip) throws ExecutionException, TimeoutException {
-        LOG.debug("{}: canCommit - candidate: {}", txId, tip);
+        if (LOG.isTraceEnabled()) {
+            LOG.trace("{}: canCommit - candidate: {}", txId, tip);
+        } else {
+            LOG.debug("{}: canCommit - candidate rootPath: {}", txId, tip.getRootPath());
+        }
 
         final List<CanCommit> messages = registry.createCanCommitMessages(txId, tip, schema);
         LOG.debug("{}: canCommit - messages: {}", txId, messages);
index 895ce30..449b620 100644 (file)
@@ -38,7 +38,12 @@ final class DefaultShardDataTreeChangeListenerPublisher extends AbstractDOMStore
 
     @Override
     public void publishChanges(final DataTreeCandidate candidate) {
-        LOG.debug("{}: publishChanges: {}", logContext, candidate);
+        if (LOG.isTraceEnabled()) {
+            LOG.trace("{}: publishChanges: {}", logContext, candidate);
+        } else {
+            LOG.debug("{}: publishChanges: rootPath: {}", logContext, candidate.getRootPath());
+        }
+
         processCandidateTree(candidate);
     }
 

©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.