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%2FSingleCommitCohortProxy.java;h=c099c45cdb912a172b87f434378bfb77fe7869f9;hp=9c17bc1a476c3c95060498656df9061a8312bcab;hb=118cd0216b0c6b0ec1a01689ec2025a13e090861;hpb=0281535ab08fd795e42df66d25e9a904ff941ad7 diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/SingleCommitCohortProxy.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/SingleCommitCohortProxy.java index 9c17bc1a47..c099c45cdb 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/SingleCommitCohortProxy.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/SingleCommitCohortProxy.java @@ -7,13 +7,17 @@ */ package org.opendaylight.controller.cluster.datastore; +import static java.util.Objects.requireNonNull; + import akka.dispatch.OnComplete; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.SettableFuture; -import java.util.Arrays; import java.util.List; -import org.opendaylight.controller.cluster.datastore.utils.ActorContext; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort; +import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier; +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.yangtools.yang.common.Empty; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import scala.concurrent.Future; @@ -28,17 +32,17 @@ import scala.concurrent.Future; class SingleCommitCohortProxy extends AbstractThreePhaseCommitCohort { private static final Logger LOG = LoggerFactory.getLogger(SingleCommitCohortProxy.class); - private final ActorContext actorContext; + private final ActorUtils actorUtils; private final Future cohortFuture; - private final String transactionId; + private final TransactionIdentifier transactionId; private volatile DOMStoreThreePhaseCommitCohort delegateCohort = NoOpDOMStoreThreePhaseCommitCohort.INSTANCE; private final OperationCallback.Reference operationCallbackRef; - SingleCommitCohortProxy(ActorContext actorContext, Future cohortFuture, String transactionId, - OperationCallback.Reference operationCallbackRef) { - this.actorContext = actorContext; + SingleCommitCohortProxy(final ActorUtils actorUtils, final Future cohortFuture, + final TransactionIdentifier transactionId, final OperationCallback.Reference operationCallbackRef) { + this.actorUtils = actorUtils; this.cohortFuture = cohortFuture; - this.transactionId = transactionId; + this.transactionId = requireNonNull(transactionId); this.operationCallbackRef = operationCallbackRef; } @@ -48,10 +52,10 @@ class SingleCommitCohortProxy extends AbstractThreePhaseCommitCohort { final SettableFuture returnFuture = SettableFuture.create(); - cohortFuture.onComplete(new OnComplete() { + cohortFuture.onComplete(new OnComplete<>() { @Override - public void onComplete(Throwable failure, Object cohortResponse) { - if(failure != null) { + public void onComplete(final Throwable failure, final Object cohortResponse) { + if (failure != null) { operationCallbackRef.get().failure(); returnFuture.setException(failure); return; @@ -68,28 +72,28 @@ class SingleCommitCohortProxy extends AbstractThreePhaseCommitCohort { // immediate success, to complete the 3PC for the front-end. returnFuture.set(Boolean.TRUE); } - }, actorContext.getClientDispatcher()); + }, actorUtils.getClientDispatcher()); return returnFuture; } @Override - public ListenableFuture preCommit() { + public ListenableFuture preCommit() { return delegateCohort.preCommit(); } @Override - public ListenableFuture abort() { + public ListenableFuture abort() { return delegateCohort.abort(); } @Override - public ListenableFuture commit() { + public ListenableFuture commit() { return delegateCohort.commit(); } @Override List> getCohortFutures() { - return Arrays.asList(cohortFuture); + return List.of(cohortFuture); } }