X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-dom-broker%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fmd%2Fsal%2Fdom%2Fstore%2Fimpl%2Ftree%2Fdata%2FInMemoryDataTreeModification.java;h=39ff4f0aa03f9b0ad1d3ccdce080b4cf7c7989a2;hp=c05ed4b442d0fa964fa94d88fb9526a5c88673c6;hb=2c4a9be1a89caa93f4f2697401771dcb0fa67c5a;hpb=f2b0b8646e5e8060dbb1a8278ddaf0f4b2a422c0 diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/InMemoryDataTreeModification.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/InMemoryDataTreeModification.java index c05ed4b442..39ff4f0aa0 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/InMemoryDataTreeModification.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/InMemoryDataTreeModification.java @@ -12,6 +12,7 @@ import java.util.Map.Entry; import javax.annotation.concurrent.GuardedBy; import org.opendaylight.controller.md.sal.dom.store.impl.tree.DataTreeModification; +import org.opendaylight.controller.md.sal.dom.store.impl.tree.ModificationType; import org.opendaylight.controller.md.sal.dom.store.impl.tree.TreeNodeUtils; import org.opendaylight.controller.md.sal.dom.store.impl.tree.spi.TreeNode; import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; @@ -131,7 +132,7 @@ final class InMemoryDataTreeModification implements DataTreeModification { } @Override - public synchronized void seal() { + public synchronized void ready() { Preconditions.checkState(!sealed, "Attempted to seal an already-sealed Data Tree."); sealed = true; rootNode.seal(); @@ -151,7 +152,27 @@ final class InMemoryDataTreeModification implements DataTreeModification { public synchronized DataTreeModification newModification() { Preconditions.checkState(sealed, "Attempted to chain on an unsealed modification"); - // FIXME: transaction chaining - throw new UnsupportedOperationException("Implement this as part of transaction chaining"); + if(rootNode.getType() == ModificationType.UNMODIFIED) { + return snapshot.newModification(); + } + + /* + * FIXME: Add advanced transaction chaining for modification of not rebased + * modification. + * + * Current computation of tempRoot may yeld incorrect subtree versions + * if there are multiple concurrent transactions, which may break + * versioning preconditions for modification of previously occured write, + * directly nested under parent node, since node version is derived from + * subtree version. + * + * For deeper nodes subtree version is derived from their respective metadata + * nodes, so this incorrect root subtree version is not affecting us. + */ + TreeNode originalSnapshotRoot = snapshot.getRootNode(); + Optional tempRoot = strategyTree.apply(rootNode, Optional.of(originalSnapshotRoot), originalSnapshotRoot.getSubtreeVersion().next()); + + InMemoryDataTreeSnapshot tempTree = new InMemoryDataTreeSnapshot(snapshot.getSchemaContext(), tempRoot.get(), strategyTree); + return tempTree.newModification(); } }