X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=opendaylight%2Fmd-sal%2Fsal-dom-broker%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fmd%2Fsal%2Fdom%2Fstore%2Fimpl%2Ftree%2FNodeModification.java;h=4f650c171107abdbffd552a11f7e5531a1f1f8b8;hb=refs%2Fchanges%2F38%2F6338%2F3;hp=a0c15eb4a0590f2fe56f7008456a36ddc2dbba03;hpb=43d7c8702fc7a89ca5acdeefb4696c91b2963b38;p=controller.git 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 a0c15eb4a0..4f650c1711 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 @@ -12,13 +12,14 @@ import static com.google.common.base.Preconditions.checkState; import java.util.LinkedHashMap; import java.util.Map; +import javax.annotation.concurrent.GuardedBy; + import org.opendaylight.yangtools.concepts.Identifiable; 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 @@ -35,7 +36,9 @@ public class NodeModification implements StoreTreeNode, Identi 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; + return input.getModificationType() == ModificationType.WRITE // + || input.getModificationType() == ModificationType.DELETE // + || input.getModificationType() == ModificationType.MERGE; } }; private final PathArgument identifier; @@ -46,11 +49,11 @@ public class NodeModification implements StoreTreeNode, Identi private NormalizedNode value; - private UnsignedLong subtreeVersion; private Optional snapshotCache; private final Map childModification; + @GuardedBy("this") private boolean sealed = false; protected NodeModification(final PathArgument identifier, final Optional original) { @@ -173,6 +176,15 @@ public class NodeModification implements StoreTreeNode, Identi this.value = value; } + public synchronized void merge(final NormalizedNode data) { + checkSealed(); + clearSnapshot(); + updateModificationType(ModificationType.MERGE); + // FIXME: Probably merge with previous value. + this.value = data; + } + + @GuardedBy("this") private void checkSealed() { checkState(!sealed, "Node Modification is sealed. No further changes allowed."); } @@ -202,7 +214,8 @@ public class NodeModification implements StoreTreeNode, Identi return !childModification.isEmpty(); } - public void updateModificationType(final ModificationType type) { + @GuardedBy("this") + private void updateModificationType(final ModificationType type) { modificationType = type; clearSnapshot(); }