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%2FSimpleShardDataTreeCohort.java;h=f42af0b88e5847c3201520cfbca632b4b2da4dcd;hb=546cd1fd100dbaa36908b22c2f422320dbd8c4b2;hp=3104cb4972de5973f270ceb32593fd809bb58088;hpb=f81bccec7ac422dbcfdfba70dcfa22f9824b8e4c;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/SimpleShardDataTreeCohort.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/SimpleShardDataTreeCohort.java index 3104cb4972..f42af0b88e 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/SimpleShardDataTreeCohort.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/SimpleShardDataTreeCohort.java @@ -7,13 +7,17 @@ */ package org.opendaylight.controller.cluster.datastore; +import static java.util.Objects.requireNonNull; + import com.google.common.base.MoreObjects.ToStringHelper; import com.google.common.base.Preconditions; import com.google.common.base.Verify; import com.google.common.primitives.UnsignedLong; import com.google.common.util.concurrent.FutureCallback; import java.util.Optional; +import java.util.SortedSet; import java.util.concurrent.CompletionStage; +import org.eclipse.jdt.annotation.Nullable; import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate; import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateTip; @@ -28,6 +32,7 @@ final class SimpleShardDataTreeCohort extends ShardDataTreeCohort { private final ShardDataTree dataTree; private final TransactionIdentifier transactionId; private final CompositeDataTreeCohort userCohorts; + private final @Nullable SortedSet participatingShardNames; private State state = State.READY; private DataTreeCandidateTip candidate; @@ -35,20 +40,23 @@ final class SimpleShardDataTreeCohort extends ShardDataTreeCohort { private Exception nextFailure; SimpleShardDataTreeCohort(final ShardDataTree dataTree, final DataTreeModification transaction, - final TransactionIdentifier transactionId, final CompositeDataTreeCohort userCohorts) { - this.dataTree = Preconditions.checkNotNull(dataTree); - this.transaction = Preconditions.checkNotNull(transaction); - this.transactionId = Preconditions.checkNotNull(transactionId); - this.userCohorts = Preconditions.checkNotNull(userCohorts); + final TransactionIdentifier transactionId, final CompositeDataTreeCohort userCohorts, + final Optional> participatingShardNames) { + this.dataTree = requireNonNull(dataTree); + this.transaction = requireNonNull(transaction); + this.transactionId = requireNonNull(transactionId); + this.userCohorts = requireNonNull(userCohorts); + this.participatingShardNames = requireNonNull(participatingShardNames).orElse(null); } SimpleShardDataTreeCohort(final ShardDataTree dataTree, final DataTreeModification transaction, final TransactionIdentifier transactionId, final Exception nextFailure) { - this.dataTree = Preconditions.checkNotNull(dataTree); - this.transaction = Preconditions.checkNotNull(transaction); - this.transactionId = Preconditions.checkNotNull(transactionId); + this.dataTree = requireNonNull(dataTree); + this.transaction = requireNonNull(transaction); + this.transactionId = requireNonNull(transactionId); this.userCohorts = null; - this.nextFailure = Preconditions.checkNotNull(nextFailure); + this.participatingShardNames = null; + this.nextFailure = requireNonNull(nextFailure); } @Override @@ -66,8 +74,14 @@ final class SimpleShardDataTreeCohort extends ShardDataTreeCohort { return transaction; } + @Override + Optional> getParticipatingShardNames() { + return Optional.ofNullable(participatingShardNames); + } + private void checkState(final State expected) { - Preconditions.checkState(state == expected, "State %s does not match expected state %s", state, expected); + Preconditions.checkState(state == expected, "State %s does not match expected state %s for %s", + state, expected, getIdentifier()); } @Override @@ -77,7 +91,7 @@ final class SimpleShardDataTreeCohort extends ShardDataTreeCohort { } checkState(State.READY); - this.callback = Preconditions.checkNotNull(newCallback); + this.callback = requireNonNull(newCallback); state = State.CAN_COMMIT_PENDING; if (nextFailure == null) { @@ -90,7 +104,7 @@ final class SimpleShardDataTreeCohort extends ShardDataTreeCohort { @Override public void preCommit(final FutureCallback newCallback) { checkState(State.CAN_COMMIT_COMPLETE); - this.callback = Preconditions.checkNotNull(newCallback); + this.callback = requireNonNull(newCallback); state = State.PRE_COMMIT_PENDING; if (nextFailure == null) { @@ -128,7 +142,7 @@ final class SimpleShardDataTreeCohort extends ShardDataTreeCohort { @Override public void commit(final FutureCallback newCallback) { checkState(State.PRE_COMMIT_COMPLETE); - this.callback = Preconditions.checkNotNull(newCallback); + this.callback = requireNonNull(newCallback); state = State.COMMIT_PENDING; if (nextFailure == null) { @@ -257,7 +271,7 @@ final class SimpleShardDataTreeCohort extends ShardDataTreeCohort { void reportFailure(final Exception cause) { if (nextFailure == null) { - this.nextFailure = Preconditions.checkNotNull(cause); + this.nextFailure = requireNonNull(cause); } else { LOG.debug("Transaction {} already has a set failure, not updating it", transactionId, cause); }