Cleanup warnings
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / ShardDataTreeTransactionChain.java
index 9a8e89eb422c4b4f909e6a6c3ea97366d1ab01f2..f2e9af3656abdc6bf66f36f645e736d15b8d2168 100644 (file)
@@ -24,6 +24,7 @@ import org.slf4j.LoggerFactory;
 @NotThreadSafe
 final class ShardDataTreeTransactionChain extends ShardDataTreeTransactionParent
         implements Identifiable<LocalHistoryIdentifier> {
+
     private static final Logger LOG = LoggerFactory.getLogger(ShardDataTreeTransactionChain.class);
     private final LocalHistoryIdentifier chainId;
     private final ShardDataTree dataTree;
@@ -42,17 +43,19 @@ final class ShardDataTreeTransactionChain extends ShardDataTreeTransactionParent
         Preconditions.checkState(openTransaction == null, "Transaction %s is open", openTransaction);
 
         if (previousTx == null) {
+            LOG.debug("Opening an unchained snapshot in {}", chainId);
             return dataTree.takeSnapshot();
-        } else {
-            return previousTx.getSnapshot();
         }
+
+        LOG.debug("Reusing a chained snapshot in {}", chainId);
+        return previousTx.getSnapshot();
     }
 
     ReadOnlyShardDataTreeTransaction newReadOnlyTransaction(final TransactionIdentifier txId) {
         final DataTreeSnapshot snapshot = getSnapshot();
         LOG.debug("Allocated read-only transaction {} snapshot {}", txId, snapshot);
 
-        return new ReadOnlyShardDataTreeTransaction(txId, snapshot);
+        return new ReadOnlyShardDataTreeTransaction(this, txId, snapshot);
     }
 
     ReadWriteShardDataTreeTransaction newReadWriteTransaction(final TransactionIdentifier txId) {
@@ -65,20 +68,27 @@ final class ShardDataTreeTransactionChain extends ShardDataTreeTransactionParent
 
     void close() {
         closed = true;
+        LOG.debug("Closing chain {}", chainId);
     }
 
     @Override
-    protected void abortTransaction(final AbstractShardDataTreeTransaction<?> transaction) {
+    void abortFromTransactionActor(final AbstractShardDataTreeTransaction<?> transaction) {
         if (transaction instanceof ReadWriteShardDataTreeTransaction) {
             Preconditions.checkState(openTransaction != null,
                     "Attempted to abort transaction %s while none is outstanding", transaction);
-            LOG.debug("Aborted transaction {}", transaction);
+            LOG.debug("Aborted open transaction {}", transaction);
             openTransaction = null;
         }
     }
 
     @Override
-    protected ShardDataTreeCohort finishTransaction(final ReadWriteShardDataTreeTransaction transaction) {
+    void abortTransaction(final AbstractShardDataTreeTransaction<?> transaction, final Runnable callback) {
+        abortFromTransactionActor(transaction);
+        dataTree.abortTransaction(transaction, callback);
+    }
+
+    @Override
+    ShardDataTreeCohort finishTransaction(final ReadWriteShardDataTreeTransaction transaction) {
         Preconditions.checkState(openTransaction != null,
                 "Attempted to finish transaction %s while none is outstanding", transaction);
 
@@ -109,7 +119,13 @@ final class ShardDataTreeTransactionChain extends ShardDataTreeTransactionParent
     }
 
     @Override
-    ShardDataTreeCohort createReadyCohort(final TransactionIdentifier txId, final DataTreeModification modification) {
-        return dataTree.createReadyCohort(txId, modification);
+    ShardDataTreeCohort createFailedCohort(final TransactionIdentifier txId, final DataTreeModification mod,
+            final Exception failure) {
+        return dataTree.createFailedCohort(txId, mod, failure);
+    }
+
+    @Override
+    ShardDataTreeCohort createReadyCohort(final TransactionIdentifier txId, final DataTreeModification mod) {
+        return dataTree.createReadyCohort(txId, mod);
     }
 }