BUG-7033: Fix commit exception due to pipe-lining
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / LocalFrontendHistory.java
index a03b54fbef584bbb715edea0e68de5bfa25dc7b4..cd0cc30a09738e49915939cd967a0dc04df472c4 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.controller.cluster.datastore;
 
 import com.google.common.base.Preconditions;
+import com.google.common.base.Ticker;
 import org.opendaylight.controller.cluster.access.commands.DeadTransactionException;
 import org.opendaylight.controller.cluster.access.commands.LocalHistorySuccess;
 import org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifier;
@@ -36,8 +37,8 @@ final class LocalFrontendHistory extends AbstractFrontendHistory {
     private Long lastSeenTransaction;
     private State state = State.OPEN;
 
-    LocalFrontendHistory(final String persistenceId, final ShardDataTreeTransactionChain chain) {
-        super(persistenceId);
+    LocalFrontendHistory(final String persistenceId, final Ticker ticker, final ShardDataTreeTransactionChain chain) {
+        super(persistenceId, ticker);
         this.chain = Preconditions.checkNotNull(chain);
     }
 
@@ -46,11 +47,18 @@ final class LocalFrontendHistory extends AbstractFrontendHistory {
         return chain.getIdentifier();
     }
 
+    @Override
+    FrontendTransaction createOpenSnapshot(final TransactionIdentifier id) throws RequestException {
+        checkDeadTransaction(id);
+        lastSeenTransaction = id.getTransactionId();
+        return FrontendReadOnlyTransaction.create(this, chain.newReadOnlyTransaction(id));
+    }
+
     @Override
     FrontendTransaction createOpenTransaction(final TransactionIdentifier id) throws RequestException {
         checkDeadTransaction(id);
         lastSeenTransaction = id.getTransactionId();
-        return FrontendTransaction.createOpen(this, chain.newReadWriteTransaction(id));
+        return FrontendReadWriteTransaction.createOpen(this, chain.newReadWriteTransaction(id));
     }
 
     @Override
@@ -58,7 +66,7 @@ final class LocalFrontendHistory extends AbstractFrontendHistory {
             throws RequestException {
         checkDeadTransaction(id);
         lastSeenTransaction = id.getTransactionId();
-        return FrontendTransaction.createReady(this, id, mod);
+        return FrontendReadWriteTransaction.createReady(this, id, mod);
     }
 
     @Override
@@ -66,7 +74,7 @@ final class LocalFrontendHistory extends AbstractFrontendHistory {
         return chain.createReadyCohort(id, mod);
     }
 
-    LocalHistorySuccess destroy(final long sequence) throws RequestException {
+    LocalHistorySuccess destroy(final long sequence, final long now) throws RequestException {
         if (state != State.CLOSED) {
             LOG.debug("{}: closing history {}", persistenceId(), getIdentifier());