Stop logging complete data tree on prepare/commit failure 13/36513/2
authorMoiz Raja <moraja@cisco.com>
Fri, 18 Mar 2016 19:29:50 +0000 (12:29 -0700)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 24 Mar 2016 19:23:05 +0000 (19:23 +0000)
Sometimes the data tree modification is so large that just trying to create
the buffer to hold the message can make the controller run out of memory. Plus
it's rarely useful to have a log filled with data which obfuscates other
important log messages. This patch still logs the data tree modification at
trace level.

Change-Id: I76bff9f7e836ee5eff347b0b77e2817f441ab953
Signed-off-by: Moiz Raja <moraja@cisco.com>
(cherry picked from commit 2cf157241dc0ce5045c26e2ad07d053a60b37822)

opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/SimpleShardDataTreeCohort.java

index 4860e38e8fdffb7e61a121c1340915d28f3b1ce8..0c44f6a92d3d1dadb5f1d99d95d4ec18ae620e04 100644 (file)
@@ -77,7 +77,11 @@ final class SimpleShardDataTreeCohort extends ShardDataTreeCohort {
             LOG.trace("Transaction {} prepared candidate {}", transaction, candidate);
             return VOID_FUTURE;
         } catch (Exception e) {
-            LOG.debug("Transaction {} failed to prepare", transaction, e);
+            if(LOG.isTraceEnabled()) {
+                LOG.trace("Transaction {} failed to prepare", transaction, e);
+            } else {
+                LOG.error("Transaction failed to prepare", e);
+            }
             return Futures.immediateFailedFuture(e);
         }
     }
@@ -101,7 +105,11 @@ final class SimpleShardDataTreeCohort extends ShardDataTreeCohort {
         try {
             dataTree.getDataTree().commit(candidate);
         } catch (Exception e) {
-            LOG.error("Transaction {} failed to commit", transaction, e);
+            if(LOG.isTraceEnabled()) {
+                LOG.trace("Transaction {} failed to commit", transaction, e);
+            } else {
+                LOG.error("Transaction failed to commit", e);
+            }
             return Futures.immediateFailedFuture(e);
         }