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=db879c07730e99ddfb78aaca3af96790f6077c61;hb=refs%2Fchanges%2F51%2F75351%2F4;hp=d90b82be4bff1184bd0e846c6fe82f13e5c814aa;hpb=c796596b5c46b5203c30b143e6282662e66c5642;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 d90b82be4b..db879c0773 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 @@ -12,13 +12,14 @@ 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.TransactionIdentifierUtils; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort; -import org.opendaylight.controller.sal.core.spi.data.SnapshotBackedWriteTransaction; +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; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -41,12 +42,14 @@ class LocalThreePhaseCommitCohort implements DOMStoreThreePhaseCommitCohort { private final Exception operationError; protected LocalThreePhaseCommitCohort(final ActorContext actorContext, final ActorSelection leader, - final SnapshotBackedWriteTransaction transaction, final DataTreeModification modification) { + 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.operationError = null; + this.operationError = operationError; } protected LocalThreePhaseCommitCohort(final ActorContext actorContext, final ActorSelection leader, @@ -58,25 +61,26 @@ class LocalThreePhaseCommitCohort implements DOMStoreThreePhaseCommitCohort { this.modification = null; } - private Future initiateCommit(final boolean immediate) { - if(operationError != null) { + private Future initiateCommit(final boolean immediate, + final Optional> participatingShardNames) { + if (operationError != null) { return Futures.failed(operationError); } - final ReadyLocalTransaction message = new ReadyLocalTransaction( - TransactionIdentifierUtils.actorNameFor(transaction.getIdentifier()), modification, immediate); + final ReadyLocalTransaction message = new ReadyLocalTransaction(transaction.getIdentifier(), + modification, immediate, participatingShardNames); return actorContext.executeOperationAsync(leader, message, actorContext.getTransactionCommitOperationTimeout()); } - Future initiateCoordinatedCommit() { - final Future messageFuture = initiateCommit(false); + Future initiateCoordinatedCommit(final Optional> participatingShardNames) { + final Future messageFuture = initiateCommit(false, participatingShardNames); final Future ret = TransactionReadyReplyMapper.transform(messageFuture, actorContext, 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; } @@ -89,18 +93,19 @@ class LocalThreePhaseCommitCohort implements DOMStoreThreePhaseCommitCohort { } Future initiateDirectCommit() { - final Future messageFuture = initiateCommit(true); + 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); } } @@ -133,9 +138,9 @@ class LocalThreePhaseCommitCohort implements DOMStoreThreePhaseCommitCohort { throw new UnsupportedOperationException(); } - protected void transactionAborted(SnapshotBackedWriteTransaction transaction) { + protected void transactionAborted(final SnapshotBackedWriteTransaction aborted) { } - protected void transactionCommitted(SnapshotBackedWriteTransaction transaction) { + protected void transactionCommitted(final SnapshotBackedWriteTransaction comitted) { } }