Uploaded image for project: 'controller'
  1. controller
  2. CONTROLLER-761

Tree traversal to find a parent does not return data.

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • Resolution: Duplicate
    • Helium
    • None
    • mdsal
    • 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

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              tony.tkacik@gmail.com Tony Tkacik
              ramkumar.gowrishankar@gmail.com Ramkumar Gowrishankar
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: