Bump yangtools to 3.0.0
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / AbstractShardDataTreeTransaction.java
index 56e11c124984c6042f269cced30b06322d9e9475..9412d47b510bfe82063c295a90f1c2e5f1d52f2d 100644 (file)
@@ -9,23 +9,18 @@ package org.opendaylight.controller.cluster.datastore;
 
 import com.google.common.base.MoreObjects;
 import com.google.common.base.Preconditions;
-import javax.annotation.concurrent.NotThreadSafe;
 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
+import org.opendaylight.controller.cluster.datastore.persisted.AbortTransactionPayload;
 import org.opendaylight.yangtools.concepts.Identifiable;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 /**
- * Abstract base for transactions running on SharrdDataTree.
+ * Abstract base for transactions running on SharrdDataTree. This class is NOT thread-safe.
  *
  * @param <T> Backing transaction type.
  */
-@NotThreadSafe
 abstract class AbstractShardDataTreeTransaction<T extends DataTreeSnapshot>
         implements Identifiable<TransactionIdentifier> {
-    private static final Logger LOG = LoggerFactory.getLogger(AbstractShardDataTreeTransaction.class);
-
     private final ShardDataTreeTransactionParent parent;
     private final TransactionIdentifier id;
     private final T snapshot;
@@ -75,11 +70,18 @@ abstract class AbstractShardDataTreeTransaction<T extends DataTreeSnapshot>
         parent.abortTransaction(this, callback);
     }
 
-    final void purge(final Runnable callback) {
-        if (!closed) {
-            LOG.warn("Purging unclosed transaction {}", id);
+    /**
+     * This method is exposed for sake of {@link ShardTransaction}, which is an actor. We need to ensure that
+     * the parent is updated to reflect the transaction has been closed, but no journal actions may be invoked.
+     *
+     * <p>
+     * ShardTransaction is responsible for additionally sending a request to persist an {@link AbortTransactionPayload}
+     * via a message to the Shard actor.
+     */
+    final void abortFromTransactionActor() {
+        if (close()) {
+            parent.abortFromTransactionActor(this);
         }
-        parent.purgeTransaction(id, callback);
     }
 
     @Override