Cleanup warnings
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / StandaloneFrontendHistory.java
index 1f2eb72560aef600a2deb9520600f8f845600fd3..7fd53c7b7cb66f72805e6b3939a57a36be78a4c3 100644 (file)
@@ -8,6 +8,12 @@
 package org.opendaylight.controller.cluster.datastore;
 
 import com.google.common.base.Preconditions;
+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 org.opendaylight.controller.cluster.access.concepts.ClientIdentifier;
 import org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifier;
 import org.opendaylight.controller.cluster.access.concepts.RequestException;
@@ -24,26 +30,52 @@ final class StandaloneFrontendHistory extends AbstractFrontendHistory {
     private final LocalHistoryIdentifier identifier;
     private final ShardDataTree tree;
 
-    StandaloneFrontendHistory(final String persistenceId, final ClientIdentifier clientId, final ShardDataTree tree) {
-        super(persistenceId);
+    private StandaloneFrontendHistory(final String persistenceId, final ClientIdentifier clientId,
+            final ShardDataTree tree, final Map<UnsignedLong, Boolean> closedTransactions,
+            final RangeSet<UnsignedLong> purgedTransactions) {
+        super(persistenceId, tree, closedTransactions, purgedTransactions);
         this.identifier = new LocalHistoryIdentifier(clientId, 0);
         this.tree = Preconditions.checkNotNull(tree);
     }
 
+    static StandaloneFrontendHistory create(final String persistenceId, final ClientIdentifier clientId,
+            final ShardDataTree tree) {
+        return new StandaloneFrontendHistory(persistenceId, clientId, tree, ImmutableMap.of(),
+            TreeRangeSet.create());
+    }
+
+    static StandaloneFrontendHistory recreate(final String persistenceId, final ClientIdentifier clientId,
+            final ShardDataTree tree, final Map<UnsignedLong, Boolean> closedTransactions,
+            final RangeSet<UnsignedLong> purgedTransactions) {
+        return new StandaloneFrontendHistory(persistenceId, clientId, tree, new HashMap<>(closedTransactions),
+            purgedTransactions);
+    }
+
     @Override
     public LocalHistoryIdentifier getIdentifier() {
         return identifier;
     }
 
+    @Override
+    FrontendTransaction createOpenSnapshot(final TransactionIdentifier id) throws RequestException {
+        return FrontendReadOnlyTransaction.create(this, tree.newReadOnlyTransaction(id));
+    }
+
     @Override
     FrontendTransaction createOpenTransaction(final TransactionIdentifier id) throws RequestException {
-        return FrontendTransaction.createOpen(this, tree.newReadWriteTransaction(id));
+        return FrontendReadWriteTransaction.createOpen(this, tree.newReadWriteTransaction(id));
     }
 
     @Override
     FrontendTransaction createReadyTransaction(final TransactionIdentifier id, final DataTreeModification mod)
             throws RequestException {
-        return FrontendTransaction.createReady(this, id, mod);
+        return FrontendReadWriteTransaction.createReady(this, id, mod);
+    }
+
+    @Override
+    ShardDataTreeCohort createFailedCohort(final TransactionIdentifier id, final DataTreeModification mod,
+            final Exception failure) {
+        return tree.createFailedCohort(id, mod, failure);
     }
 
     @Override