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%2FLeaderFrontendState.java;fp=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2FLeaderFrontendState.java;h=ba2bdb3c7bfc87ba0dcc479ec754d7ff8dd7a751;hp=d860bfa289e39f7b9a144aa652a5a030ec4c4546;hb=a7aab5b8d7692d12928944a0d3da818571e324cc;hpb=b5cb353e3553a39f576c284119af75ffa5ea66a9 diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/LeaderFrontendState.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/LeaderFrontendState.java index d860bfa289..ba2bdb3c7b 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/LeaderFrontendState.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/LeaderFrontendState.java @@ -9,10 +9,6 @@ package org.opendaylight.controller.cluster.datastore; import com.google.common.base.MoreObjects; import com.google.common.base.Preconditions; -import com.google.common.collect.Range; -import com.google.common.collect.RangeSet; -import com.google.common.collect.TreeRangeSet; -import com.google.common.primitives.UnsignedLong; import java.util.HashMap; import java.util.Map; import javax.annotation.Nullable; @@ -32,6 +28,7 @@ import org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifie import org.opendaylight.controller.cluster.access.concepts.RequestEnvelope; import org.opendaylight.controller.cluster.access.concepts.RequestException; import org.opendaylight.controller.cluster.access.concepts.UnsupportedRequestException; +import org.opendaylight.controller.cluster.datastore.utils.UnsignedLongRangeSet; import org.opendaylight.yangtools.concepts.Identifiable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -50,7 +47,7 @@ final class LeaderFrontendState implements Identifiable { private final Map localHistories; // RangeSet performs automatic merging, hence we keep minimal state tracking information - private final RangeSet purgedHistories; + private final UnsignedLongRangeSet purgedHistories; // Used for all standalone transactions private final AbstractFrontendHistory standaloneHistory; @@ -71,12 +68,12 @@ final class LeaderFrontendState implements Identifiable { // - per-RequestException throw counters LeaderFrontendState(final String persistenceId, final ClientIdentifier clientId, final ShardDataTree tree) { - this(persistenceId, clientId, tree, TreeRangeSet.create(), StandaloneFrontendHistory.create(persistenceId, - clientId, tree), new HashMap<>()); + this(persistenceId, clientId, tree, UnsignedLongRangeSet.create(), + StandaloneFrontendHistory.create(persistenceId, clientId, tree), new HashMap<>()); } LeaderFrontendState(final String persistenceId, final ClientIdentifier clientId, final ShardDataTree tree, - final RangeSet purgedHistories, final AbstractFrontendHistory standaloneHistory, + final UnsignedLongRangeSet purgedHistories, final AbstractFrontendHistory standaloneHistory, final Map localHistories) { this.persistenceId = Preconditions.checkNotNull(persistenceId); this.clientId = Preconditions.checkNotNull(clientId); @@ -133,9 +130,9 @@ final class LeaderFrontendState implements Identifiable { // We have not found the history. Before we create it we need to check history ID sequencing so that we do not // end up resurrecting a purged history. - if (purgedHistories.contains(UnsignedLong.fromLongBits(historyId.getHistoryId()))) { + if (purgedHistories.contains(historyId.getHistoryId())) { LOG.debug("{}: rejecting purged request {}", persistenceId, request); - throw new DeadHistoryException(purgedHistories); + throw new DeadHistoryException(purgedHistories.toImmutable()); } // Update last history we have seen @@ -179,8 +176,7 @@ final class LeaderFrontendState implements Identifiable { } LOG.debug("{}: purging history {}", persistenceId, id); - final UnsignedLong ul = UnsignedLong.fromLongBits(id.getHistoryId()); - purgedHistories.add(Range.closedOpen(ul, UnsignedLong.ONE.plus(ul))); + purgedHistories.add(id.getHistoryId()); existing.purge(request.getSequence(), envelope, now); return null; } @@ -196,9 +192,9 @@ final class LeaderFrontendState implements Identifiable { if (lhId.getHistoryId() != 0) { history = localHistories.get(lhId); if (history == null) { - if (purgedHistories.contains(UnsignedLong.fromLongBits(lhId.getHistoryId()))) { + if (purgedHistories.contains(lhId.getHistoryId())) { LOG.warn("{}: rejecting request {} to purged history", persistenceId, request); - throw new DeadHistoryException(purgedHistories); + throw new DeadHistoryException(purgedHistories.toImmutable()); } LOG.warn("{}: rejecting unknown history request {}", persistenceId, request);