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%2FNodeModification.java;fp=opendaylight%2Fmd-sal%2Fsal-dom-broker%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fmd%2Fsal%2Fdom%2Fstore%2Fimpl%2Ftree%2FNodeModification.java;h=a0c15eb4a0590f2fe56f7008456a36ddc2dbba03;hp=764afcb3e185f3d48d09b192660c3cc882c36537;hb=43d7c8702fc7a89ca5acdeefb4696c91b2963b38;hpb=822e5c6c51346ef6ca8254b5597b95742a05fc7d diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/NodeModification.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/NodeModification.java index 764afcb3e1..a0c15eb4a0 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/NodeModification.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/NodeModification.java @@ -17,6 +17,8 @@ import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import com.google.common.base.Optional; +import com.google.common.base.Predicate; +import com.google.common.primitives.UnsignedLong; /** * Node Modification Node and Tree @@ -30,6 +32,12 @@ import com.google.common.base.Optional; */ public class NodeModification implements StoreTreeNode, Identifiable { + public static final Predicate IS_TERMINAL_PREDICATE = new Predicate() { + @Override + public boolean apply(final NodeModification input) { + return input.getModificationType() == ModificationType.WRITE || input.getModificationType() == ModificationType.DELETE; + } + }; private final PathArgument identifier; private ModificationType modificationType = ModificationType.UNMODIFIED; @@ -38,7 +46,8 @@ public class NodeModification implements StoreTreeNode, Identi private NormalizedNode value; - private StoreMetadataNode snapshotCache; + private UnsignedLong subtreeVersion; + private Optional snapshotCache; private final Map childModification; @@ -109,6 +118,7 @@ public class NodeModification implements StoreTreeNode, Identi */ public synchronized NodeModification modifyChild(final PathArgument child) { checkSealed(); + clearSnapshot(); if(modificationType == ModificationType.UNMODIFIED) { updateModificationType(ModificationType.SUBTREE_MODIFIED); } @@ -143,6 +153,7 @@ public class NodeModification implements StoreTreeNode, Identi */ public synchronized void delete() { checkSealed(); + clearSnapshot(); updateModificationType(ModificationType.DELETE); childModification.clear(); this.value = null; @@ -156,6 +167,7 @@ public class NodeModification implements StoreTreeNode, Identi */ public synchronized void write(final NormalizedNode value) { checkSealed(); + clearSnapshot(); updateModificationType(ModificationType.WRITE); childModification.clear(); this.value = value; @@ -167,6 +179,7 @@ public class NodeModification implements StoreTreeNode, Identi public synchronized void seal() { sealed = true; + clearSnapshot(); for(NodeModification child : childModification.values()) { child.seal(); } @@ -176,6 +189,15 @@ public class NodeModification implements StoreTreeNode, Identi snapshotCache = null; } + public Optional storeSnapshot(final Optional snapshot) { + snapshotCache = snapshot; + return snapshot; + } + + public Optional> getSnapshotCache() { + return Optional.fromNullable(snapshotCache); + } + public boolean hasAdditionalModifications() { return !childModification.isEmpty(); } @@ -188,7 +210,7 @@ public class NodeModification implements StoreTreeNode, Identi @Override public String toString() { return "NodeModification [identifier=" + identifier + ", modificationType=" - + modificationType + ", value=" + value + ", childModification=" + childModification + "]"; + + modificationType + ", childModification=" + childModification + "]"; } public static NodeModification createUnmodified(final StoreMetadataNode metadataTree) {