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=d19cf96d390ffcdba8b1f64a6dd3f3749ecc5872;hp=3d5238ee77812eed4190017d7d7a1289887875dd;hpb=731e7284cf0895fdb1b89427f91762e80e67c2ff;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 3d5238ee77..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,13 @@ */ 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; @@ -26,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; @@ -76,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()); @@ -112,7 +122,7 @@ final class CohortEntry { } void ready(final Optional> participatingShardNames, final CohortDecorator cohortDecorator) { - Preconditions.checkState(cohort == null, "cohort was already set"); + checkState(cohort == null, "cohort was already set"); cohort = transaction.ready(participatingShardNames); @@ -122,6 +132,10 @@ final class CohortEntry { } } + boolean isSealed() { + return cohort != null; + } + Optional> getParticipatingShardNames() { return cohort != null ? cohort.getParticipatingShardNames() : Optional.empty(); }