X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2FSimpleShardDataTreeCohort.java;h=28428815109e87f05f87b3b83a807f3d5fa98167;hb=92f2f20ea21e4e92d6407cd687d7dc34854e330a;hp=7f1c6a0cb2e578670c5c880453cc03a1a8117832;hpb=561058be77594a026abbdbe82616fc65c7f58f48;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/SimpleShardDataTreeCohort.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/SimpleShardDataTreeCohort.java index 7f1c6a0cb2..2842881510 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/SimpleShardDataTreeCohort.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/SimpleShardDataTreeCohort.java @@ -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_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 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 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); }