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%2Fdatabroker%2Factors%2Fdds%2FAbstractProxyTransaction.java;h=546738fb670ec9592f7086ac4ea84c3b8f8310c1;hb=4db06286a59f00d8cda6c952d5704e89dac9268c;hp=51f528150d22a717034cc4281618591645cca92f;hpb=7991491f2854dde2ec625ed6c08b44df7d258795;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/AbstractProxyTransaction.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/AbstractProxyTransaction.java index 51f528150d..546738fb67 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/AbstractProxyTransaction.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/AbstractProxyTransaction.java @@ -9,16 +9,16 @@ package org.opendaylight.controller.cluster.databroker.actors.dds; import akka.actor.ActorRef; import com.google.common.base.MoreObjects; -import com.google.common.base.Optional; import com.google.common.base.Preconditions; import com.google.common.base.Verify; import com.google.common.collect.Iterables; -import com.google.common.util.concurrent.CheckedFuture; +import com.google.common.util.concurrent.FluentFuture; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.SettableFuture; import java.util.ArrayDeque; import java.util.Deque; import java.util.Iterator; +import java.util.Optional; import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; @@ -45,7 +45,6 @@ import org.opendaylight.controller.cluster.access.concepts.Request; import org.opendaylight.controller.cluster.access.concepts.RequestFailure; import org.opendaylight.controller.cluster.access.concepts.Response; import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier; -import org.opendaylight.mdsal.common.api.ReadFailedException; import org.opendaylight.yangtools.concepts.Identifiable; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; @@ -305,12 +304,12 @@ abstract class AbstractProxyTransaction implements Identifiable exists(final YangInstanceIdentifier path) { + final FluentFuture exists(final YangInstanceIdentifier path) { checkNotSealed(); return doExists(path); } - final CheckedFuture>, ReadFailedException> read(final YangInstanceIdentifier path) { + final FluentFuture>> read(final YangInstanceIdentifier path) { checkNotSealed(); return doRead(path); } @@ -335,7 +334,7 @@ abstract class AbstractProxyTransaction implements Identifiable optState = flushState(); + final Optional optState = flushState(); if (optState.isPresent()) { forwardToSuccessor(successor, optState.get(), null); } @@ -359,15 +358,19 @@ abstract class AbstractProxyTransaction implements Identifiable enqueuedTicks) { - parent.onTransactionSealed(this); + return sealState(); + } + private boolean sealState() { + parent.onTransactionSealed(this); // Transition internal state to sealed and detect presence of a successor return STATE_UPDATER.compareAndSet(this, OPEN, SEALED); } @@ -413,7 +419,7 @@ abstract class AbstractProxyTransaction implements Identifiable req) { + final void recordSuccessfulRequest(@Nonnull final TransactionRequest req) { successfulRequests.add(Verify.verifyNotNull(req)); } @@ -449,7 +455,7 @@ abstract class AbstractProxyTransaction implements Identifiable) t).getCause().unwrap()); } else { - ret.voteNo(new IllegalStateException("Unhandled response " + t.getClass())); + ret.voteNo(unhandledResponseException(t)); } // This is a terminal request, hence we do not need to record it @@ -507,7 +513,7 @@ abstract class AbstractProxyTransaction implements Identifiable) t).getCause().unwrap()); } else { - ret.voteNo(new IllegalStateException("Unhandled response " + t.getClass())); + ret.voteNo(unhandledResponseException(t)); } recordSuccessfulRequest(req); @@ -569,7 +575,7 @@ abstract class AbstractProxyTransaction implements Identifiable) t).getCause().unwrap()); } else { - ret.voteNo(new IllegalStateException("Unhandled response " + t.getClass())); + ret.voteNo(unhandledResponseException(t)); } onPreCommitComplete(req); @@ -602,7 +608,7 @@ abstract class AbstractProxyTransaction implements Identifiable) t).getCause().unwrap()); } else { - ret.voteNo(new IllegalStateException("Unhandled response " + t.getClass())); + ret.voteNo(unhandledResponseException(t)); } LOG.debug("Transaction {} doCommit completed", this); @@ -687,13 +693,13 @@ abstract class AbstractProxyTransaction implements Identifiable) obj, resp -> { }, now); + successor.doReplayRequest((TransactionRequest) obj, resp -> { /*NOOP*/ }, now); } else { Verify.verify(obj instanceof IncrementSequence); final IncrementSequence increment = (IncrementSequence) obj; successor.doReplayRequest(new IncrementTransactionSequenceRequest(getIdentifier(), - increment.getSequence(), localActor(), isSnapshotOnly(), increment.getDelta()), resp -> { }, - now); + increment.getSequence(), localActor(), isSnapshotOnly(), + increment.getDelta()), resp -> { /*NOOP*/ }, now); LOG.debug("Incrementing sequence {} to successor {}", obj, successor); } } @@ -723,7 +729,7 @@ abstract class AbstractProxyTransaction implements Identifiable optState = flushState(); + final Optional optState = flushState(); if (optState.isPresent()) { successor.handleReplayedRemoteRequest(optState.get(), null, enqueuedTicks); } @@ -797,12 +803,12 @@ abstract class AbstractProxyTransaction implements Identifiable data); - abstract CheckedFuture doExists(YangInstanceIdentifier path); + abstract FluentFuture doExists(YangInstanceIdentifier path); - abstract CheckedFuture>, ReadFailedException> doRead(YangInstanceIdentifier path); + abstract FluentFuture>> doRead(YangInstanceIdentifier path); @GuardedBy("this") - abstract java.util.Optional flushState(); + abstract Optional flushState(); abstract TransactionRequest abortRequest(); @@ -846,6 +852,10 @@ abstract class AbstractProxyTransaction implements Identifiable request, @Nullable Consumer> callback, long enqueuedTicks); + private static IllegalStateException unhandledResponseException(Response resp) { + return new IllegalStateException("Unhandled response " + resp.getClass()); + } + @Override public final String toString() { return MoreObjects.toStringHelper(this).add("identifier", getIdentifier()).add("state", state).toString();