Delay snapshot backed transaction ready error
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / LocalTransactionChain.java
index 56466f78408fe24602564f9c62e14a8f5e31add5..10ea3c63fca12d670e0a14f23d4cb1347547f061 100644 (file)
@@ -9,7 +9,9 @@ package org.opendaylight.controller.cluster.datastore;
 
 import akka.actor.ActorSelection;
 import com.google.common.base.Preconditions;
-import org.opendaylight.controller.cluster.datastore.identifiers.TransactionIdentifier;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
 import org.opendaylight.controller.sal.core.spi.data.AbstractSnapshotBackedTransactionChain;
 import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction;
 import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
@@ -57,8 +59,11 @@ final class LocalTransactionChain extends AbstractSnapshotBackedTransactionChain
     }
 
     @Override
-    protected DOMStoreThreePhaseCommitCohort createCohort(final SnapshotBackedWriteTransaction<TransactionIdentifier> transaction, final DataTreeModification modification) {
-        return new LocalChainThreePhaseCommitCohort(transaction, modification);
+    protected DOMStoreThreePhaseCommitCohort createCohort(
+            final SnapshotBackedWriteTransaction<TransactionIdentifier> transaction,
+            final DataTreeModification modification,
+            final Exception operationError) {
+        return new LocalChainThreePhaseCommitCohort(transaction, modification, operationError);
     }
 
     @Override
@@ -76,9 +81,16 @@ final class LocalTransactionChain extends AbstractSnapshotBackedTransactionChain
         return super.newWriteOnlyTransaction(identifier);
     }
 
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings({"unchecked", "checkstyle:IllegalCatch"})
     @Override
-    public LocalThreePhaseCommitCohort onTransactionReady(DOMStoreWriteTransaction tx) {
+    public LocalThreePhaseCommitCohort onTransactionReady(@Nonnull DOMStoreWriteTransaction tx,
+            @Nullable Exception operationError) {
+        Preconditions.checkArgument(tx instanceof SnapshotBackedWriteTransaction);
+        if (operationError != null) {
+            return new LocalChainThreePhaseCommitCohort((SnapshotBackedWriteTransaction<TransactionIdentifier>)tx,
+                    operationError);
+        }
+
         try {
             return (LocalThreePhaseCommitCohort) tx.ready();
         } catch (Exception e) {
@@ -91,8 +103,8 @@ final class LocalTransactionChain extends AbstractSnapshotBackedTransactionChain
     private class LocalChainThreePhaseCommitCohort extends LocalThreePhaseCommitCohort {
 
         protected LocalChainThreePhaseCommitCohort(SnapshotBackedWriteTransaction<TransactionIdentifier> transaction,
-                DataTreeModification modification) {
-            super(parent.getActorContext(), leader, transaction, modification);
+                DataTreeModification modification, Exception operationError) {
+            super(parent.getActorContext(), leader, transaction, modification, operationError);
         }
 
         protected LocalChainThreePhaseCommitCohort(SnapshotBackedWriteTransaction<TransactionIdentifier> transaction,