Improve LocalProxyTransaction.doExists()
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / LeaderFrontendState.java
index ea2ef2f8b8225a50554133f1ce19ba5a86647909..e086e51a66f706d103168bbe36db50841e3c68eb 100644 (file)
@@ -14,6 +14,7 @@ import com.google.common.base.MoreObjects.ToStringHelper;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
 import org.opendaylight.controller.cluster.access.commands.CreateLocalHistoryRequest;
 import org.opendaylight.controller.cluster.access.commands.DeadHistoryException;
@@ -31,7 +32,7 @@ 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.ShardDataTreeCohort.State;
-import org.opendaylight.controller.cluster.datastore.utils.UnsignedLongSet;
+import org.opendaylight.controller.cluster.datastore.utils.MutableUnsignedLongSet;
 import org.opendaylight.yangtools.concepts.Identifiable;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -65,8 +66,8 @@ abstract class LeaderFrontendState implements Identifiable<ClientIdentifier> {
         // Histories which have not been purged
         private final Map<LocalHistoryIdentifier, LocalFrontendHistory> localHistories;
 
-        // RangeSet performs automatic merging, hence we keep minimal state tracking information
-        private final UnsignedLongSet purgedHistories;
+        // UnsignedLongSet performs automatic merging, hence we keep minimal state tracking information
+        private final MutableUnsignedLongSet purgedHistories;
 
         // Used for all standalone transactions
         private final AbstractFrontendHistory standaloneHistory;
@@ -75,12 +76,12 @@ abstract class LeaderFrontendState implements Identifiable<ClientIdentifier> {
         private Long lastSeenHistory = null;
 
         Enabled(final String persistenceId, final ClientIdentifier clientId, final ShardDataTree tree) {
-            this(persistenceId, clientId, tree, UnsignedLongSet.of(),
+            this(persistenceId, clientId, tree, MutableUnsignedLongSet.of(),
                 StandaloneFrontendHistory.create(persistenceId, clientId, tree), new HashMap<>());
         }
 
         Enabled(final String persistenceId, final ClientIdentifier clientId, final ShardDataTree tree,
-                final UnsignedLongSet purgedHistories, final AbstractFrontendHistory standaloneHistory,
+                final MutableUnsignedLongSet purgedHistories, final AbstractFrontendHistory standaloneHistory,
                 final Map<LocalHistoryIdentifier, LocalFrontendHistory> localHistories) {
             super(persistenceId, clientId, tree);
             this.purgedHistories = requireNonNull(purgedHistories);
@@ -99,7 +100,7 @@ abstract class LeaderFrontendState implements Identifiable<ClientIdentifier> {
                 } else if (request instanceof DestroyLocalHistoryRequest) {
                     return handleDestroyHistory((DestroyLocalHistoryRequest) request, envelope, now);
                 } else if (request instanceof PurgeLocalHistoryRequest) {
-                    return handlePurgeHistory((PurgeLocalHistoryRequest)request, envelope, now);
+                    return handlePurgeHistory((PurgeLocalHistoryRequest) request, envelope, now);
                 } else {
                     LOG.warn("{}: rejecting unsupported request {}", persistenceId(), request);
                     throw new UnsupportedRequestException(request);
@@ -236,9 +237,9 @@ abstract class LeaderFrontendState implements Identifiable<ClientIdentifier> {
 
     private static final Logger LOG = LoggerFactory.getLogger(LeaderFrontendState.class);
 
-    private final ShardDataTree tree;
-    private final ClientIdentifier clientId;
-    private final String persistenceId;
+    private final @NonNull ClientIdentifier clientId;
+    private final @NonNull String persistenceId;
+    private final @NonNull ShardDataTree tree;
 
     private long lastConnectTicks;
     private long lastSeenTicks;