From: Robert Varga Date: Mon, 10 Nov 2014 15:16:57 +0000 (+0100) Subject: Bug 2062 - StreamWriter APIs loses information about leaf-set ordering X-Git-Tag: release/beryllium~31 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=8976f4ccffeba131a6f0fe1f44c7a088ef1132c8 Bug 2062 - StreamWriter APIs loses information about leaf-set ordering * modified clustering NormalizedNodeStreamWriter implementation to use OrderedLeafSet Change-Id: I663f6b6d894b8366b7a54a3c56be05f20fef43c2 Signed-off-by: Jan Hajnar Signed-off-by: Robert Varga --- diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/AbstractNormalizedNodeDataOutput.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/AbstractNormalizedNodeDataOutput.java index f8ea298458..4a76119822 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/AbstractNormalizedNodeDataOutput.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/AbstractNormalizedNodeDataOutput.java @@ -162,6 +162,14 @@ abstract class AbstractNormalizedNodeDataOutput implements NormalizedNodeDataOut startNode(name.getNodeType(), NodeTypes.LEAF_SET); } + @Override + public void startOrderedLeafSet(final YangInstanceIdentifier.NodeIdentifier name, final int childSizeHint) throws IOException, IllegalArgumentException { + Preconditions.checkNotNull(name, "Node identifier should not be null"); + LOG.debug("Starting a new ordered leaf set"); + + startNode(name.getNodeType(), NodeTypes.ORDERED_LEAF_SET); + } + @Override public void leafSetEntryNode(final Object value) throws IOException, IllegalArgumentException { LOG.debug("Writing a new leaf set entry node"); diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/NodeTypes.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/NodeTypes.java index 6b71fac485..dc034cc7ae 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/NodeTypes.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/NodeTypes.java @@ -22,7 +22,8 @@ final class NodeTypes { public static final byte AUGMENTATION_NODE = 11; public static final byte ANY_XML_NODE = 12; public static final byte END_NODE = 13; - public static final byte YANG_MODELED_ANY_XML_NODE = 14; + public static final byte ORDERED_LEAF_SET = 14; + public static final byte YANG_MODELED_ANY_XML_NODE = 15; private NodeTypes() { throw new UnsupportedOperationException("utility class"); diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/NormalizedNodeInputStreamReader.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/NormalizedNodeInputStreamReader.java index e1cb4b4c53..7753242fca 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/NormalizedNodeInputStreamReader.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/NormalizedNodeInputStreamReader.java @@ -221,6 +221,13 @@ public class NormalizedNodeInputStreamReader implements NormalizedNodeDataInput, return addLeafSetChildren(identifier.getNodeType(), Builders.leafSetBuilder().withNodeIdentifier(identifier)).build(); + case NodeTypes.ORDERED_LEAF_SET: + LOG.debug("Read leaf set node"); + ListNodeBuilder> orderedLeafSetBuilder = + Builders.orderedLeafSetBuilder().withNodeIdentifier(identifier); + orderedLeafSetBuilder = addLeafSetChildren(identifier.getNodeType(), orderedLeafSetBuilder); + return orderedLeafSetBuilder.build(); + default : return null; } diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/transformer/NormalizedNodePruner.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/transformer/NormalizedNodePruner.java index d6f09973f5..88c4763233 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/transformer/NormalizedNodePruner.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/transformer/NormalizedNodePruner.java @@ -74,6 +74,14 @@ public class NormalizedNodePruner implements NormalizedNodeStreamWriter { addBuilder(Builders.leafSetBuilder().withNodeIdentifier(nodeIdentifier), nodeIdentifier); } + @Override + public void startOrderedLeafSet(YangInstanceIdentifier.NodeIdentifier nodeIdentifier, int i) throws IOException, IllegalArgumentException { + + checkNotSealed(); + + addBuilder(Builders.orderedLeafSetBuilder().withNodeIdentifier(nodeIdentifier), nodeIdentifier); + } + @Override public void leafSetEntryNode(Object o) throws IOException, IllegalArgumentException {