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%2FCohortEntry.java;h=6c0c13b3abfd6dec5ca89b1014f095e4e87c468a;hb=2611e6a728e586ea34dd891f30a473bf54d6cbd8;hp=a66a49685fa2f1552b269a9c71b65e058cfab571;hpb=5fd8e6506248cc34da72281a1662612f6c2b2f9a;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/CohortEntry.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/CohortEntry.java index a66a49685f..6c0c13b3ab 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/CohortEntry.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/CohortEntry.java @@ -7,10 +7,15 @@ */ package org.opendaylight.controller.cluster.datastore; +import static com.google.common.base.Preconditions.checkState; +import static java.util.Objects.requireNonNull; + import akka.actor.ActorRef; -import com.google.common.base.Preconditions; import com.google.common.primitives.UnsignedLong; import com.google.common.util.concurrent.FutureCallback; +import java.util.List; +import java.util.Optional; +import java.util.SortedSet; import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier; import org.opendaylight.controller.cluster.datastore.ShardCommitCoordinator.CohortDecorator; import org.opendaylight.controller.cluster.datastore.modification.Modification; @@ -24,19 +29,21 @@ final class CohortEntry { private RuntimeException lastBatchedModificationsException; private int totalBatchedModificationsReceived; + private int totalOperationsProcessed; private ShardDataTreeCohort cohort; private boolean doImmediateCommit; private ActorRef replySender; private Shard shard; private CohortEntry(final ReadWriteShardDataTreeTransaction transaction, final short clientVersion) { - this.transaction = Preconditions.checkNotNull(transaction); + this.cohort = null; + this.transaction = requireNonNull(transaction); this.transactionId = transaction.getIdentifier(); this.clientVersion = clientVersion; } private CohortEntry(final ShardDataTreeCohort cohort, final short clientVersion) { - this.cohort = Preconditions.checkNotNull(cohort); + this.cohort = requireNonNull(cohort); this.transactionId = cohort.getIdentifier(); this.transaction = null; this.clientVersion = clientVersion; @@ -74,14 +81,19 @@ final class CohortEntry { return totalBatchedModificationsReceived; } + int getTotalOperationsProcessed() { + return totalOperationsProcessed; + } + RuntimeException getLastBatchedModificationsException() { return lastBatchedModificationsException; } @SuppressWarnings("checkstyle:IllegalCatch") - void applyModifications(final Iterable modifications) { + void applyModifications(final List modifications) { totalBatchedModificationsReceived++; if (lastBatchedModificationsException == null) { + totalOperationsProcessed += modifications.size(); for (Modification modification : modifications) { try { modification.apply(transaction.getSnapshot()); @@ -109,10 +121,10 @@ final class CohortEntry { cohort.abort(callback); } - void ready(final CohortDecorator cohortDecorator) { - Preconditions.checkState(cohort == null, "cohort was already set"); + void ready(final Optional> participatingShardNames, final CohortDecorator cohortDecorator) { + checkState(cohort == null, "cohort was already set"); - cohort = transaction.ready(); + cohort = transaction.ready(participatingShardNames); if (cohortDecorator != null) { // Call the hook for unit tests. @@ -120,6 +132,14 @@ final class CohortEntry { } } + boolean isSealed() { + return cohort != null; + } + + Optional> getParticipatingShardNames() { + return cohort != null ? cohort.getParticipatingShardNames() : Optional.empty(); + } + boolean isDoImmediateCommit() { return doImmediateCommit; }