Reduce missing feature warning to debug
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / SimpleShardDataTreeCohort.java
index 7f1c6a0cb2e578670c5c880453cc03a1a8117832..28428815109e87f05f87b3b83a807f3d5fa98167 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.access.concepts.TransactionIdentifier;
 import org.opendaylight.controller.cluster.datastore.utils.PruningDataTreeModification;
 import org.opendaylight.controller.md.sal.common.api.data.OptimisticLockFailedException;
 import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
@@ -26,14 +27,14 @@ final class SimpleShardDataTreeCohort extends ShardDataTreeCohort {
     private static final ListenableFuture<Void> VOID_FUTURE = Futures.immediateFuture(null);
     private final DataTreeModification transaction;
     private final ShardDataTree dataTree;
-    private final String transactionId;
+    private final TransactionIdentifier transactionId;
     private DataTreeCandidateTip candidate;
 
     SimpleShardDataTreeCohort(final ShardDataTree dataTree, final DataTreeModification transaction,
-            final String transactionId) {
+            final TransactionIdentifier transactionId) {
         this.dataTree = Preconditions.checkNotNull(dataTree);
         this.transaction = Preconditions.checkNotNull(transaction);
-        this.transactionId = transactionId;
+        this.transactionId = Preconditions.checkNotNull(transactionId);
     }
 
     @Override
@@ -43,7 +44,7 @@ final class SimpleShardDataTreeCohort extends ShardDataTreeCohort {
 
     @Override
     public ListenableFuture<Boolean> canCommit() {
-        DataTreeModification modification = dataTreeModification();
+        DataTreeModification modification = getDataTreeModification();
         try {
             dataTree.getDataTree().validate(modification);
             LOG.trace("Transaction {} validated", transaction);
@@ -69,7 +70,7 @@ final class SimpleShardDataTreeCohort extends ShardDataTreeCohort {
     @Override
     public ListenableFuture<Void> preCommit() {
         try {
-            candidate = dataTree.getDataTree().prepare(dataTreeModification());
+            candidate = dataTree.getDataTree().prepare(getDataTreeModification());
             /*
              * FIXME: this is the place where we should be interacting with persistence, specifically by invoking
              *        persist on the candidate (which gives us a Future).
@@ -77,12 +78,17 @@ 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);
         }
     }
 
-    private DataTreeModification dataTreeModification() {
+    @Override
+    DataTreeModification getDataTreeModification() {
         DataTreeModification dataTreeModification = transaction;
         if(transaction instanceof PruningDataTreeModification){
             dataTreeModification = ((PruningDataTreeModification) transaction).getResultingModification();
@@ -101,7 +107,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);
         }