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 2e329dd15e07856cdd39b45202d2871ca1e72d87..10ea3c63fca12d670e0a14f23d4cb1347547f061 100644 (file)
@@ -61,8 +61,9 @@ final class LocalTransactionChain extends AbstractSnapshotBackedTransactionChain
     @Override
     protected DOMStoreThreePhaseCommitCohort createCohort(
             final SnapshotBackedWriteTransaction<TransactionIdentifier> transaction,
-            final DataTreeModification modification) {
-        return new LocalChainThreePhaseCommitCohort(transaction, modification);
+            final DataTreeModification modification,
+            final Exception operationError) {
+        return new LocalChainThreePhaseCommitCohort(transaction, modification, operationError);
     }
 
     @Override
@@ -80,11 +81,12 @@ final class LocalTransactionChain extends AbstractSnapshotBackedTransactionChain
         return super.newWriteOnlyTransaction(identifier);
     }
 
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings({"unchecked", "checkstyle:IllegalCatch"})
     @Override
     public LocalThreePhaseCommitCohort onTransactionReady(@Nonnull DOMStoreWriteTransaction tx,
             @Nullable Exception operationError) {
-        if(operationError != null) {
+        Preconditions.checkArgument(tx instanceof SnapshotBackedWriteTransaction);
+        if (operationError != null) {
             return new LocalChainThreePhaseCommitCohort((SnapshotBackedWriteTransaction<TransactionIdentifier>)tx,
                     operationError);
         }
@@ -101,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,