while retrieving list of data from data broker getting null values

asked 2015-08-21 07:22:14 -0800

vinoth gravatar image

updated 2015-08-21 07:24:09 -0800

Yang file:

container sample-data {

    leaf sample-Id {
        type types:uuid;
        mandatory true;
    }

    leaf flowCondName {
        type string;
        mandatory true;
    }

    list sample-Wrapper {
        key "id";
        leaf id {
        type types:uuid;
        mandatory true;
    }
       leaf entityValue {
          type int32;
       }
       leaf entityName {
          type string;
       }
       leaf entityDescription {
          type string;
       }
       leaf action {
          type string;
       }
}

}

I am using this above yang file. I am trying to PUT the element through curl command. data added successfully, but while reading first time i got null list and second time while giving curl command i got the first curl command value.

In the below code i have used for PUT the value into data store

public boolean getData(sample sample, List<samplewrapper> sampleList) { SampleData sampleData try { InstanceIdentifier<sampledata> identifier = InstanceIdentifier.builder(SampleData.class).build(); sampleData = new SampleDataBuilder() .setsampleId(sample.getId()).setFlowCondName("flowcond").setsampleWrapper(sampleList).build(); WriteTransaction tx = dataBroker.newWriteOnlyTransaction(); tx.put(LogicalDatastoreType.CONFIGURATION, identifier, sampleData); tx.submit(); } catch (Exception e) { LOG.error("Add: failed: {}", e); return false; } LOG.info("initRendererConfiguration: default config populated:sampleData {}"); return true; }</sampledata></samplewrapper>

In the below code i have used for READ the value from data store

public List<sampleWrapper> readData() {
    List<sampleWrapper> listOfStoresRead = new ArrayList<sampleWrapper>();
    try {
        InstanceIdentifier<SampleData> identifierList = InstanceIdentifier
            .builder(SampleData.class).build();
        ReadOnlyTransaction tx = dataBroker.newReadOnlyTransaction();

        listOfStoresRead = tx.read(LogicalDatastoreType.CONFIGURATION, identifierList).
                        checkedGet().get().getsampleWrapper();
    } catch (Exception e) {
        LOG.error("List stores: failed: {}", e);
    }
    System.out.println("Read Values" + listOfStoresRead);
    LOG.info("ListstoresValueConfiguration: list of storesValue retrieved successfully : {}", listOfStoresRead);
    return listOfStoresRead;
}

Please validate the above code for writing / reading the list of data into data store which is mentioned above yang file and java implementation.

Please kindly suggest me your inputs.

edit retag flag offensive close merge delete