BUG 3340 : Improve logging
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / SimpleShardDataTreeCohort.java
index 9f22ce8a73e2380625f2f03c0e1ab5e7b35a2c29..2b6b39684a271976be496cd366eda3ef0797b7c9 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.controller.cluster.datastore;
 import com.google.common.base.Preconditions;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
+import org.opendaylight.controller.cluster.datastore.utils.PruningDataTreeModification;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateTip;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
 import org.slf4j.Logger;
@@ -36,8 +37,8 @@ final class SimpleShardDataTreeCohort extends ShardDataTreeCohort {
     @Override
     public ListenableFuture<Boolean> canCommit() {
         try {
-            dataTree.getDataTree().validate(transaction);
-            LOG.debug("Transaction {} validated", transaction);
+            dataTree.getDataTree().validate(dataTreeModification());
+            LOG.trace("Transaction {} validated", transaction);
             return TRUE_FUTURE;
         } catch (Exception e) {
             return Futures.immediateFailedFuture(e);
@@ -47,12 +48,12 @@ final class SimpleShardDataTreeCohort extends ShardDataTreeCohort {
     @Override
     public ListenableFuture<Void> preCommit() {
         try {
-            candidate = dataTree.getDataTree().prepare(transaction);
+            candidate = dataTree.getDataTree().prepare(dataTreeModification());
             /*
              * FIXME: this is the place where we should be interacting with persistence, specifically by invoking
              *        persist on the candidate (which gives us a Future).
              */
-            LOG.debug("Transaction {} prepared candidate {}", transaction, candidate);
+            LOG.trace("Transaction {} prepared candidate {}", transaction, candidate);
             return VOID_FUTURE;
         } catch (Exception e) {
             LOG.debug("Transaction {} failed to prepare", transaction, e);
@@ -60,6 +61,14 @@ final class SimpleShardDataTreeCohort extends ShardDataTreeCohort {
         }
     }
 
+    private DataTreeModification dataTreeModification() {
+        DataTreeModification dataTreeModification = transaction;
+        if(transaction instanceof PruningDataTreeModification){
+            dataTreeModification = ((PruningDataTreeModification) transaction).getDelegate();
+        }
+        return dataTreeModification;
+    }
+
     @Override
     public ListenableFuture<Void> abort() {
         // No-op, really
@@ -75,7 +84,7 @@ final class SimpleShardDataTreeCohort extends ShardDataTreeCohort {
             return Futures.immediateFailedFuture(e);
         }
 
-        LOG.debug("Transaction {} committed, proceeding to notify", transaction);
+        LOG.trace("Transaction {} committed, proceeding to notify", transaction);
         dataTree.notifyListeners(candidate);
         return VOID_FUTURE;
     }