Bug 2062 - StreamWriter APIs loses information about leaf-set ordering 76/12676/12
authorRobert Varga <rovarga@cisco.com>
Mon, 10 Nov 2014 15:16:57 +0000 (16:16 +0100)
committerGerrit Code Review <gerrit@opendaylight.org>
Tue, 12 Jan 2016 13:44:40 +0000 (13:44 +0000)
* modified clustering NormalizedNodeStreamWriter implementation to use
OrderedLeafSet

Change-Id: I663f6b6d894b8366b7a54a3c56be05f20fef43c2
Signed-off-by: Jan Hajnar <jhajnar@cisco.com>
Signed-off-by: Robert Varga <rovarga@cisco.com>
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/AbstractNormalizedNodeDataOutput.java
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/NodeTypes.java
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/NormalizedNodeInputStreamReader.java
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/transformer/NormalizedNodePruner.java

index f8ea298..4a76119 100644 (file)
@@ -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");
index 6b71fac..dc034cc 100644 (file)
@@ -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");
index e1cb4b4..7753242 100644 (file)
@@ -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<Object, LeafSetEntryNode<Object>> orderedLeafSetBuilder =
+                        Builders.orderedLeafSetBuilder().withNodeIdentifier(identifier);
+                orderedLeafSetBuilder = addLeafSetChildren(identifier.getNodeType(), orderedLeafSetBuilder);
+                return orderedLeafSetBuilder.build();
+
             default :
                 return null;
         }
index d6f0997..88c4763 100644 (file)
@@ -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 {