X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2FAbstractShardDataTreeTransaction.java;h=9412d47b510bfe82063c295a90f1c2e5f1d52f2d;hb=079163ec73e4304ebe9b6f9076f78e22e2d0e3a5;hp=56e11c124984c6042f269cced30b06322d9e9475;hpb=2634ed7138a343f051ff6452ccc7edd3abfc0c3a;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractShardDataTreeTransaction.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractShardDataTreeTransaction.java index 56e11c1249..9412d47b51 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractShardDataTreeTransaction.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractShardDataTreeTransaction.java @@ -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 Backing transaction type. */ -@NotThreadSafe abstract class AbstractShardDataTreeTransaction implements Identifiable { - 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 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. + * + *

+ * 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