[CONTROLLER-761] Tree traversal to find a parent does not return data. Created: 03/Sep/14  Updated: 09/Feb/15  Resolved: 09/Feb/15

Status: Resolved
Project: controller
Component/s: mdsal
Affects Version/s: Helium
Fix Version/s: None

Type: Bug
Reporter: Ramkumar Gowrishankar Assignee: Tony Tkacik
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: All
Platform: All


Issue Links:
Duplicate
duplicates YANGTOOLS-270 Class loader weirdness in invocation Resolved
External issue ID: 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.



 Comments   
Comment by Robert Varga [ 04/Sep/14 ]

Read/put/merge/delete on wildcarded instance identifiers is not defined, so https://git.opendaylight.org/gerrit/10767 adds preconditions to catch them early on.

The root cause still needs to be investigated, though.

Comment by Tony Tkacik [ 09/Sep/14 ]

Could you please provide information, on which build you experienced this error?
Also "ls -la" of plugins folder of controller will be helpful.

Comment by George Zhao [ 19/Jan/15 ]

move to Lithium

Comment by Tony Tkacik [ 09/Feb/15 ]

Fixed in stable and master. As it turned out MD-SAL did return also instance identifiers without keys, which should not be used for reads.

Generated at Wed Feb 07 19:53:48 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.