Reimplement UnsignedLongRangeSet
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / StandaloneFrontendHistory.java
index 7fd53c7b7cb66f72805e6b3939a57a36be78a4c3..be85f689eb1d3b6b0b89dacbeb96342534be90f3 100644 (file)
@@ -7,17 +7,19 @@
  */
 package org.opendaylight.controller.cluster.datastore;
 
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.collect.ImmutableMap;
-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 java.util.Optional;
+import java.util.SortedSet;
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.controller.cluster.access.concepts.ClientIdentifier;
 import org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifier;
-import org.opendaylight.controller.cluster.access.concepts.RequestException;
 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
+import org.opendaylight.controller.cluster.datastore.utils.UnsignedLongSet;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
 
 /**
@@ -32,23 +34,22 @@ final class StandaloneFrontendHistory extends AbstractFrontendHistory {
 
     private StandaloneFrontendHistory(final String persistenceId, final ClientIdentifier clientId,
             final ShardDataTree tree, final Map<UnsignedLong, Boolean> closedTransactions,
-            final RangeSet<UnsignedLong> purgedTransactions) {
+            final UnsignedLongSet purgedTransactions) {
         super(persistenceId, tree, closedTransactions, purgedTransactions);
-        this.identifier = new LocalHistoryIdentifier(clientId, 0);
-        this.tree = Preconditions.checkNotNull(tree);
+        identifier = new LocalHistoryIdentifier(clientId, 0);
+        this.tree = requireNonNull(tree);
     }
 
-    static StandaloneFrontendHistory create(final String persistenceId, final ClientIdentifier clientId,
+    static @NonNull StandaloneFrontendHistory create(final String persistenceId, final ClientIdentifier clientId,
             final ShardDataTree tree) {
-        return new StandaloneFrontendHistory(persistenceId, clientId, tree, ImmutableMap.of(),
-            TreeRangeSet.create());
+        return new StandaloneFrontendHistory(persistenceId, clientId, tree, ImmutableMap.of(), UnsignedLongSet.of());
     }
 
-    static StandaloneFrontendHistory recreate(final String persistenceId, final ClientIdentifier clientId,
+    static @NonNull StandaloneFrontendHistory recreate(final String persistenceId, final ClientIdentifier clientId,
             final ShardDataTree tree, final Map<UnsignedLong, Boolean> closedTransactions,
-            final RangeSet<UnsignedLong> purgedTransactions) {
+            final UnsignedLongSet purgedTransactions) {
         return new StandaloneFrontendHistory(persistenceId, clientId, tree, new HashMap<>(closedTransactions),
-            purgedTransactions);
+            purgedTransactions.copy());
     }
 
     @Override
@@ -57,18 +58,17 @@ final class StandaloneFrontendHistory extends AbstractFrontendHistory {
     }
 
     @Override
-    FrontendTransaction createOpenSnapshot(final TransactionIdentifier id) throws RequestException {
+    FrontendTransaction createOpenSnapshot(final TransactionIdentifier id) {
         return FrontendReadOnlyTransaction.create(this, tree.newReadOnlyTransaction(id));
     }
 
     @Override
-    FrontendTransaction createOpenTransaction(final TransactionIdentifier id) throws RequestException {
+    FrontendTransaction createOpenTransaction(final TransactionIdentifier id) {
         return FrontendReadWriteTransaction.createOpen(this, tree.newReadWriteTransaction(id));
     }
 
     @Override
-    FrontendTransaction createReadyTransaction(final TransactionIdentifier id, final DataTreeModification mod)
-            throws RequestException {
+    FrontendTransaction createReadyTransaction(final TransactionIdentifier id, final DataTreeModification mod) {
         return FrontendReadWriteTransaction.createReady(this, id, mod);
     }
 
@@ -79,7 +79,8 @@ final class StandaloneFrontendHistory extends AbstractFrontendHistory {
     }
 
     @Override
-    ShardDataTreeCohort createReadyCohort(final TransactionIdentifier id, final DataTreeModification mod) {
-        return tree.createReadyCohort(id, mod);
+    ShardDataTreeCohort createReadyCohort(final TransactionIdentifier id, final DataTreeModification mod,
+            final Optional<SortedSet<String>> participatingShardNames) {
+        return tree.createReadyCohort(id, mod, participatingShardNames);
     }
 }