Details
-
Bug
-
Status: Resolved
-
Resolution: Duplicate
-
Helium
-
None
-
None
-
Operating System: All
Platform: All
-
1690
Description
I have the following tree in the configuration tree:
Nodes
Node – SampleNodeAugmentation
NodeConnector – SampleNodeConnectorAugmentation
There can be multiple instances of Node under Nodes and multiple instances of NodeConnector under Node. There can be only one instance of SampleNodeAugmentation and SampleNodeConnectorAugmentation for a given instance of Node or NodeConnector.
I have registered for datachangenotification on the SampleNodeConnectorAugmentation. When I get the instance of SampleNodeConnectorAugmentation in onDataChanged, I need to traverse the tree up and get some data from the SampleNodeAugmentation object.
I tried the following in onDataChanged:
Map<InstanceIdentifier<?>, DataObject> created = change.getCreatedData();
for (Map.Entry<InstanceIdentifier<?>, DataObject> entry : created.entrySet())
{
InstanceIdentifier<?> ii = entry.getKey();
InstanceIdentifier<NodeConnector> ncii = ii.firstIdentifierOf(NodeConnector.class);
InstanceIdentifier<Node> nii = ncii.firstIdentifierOf(Node.class);
System.out.println("**** Instance Identifier of the node connector is : " + ncii.toString());
System.out.println("**** Instance Identifier of the node is : " + nii.toString());
ReadOnlyTransaction readTx = dataService.newReadOnlyTransaction();
try {
ncdata = readTx.read(LogicalDatastoreType.CONFIGURATION, nii).get();
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
}
However, the ReadOnlyTransaction does not return a Node object. It looks like the ReadOnlyTransaction needs the Key of the object along with the path to return the object and the firstIdentiferOf does not return a keyed identifier.
Using an instance identifier without a key works only for root objects like the Nodes class or the NetworkTopology class that can have only one instance in the MD-SAL.
There should be a way to traverse up the tree from a given object in the tree.
Attachments
Issue Links
- duplicates
-
YANGTOOLS-270 Class loader weirdness in invocation
- Resolved