X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-inmemory-datastore%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fmd%2Fsal%2Fdom%2Fstore%2Fimpl%2FSnapshotBackedWriteTransaction.java;h=60a23403b3ac7fce67b01b85295752cdbb2a2e6e;hb=510f3bd2d25c0e667a60ff5ef18cfbd40534cec0;hp=5f102047684f595a81adc12ddd18866f4fbcd9d7;hpb=28b6378c12b00eb9110e87a15d6a829c33945c66;p=controller.git diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/SnapshotBackedWriteTransaction.java b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/SnapshotBackedWriteTransaction.java index 5f10204768..60a23403b3 100644 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/SnapshotBackedWriteTransaction.java +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/SnapshotBackedWriteTransaction.java @@ -35,8 +35,10 @@ class SnapshotBackedWriteTransaction extends AbstractDOMStoreTransaction impleme private static final AtomicReferenceFieldUpdater TREE_UPDATER = AtomicReferenceFieldUpdater.newUpdater(SnapshotBackedWriteTransaction.class, DataTreeModification.class, "mutableTree"); - private volatile TransactionReadyPrototype readyImpl; // non-null when not ready - private volatile DataTreeModification mutableTree; // non-null when not committed/closed + // non-null when not ready + private volatile TransactionReadyPrototype readyImpl; + // non-null when not committed/closed + private volatile DataTreeModification mutableTree; /** * Creates new write-only transaction. @@ -137,8 +139,11 @@ class SnapshotBackedWriteTransaction extends AbstractDOMStoreTransaction impleme checkState(wasReady != null, "Transaction %s is no longer open", getIdentifier()); LOG.debug("Store transaction: {} : Ready", getIdentifier()); - mutableTree.ready(); - return wasReady.ready(this); + + final DataTreeModification tree = mutableTree; + TREE_UPDATER.lazySet(this, null); + tree.ready(); + return wasReady.transactionReady(this, tree); } @Override @@ -147,6 +152,7 @@ class SnapshotBackedWriteTransaction extends AbstractDOMStoreTransaction impleme if (wasReady != null) { LOG.debug("Store transaction: {} : Closed", getIdentifier()); TREE_UPDATER.lazySet(this, null); + wasReady.transactionAborted(this); } else { LOG.debug("Store transaction: {} : Closed after submit", getIdentifier()); } @@ -157,15 +163,6 @@ class SnapshotBackedWriteTransaction extends AbstractDOMStoreTransaction impleme return toStringHelper.add("ready", readyImpl == null); } - // FIXME: used by chaining on, which really wants an mutated view with a precondition - final boolean isReady() { - return readyImpl == null; - } - - protected DataTreeModification getMutatedView() { - return mutableTree; - } - /** * Prototype implementation of * {@link #ready(org.opendaylight.controller.md.sal.dom.store.impl.SnapshotBackedWriteTransaction)} @@ -175,8 +172,15 @@ class SnapshotBackedWriteTransaction extends AbstractDOMStoreTransaction impleme * providing underlying logic for applying implementation. * */ - // FIXME: needs access to local stuff, so make it an abstract class - public static interface TransactionReadyPrototype { + abstract static class TransactionReadyPrototype { + /** + * Called when a transaction is closed without being readied. This is not invoked for + * transactions which are ready. + * + * @param tx Transaction which got aborted. + */ + protected abstract void transactionAborted(final SnapshotBackedWriteTransaction tx); + /** * Returns a commit coordinator associated with supplied transactions. * @@ -184,8 +188,10 @@ class SnapshotBackedWriteTransaction extends AbstractDOMStoreTransaction impleme * * @param tx * Transaction on which ready was invoked. + * @param tree + * Modified data tree which has been constructed. * @return DOMStoreThreePhaseCommitCohort associated with transaction */ - DOMStoreThreePhaseCommitCohort ready(SnapshotBackedWriteTransaction tx); + protected abstract DOMStoreThreePhaseCommitCohort transactionReady(SnapshotBackedWriteTransaction tx, DataTreeModification tree); } } \ No newline at end of file