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%2FLocalThreePhaseCommitCohort.java;h=ac279b7e995aee715b6e050c3c1bce043cfcf16c;hb=3cd86749fb3224544b32bace13cf28abadd2ec44;hp=8d0068172a65eea7124b890354961ab68b1986b0;hpb=731e7284cf0895fdb1b89427f91762e80e67c2ff;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/LocalThreePhaseCommitCohort.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/LocalThreePhaseCommitCohort.java index 8d0068172a..ac279b7e99 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/LocalThreePhaseCommitCohort.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/LocalThreePhaseCommitCohort.java @@ -7,17 +7,18 @@ */ package org.opendaylight.controller.cluster.datastore; +import static java.util.Objects.requireNonNull; + import akka.actor.ActorSelection; import akka.dispatch.Futures; import akka.dispatch.OnComplete; -import com.google.common.base.Preconditions; import com.google.common.util.concurrent.ListenableFuture; import java.util.Optional; import java.util.SortedSet; import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier; import org.opendaylight.controller.cluster.datastore.messages.CommitTransactionReply; import org.opendaylight.controller.cluster.datastore.messages.ReadyLocalTransaction; -import org.opendaylight.controller.cluster.datastore.utils.ActorContext; +import org.opendaylight.controller.cluster.datastore.utils.ActorUtils; import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort; import org.opendaylight.mdsal.dom.spi.store.SnapshotBackedWriteTransaction; import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification; @@ -37,27 +38,27 @@ class LocalThreePhaseCommitCohort implements DOMStoreThreePhaseCommitCohort { private final SnapshotBackedWriteTransaction transaction; private final DataTreeModification modification; - private final ActorContext actorContext; + private final ActorUtils actorUtils; private final ActorSelection leader; private final Exception operationError; - protected LocalThreePhaseCommitCohort(final ActorContext actorContext, final ActorSelection leader, + protected LocalThreePhaseCommitCohort(final ActorUtils actorUtils, final ActorSelection leader, final SnapshotBackedWriteTransaction transaction, final DataTreeModification modification, final Exception operationError) { - this.actorContext = Preconditions.checkNotNull(actorContext); - this.leader = Preconditions.checkNotNull(leader); - this.transaction = Preconditions.checkNotNull(transaction); - this.modification = Preconditions.checkNotNull(modification); + this.actorUtils = requireNonNull(actorUtils); + this.leader = requireNonNull(leader); + this.transaction = requireNonNull(transaction); + this.modification = requireNonNull(modification); this.operationError = operationError; } - protected LocalThreePhaseCommitCohort(final ActorContext actorContext, final ActorSelection leader, + protected LocalThreePhaseCommitCohort(final ActorUtils actorUtils, final ActorSelection leader, final SnapshotBackedWriteTransaction transaction, final Exception operationError) { - this.actorContext = Preconditions.checkNotNull(actorContext); - this.leader = Preconditions.checkNotNull(leader); - this.transaction = Preconditions.checkNotNull(transaction); - this.operationError = Preconditions.checkNotNull(operationError); + this.actorUtils = requireNonNull(actorUtils); + this.leader = requireNonNull(leader); + this.transaction = requireNonNull(transaction); + this.operationError = requireNonNull(operationError); this.modification = null; } @@ -69,25 +70,25 @@ class LocalThreePhaseCommitCohort implements DOMStoreThreePhaseCommitCohort { final ReadyLocalTransaction message = new ReadyLocalTransaction(transaction.getIdentifier(), modification, immediate, participatingShardNames); - return actorContext.executeOperationAsync(leader, message, actorContext.getTransactionCommitOperationTimeout()); + return actorUtils.executeOperationAsync(leader, message, actorUtils.getTransactionCommitOperationTimeout()); } - Future initiateCoordinatedCommit(Optional> participatingShardNames) { + Future initiateCoordinatedCommit(final Optional> participatingShardNames) { final Future messageFuture = initiateCommit(false, participatingShardNames); - final Future ret = TransactionReadyReplyMapper.transform(messageFuture, actorContext, + final Future ret = TransactionReadyReplyMapper.transform(messageFuture, actorUtils, transaction.getIdentifier()); ret.onComplete(new OnComplete() { @Override - public void onComplete(final Throwable failure, final ActorSelection success) throws Throwable { + public void onComplete(final Throwable failure, final ActorSelection success) { if (failure != null) { - LOG.info("Failed to prepare transaction {} on backend", transaction.getIdentifier(), failure); + LOG.warn("Failed to prepare transaction {} on backend", transaction.getIdentifier(), failure); transactionAborted(transaction); return; } LOG.debug("Transaction {} resolved to actor {}", transaction.getIdentifier(), success); } - }, actorContext.getClientDispatcher()); + }, actorUtils.getClientDispatcher()); return ret; } @@ -96,19 +97,20 @@ class LocalThreePhaseCommitCohort implements DOMStoreThreePhaseCommitCohort { final Future messageFuture = initiateCommit(true, Optional.empty()); messageFuture.onComplete(new OnComplete() { @Override - public void onComplete(final Throwable failure, final Object message) throws Throwable { + public void onComplete(final Throwable failure, final Object message) { if (failure != null) { - LOG.error("Failed to prepare transaction {} on backend", transaction.getIdentifier(), failure); + LOG.warn("Failed to prepare transaction {} on backend", transaction.getIdentifier(), failure); transactionAborted(transaction); } else if (CommitTransactionReply.isSerializedType(message)) { LOG.debug("Transaction {} committed successfully", transaction.getIdentifier()); transactionCommitted(transaction); } else { - LOG.error("Transaction {} resulted in unhandled message type {}, aborting", message.getClass()); + LOG.error("Transaction {} resulted in unhandled message type {}, aborting", + transaction.getIdentifier(), message.getClass()); transactionAborted(transaction); } } - }, actorContext.getClientDispatcher()); + }, actorUtils.getClientDispatcher()); return messageFuture; } @@ -137,9 +139,9 @@ class LocalThreePhaseCommitCohort implements DOMStoreThreePhaseCommitCohort { throw new UnsupportedOperationException(); } - protected void transactionAborted(SnapshotBackedWriteTransaction aborted) { + protected void transactionAborted(final SnapshotBackedWriteTransaction aborted) { } - protected void transactionCommitted(SnapshotBackedWriteTransaction comitted) { + protected void transactionCommitted(final SnapshotBackedWriteTransaction comitted) { } }