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%2FDebugThreePhaseCommitCohort.java;h=4562ed13c56955c96e3f5ede6cb97c3231e5fb30;hb=2dedb8231e13abe55d6b75eb532d23dbe536e168;hp=e0b5c1f9c869ce72e283708f45e620341512ba8b;hpb=c796596b5c46b5203c30b143e6282662e66c5642;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DebugThreePhaseCommitCohort.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DebugThreePhaseCommitCohort.java index e0b5c1f9c8..4562ed13c5 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DebugThreePhaseCommitCohort.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DebugThreePhaseCommitCohort.java @@ -7,13 +7,18 @@ */ package org.opendaylight.controller.cluster.datastore; +import static java.util.Objects.requireNonNull; + import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Preconditions; import com.google.common.util.concurrent.FutureCallback; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; +import com.google.common.util.concurrent.MoreExecutors; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.util.List; import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier; +import org.opendaylight.mdsal.common.api.CommitInfo; +import org.opendaylight.yangtools.yang.common.Empty; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import scala.concurrent.Future; @@ -30,28 +35,30 @@ class DebugThreePhaseCommitCohort extends AbstractThreePhaseCommitCohort private final AbstractThreePhaseCommitCohort delegate; private final Throwable debugContext; private final TransactionIdentifier transactionId; + + @SuppressFBWarnings("SLF4J_LOGGER_SHOULD_BE_FINAL") private Logger log = LOG; - DebugThreePhaseCommitCohort(TransactionIdentifier transactionId, AbstractThreePhaseCommitCohort delegate, - Throwable debugContext) { - this.delegate = Preconditions.checkNotNull(delegate); - this.debugContext = Preconditions.checkNotNull(debugContext); - this.transactionId = Preconditions.checkNotNull(transactionId); + DebugThreePhaseCommitCohort(final TransactionIdentifier transactionId, + final AbstractThreePhaseCommitCohort delegate, final Throwable debugContext) { + this.delegate = requireNonNull(delegate); + this.debugContext = requireNonNull(debugContext); + this.transactionId = requireNonNull(transactionId); } - private ListenableFuture addFutureCallback(ListenableFuture future) { + private ListenableFuture addFutureCallback(final ListenableFuture future) { Futures.addCallback(future, new FutureCallback() { @Override - public void onSuccess(V result) { + public void onSuccess(final V result) { // no-op } @Override - public void onFailure(Throwable t) { + public void onFailure(final Throwable failure) { log.warn("Transaction {} failed with error \"{}\" - was allocated in the following context", - transactionId, t, debugContext); + transactionId, failure, debugContext); } - }); + }, MoreExecutors.directExecutor()); return future; } @@ -62,17 +69,17 @@ class DebugThreePhaseCommitCohort extends AbstractThreePhaseCommitCohort } @Override - public ListenableFuture preCommit() { + public ListenableFuture preCommit() { return addFutureCallback(delegate.preCommit()); } @Override - public ListenableFuture commit() { + public ListenableFuture commit() { return addFutureCallback(delegate.commit()); } @Override - public ListenableFuture abort() { + public ListenableFuture abort() { return delegate.abort(); } @@ -83,7 +90,7 @@ class DebugThreePhaseCommitCohort extends AbstractThreePhaseCommitCohort } @VisibleForTesting - void setLogger(Logger log) { - this.log = log; + void setLogger(final Logger logger) { + log = logger; } }