Overview
Ideally one anchor could support more then one data tree instance using different independent models provided in the schema-set for that anchor. Refer - CPS-341Getting issue details... STATUS
The Problem statement
The YANG specification allows multiple containers (lists etc) to be defined on a module's top level, however in CPS currently the eligible JSON data (having corresponding data sets) is not accepted. When data is parsed using YangUtils.parseJsonData(...) the exception like below occurs
org.opendaylight.yangtools.yang.data.impl.schema.ResultAlreadySetException: Normalized Node result was already set. at org.opendaylight.yangtools.yang.data.impl.schema.NormalizedNodeResult.setResult(NormalizedNodeResult.java:39) at org.opendaylight.yangtools.yang.data.impl.schema.NormalizedNodeResultBuilder.addChild(NormalizedNodeResultBuilder.java:57) at org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNormalizedNodeStreamWriter.writeChild(ImmutableNormalizedNodeStreamWriter.java:305) at org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNormalizedNodeStreamWriter.endNode(ImmutableNormalizedNodeStreamWriter.java:283) at org.opendaylight.yangtools.yang.data.util.ContainerNodeDataWithSchema.write(ContainerNodeDataWithSchema.java:37) at org.opendaylight.yangtools.yang.data.util.CompositeNodeDataWithSchema.write(CompositeNodeDataWithSchema.java:273) at org.opendaylight.yangtools.yang.data.util.AbstractNodeDataWithSchema.write(AbstractNodeDataWithSchema.java:74) at org.opendaylight.yangtools.yang.data.codec.gson.JsonParserStream.parse(JsonParserStream.java:170) at org.onap.cps.utils.YangUtils.parseJsonData(YangUtils.java:73) ...
Goal of this spike
The current limitation of only one data tree(single top level data node) being supported by CPS does not seems to be justifiable. The goal of this study is to find out what is the cause of the above error and bring in support for JSON data with multiple top level nodes.
Problem Statement | Possible Solutions | Sub-Tasks | Notes/Comments | Pros/Cons |
---|---|---|---|---|
Identify the top-level data nodes in the existing JSON payload and then iterate over them and store them individually one by one in using Create node endpoint |
|
| Pros:
Cons:
| |
Use JSON array and store the JSON array in CPS DB using Create node endpoint |
Sample: [{...},{...},{...}]
|
| Pros:
Cons:
|
Findings for the above mentioned Possible Solutions
Possible Solutions | Payload | Description/Findings | Comments |
---|---|---|---|
Identify the top-level keys in the existing JSON payload (which is JSON object) and then iterate over them and store them individually one by one in using Create node endpoint | The JSON object with multiple data trees would be structured as follows: { "container-1": { values }, //data tree 1 "container-2": { values } //data tree 2 } Refer the following files for Yang and Json data (from spike CPS-341): |
| |
Use new payload in form of JSON array and store the JSON array in CPS DB using Create node endpoint | The JSON object with multiple data trees would be structured as follows: [ { //data tree 1 "container-1": { values } }, { //data tree 2 "container-2": { values } } ] Refer the following files for Yang and Json data (from spike CPS-341): |
|