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.
@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;
parent.abortTransaction(this, callback);
}
+ /**
+ * 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);
+ }
+ }
+
@Override
public final String toString() {
return MoreObjects.toStringHelper(this).add("id", id).add("closed", closed).add("snapshot", snapshot)