X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2FLocalThreePhaseCommitCohort.java;h=091bfa01e4db0346b85fbb432ddace51e7e8857c;hp=db879c07730e99ddfb78aaca3af96790f6077c61;hb=118cd0216b0c6b0ec1a01689ec2025a13e090861;hpb=634dfac8eead60f443bf75e749c70d1f2bb29198 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 db879c0773..091bfa01e4 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,20 +7,23 @@ */ 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.common.api.CommitInfo; 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.opendaylight.yangtools.yang.common.Empty; +import org.opendaylight.yangtools.yang.data.tree.api.DataTreeModification; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import scala.concurrent.Future; @@ -37,28 +40,28 @@ 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.modification = null; + this.actorUtils = requireNonNull(actorUtils); + this.leader = requireNonNull(leader); + this.transaction = requireNonNull(transaction); + this.operationError = requireNonNull(operationError); + modification = null; } private Future initiateCommit(final boolean immediate, @@ -69,12 +72,12 @@ 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(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 @@ -87,14 +90,14 @@ class LocalThreePhaseCommitCohort implements DOMStoreThreePhaseCommitCohort { LOG.debug("Transaction {} resolved to actor {}", transaction.getIdentifier(), success); } - }, actorContext.getClientDispatcher()); + }, actorUtils.getClientDispatcher()); return ret; } Future initiateDirectCommit() { final Future messageFuture = initiateCommit(true, Optional.empty()); - messageFuture.onComplete(new OnComplete() { + messageFuture.onComplete(new OnComplete<>() { @Override public void onComplete(final Throwable failure, final Object message) { if (failure != null) { @@ -109,7 +112,7 @@ class LocalThreePhaseCommitCohort implements DOMStoreThreePhaseCommitCohort { transactionAborted(transaction); } } - }, actorContext.getClientDispatcher()); + }, actorUtils.getClientDispatcher()); return messageFuture; } @@ -121,19 +124,19 @@ class LocalThreePhaseCommitCohort implements DOMStoreThreePhaseCommitCohort { } @Override - public final ListenableFuture preCommit() { + public final ListenableFuture preCommit() { // Intended no-op throw new UnsupportedOperationException(); } @Override - public final ListenableFuture abort() { + public final ListenableFuture abort() { // Intended no-op throw new UnsupportedOperationException(); } @Override - public final ListenableFuture commit() { + public final ListenableFuture commit() { // Intended no-op throw new UnsupportedOperationException(); }