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%2FNormalizedNodeContainerModificationStrategy.java;h=1d10ab6ea5a971dfc3e4a160949fd6f5c17fd30b;hp=3a3af5ecab966049196c576df7f6c7bd24b560a2;hb=3b301f14027755f8924714c25d888132080f6b54;hpb=c6ab5fdef3d0cc6fac96cb960839168ed7906b3a diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/NormalizedNodeContainerModificationStrategy.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/NormalizedNodeContainerModificationStrategy.java index 3a3af5ecab..1d10ab6ea5 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/NormalizedNodeContainerModificationStrategy.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/NormalizedNodeContainerModificationStrategy.java @@ -11,9 +11,8 @@ import static com.google.common.base.Preconditions.checkArgument; import java.util.Map; -import org.opendaylight.controller.md.sal.dom.store.impl.tree.DataPreconditionFailedException; +import org.opendaylight.controller.md.sal.dom.store.impl.tree.DataValidationFailedException; import org.opendaylight.controller.md.sal.dom.store.impl.tree.ModificationType; -import org.opendaylight.controller.md.sal.dom.store.impl.tree.StoreUtils; import org.opendaylight.controller.md.sal.dom.store.impl.tree.data.DataNodeContainerModificationStrategy.ListEntryModificationStrategy; import org.opendaylight.controller.md.sal.dom.store.impl.tree.data.ValueNodeModificationStrategy.LeafSetEntryModificationStrategy; import org.opendaylight.controller.md.sal.dom.store.impl.tree.spi.MutableTreeNode; @@ -68,7 +67,7 @@ abstract class NormalizedNodeContainerModificationStrategy extends SchemaAwareAp @Override protected void checkWriteApplicable(final InstanceIdentifier path, final NodeModification modification, - final Optional current) throws DataPreconditionFailedException { + final Optional current) throws DataValidationFailedException { // FIXME: Implement proper write check for replacement of node container // prerequisite is to have transaction chain available for clients // otherwise this will break chained writes to same node. @@ -95,16 +94,9 @@ abstract class NormalizedNodeContainerModificationStrategy extends SchemaAwareAp @Override protected TreeNode applyWrite(final ModifiedNode modification, - final Optional currentMeta, final Version subtreeVersion) { - final Version nodeVersion; - if (currentMeta.isPresent()) { - nodeVersion = currentMeta.get().getVersion().next(); - } else { - nodeVersion = subtreeVersion; - } - + final Optional currentMeta, final Version version) { final NormalizedNode newValue = modification.getWrittenValue(); - final TreeNode newValueMeta = TreeNodeFactory.createTreeNode(newValue, nodeVersion); + final TreeNode newValueMeta = TreeNodeFactory.createTreeNode(newValue, version); if (Iterables.isEmpty(modification.getChildren())) { return newValueMeta; @@ -122,12 +114,12 @@ abstract class NormalizedNodeContainerModificationStrategy extends SchemaAwareAp * and run the common parts on it -- which end with the node being sealed. */ final MutableTreeNode mutable = newValueMeta.mutable(); - mutable.setSubtreeVersion(subtreeVersion); + mutable.setSubtreeVersion(version); @SuppressWarnings("rawtypes") final NormalizedNodeContainerBuilder dataBuilder = createBuilder(newValue); - return mutateChildren(mutable, dataBuilder, nodeVersion, modification.getChildren()); + return mutateChildren(mutable, dataBuilder, version, modification.getChildren()); } @SuppressWarnings({ "rawtypes", "unchecked" }) @@ -155,47 +147,44 @@ abstract class NormalizedNodeContainerModificationStrategy extends SchemaAwareAp @Override protected TreeNode applyMerge(final ModifiedNode modification, final TreeNode currentMeta, - final Version subtreeVersion) { + final Version version) { // For Node Containers - merge is same as subtree change - we only replace children. - return applySubtreeChange(modification, currentMeta, subtreeVersion); + return applySubtreeChange(modification, currentMeta, version); } @Override public TreeNode applySubtreeChange(final ModifiedNode modification, - final TreeNode currentMeta, final Version subtreeVersion) { - // Bump subtree version to its new target - final Version updatedSubtreeVersion = currentMeta.getSubtreeVersion().next(); - + final TreeNode currentMeta, final Version version) { final MutableTreeNode newMeta = currentMeta.mutable(); - newMeta.setSubtreeVersion(updatedSubtreeVersion); + newMeta.setSubtreeVersion(version); @SuppressWarnings("rawtypes") NormalizedNodeContainerBuilder dataBuilder = createBuilder(currentMeta.getData()); - return mutateChildren(newMeta, dataBuilder, updatedSubtreeVersion, modification.getChildren()); + return mutateChildren(newMeta, dataBuilder, version, modification.getChildren()); } @Override protected void checkSubtreeModificationApplicable(final InstanceIdentifier path, final NodeModification modification, - final Optional current) throws DataPreconditionFailedException { - checkDataPrecondition(path, current.isPresent(), "Node was deleted by other transaction."); + final Optional current) throws DataValidationFailedException { + checkConflicting(path, current.isPresent(), "Node was deleted by other transaction."); checkChildPreconditions(path, modification, current); } - private void checkChildPreconditions(final InstanceIdentifier path, final NodeModification modification, final Optional current) throws DataPreconditionFailedException { + private void checkChildPreconditions(final InstanceIdentifier path, final NodeModification modification, final Optional current) throws DataValidationFailedException { final TreeNode currentMeta = current.get(); for (NodeModification childMod : modification.getChildren()) { final PathArgument childId = childMod.getIdentifier(); final Optional childMeta = currentMeta.getChild(childId); - InstanceIdentifier childPath = StoreUtils.append(path, childId); + InstanceIdentifier childPath = path.node(childId); resolveChildOperation(childId).checkApplicable(childPath, childMod, childMeta); } } @Override protected void checkMergeApplicable(final InstanceIdentifier path, final NodeModification modification, - final Optional current) throws DataPreconditionFailedException { + final Optional current) throws DataValidationFailedException { if(current.isPresent()) { checkChildPreconditions(path, modification,current); }