X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?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;hb=00c362a353f1a7e6145f4c50811fa8b7a6c871d2;hp=d3e4bf07144e0e99ebe3be6e8e322c5fb9cf4b1d;hpb=5083ffe044b253021c91bc90b61f9af7d24f226c;p=controller.git 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 d3e4bf0714..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,7 +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.StoreUtils; +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; @@ -109,7 +109,7 @@ final class InMemoryDataTreeModification implements DataTreeModification { try { return resolveModificationStrategy(path).apply(modification, modification.getOriginal(), - StoreUtils.increase(snapshot.getRootNode().getSubtreeVersion())); + snapshot.getRootNode().getSubtreeVersion().next()); } catch (Exception e) { LOG.error("Could not create snapshot for {}:{}", path,modification,e); throw e; @@ -132,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(); @@ -152,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(); } }