[MDSAL-45] InstanceIdentifier does not properly capture choice-case child relationship Created: 28/Aug/14  Updated: 22/Jun/18  Resolved: 22/Jun/18

Status: Resolved
Project: mdsal
Component/s: Binding API, Binding codegen
Affects Version/s: None
Fix Version/s: Fluorine

Type: Improvement
Reporter: Dana Kutenicsova Assignee: Robert Varga
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: Linux
Platform: PC


Issue Links:
Blocks
blocks MDSAL-342 DataObjectModification not able find ... Resolved
Relates
relates to MDSAL-310 Instance Identifier is unable to repr... Resolved

 Description   

yang model:

augment "<path>tables/routes" {
case linkstate-routes-case {
container linkstate-routes {
list linkstate-route {
...
}

Works fine with InstanceIdentifier constructed like this:

iid = InstanceIdentifier.create(..).child(Tables.class, new TablesKey(..))
.child(LinkstateRoutes.class).child(LinkstateRoute.class, new LinkstateRouteKey(this.linkNlri));

But when the container is moved to grouping:

grouping linkstate-routes {
container linkstate-routes {
list linkstate-route

{ .... }

}

augment "<path>tables/routes" {
case linkstate-routes-case {
uses linkstate-routes;
}

The instance identifier gives following compilation error:

Bound mismatch: The generic method child(Class<N>) of type InstanceIdentifier<T> is not applicable for the arguments (Class<LinkstateRoutes>). The inferred type LinkstateRoutes is not a valid substitute for the bounded parameter <N extends ChildOf<? super Tables>>



 Comments   
Comment by Robert Varga [ 23/May/18 ]

I think the solution to this conundrum lies with MDSAL-310's approach to fixing the problem. Essentially we can have two modes of addressing:

  • direct child when unambiguous, crossing tables->linkstate-routes, as is the case when the container is outside of the grouping
  • Intermediate addressing, which includes the item for the choice/case – requiring the user to specify the Case node (which would implement ChildOf<Tables>)

This is slightly confusing, though, as suddenly it looks like you should be able to read the case node directly from the data store... Which you probably don't want Unfortunately we do not generate proper grouping instantiations, hence we are not getting a class for 'container linkstate-routes' as instantiated by uses in case – that class would have ChildOf<Tables>.

Comment by Robert Varga [ 23/May/18 ]

Thinking about it a bit more, we really need a new marker interfaces:

  • ChoiceIn<T>, which will mimic ChildOf<T> except being a DataObject

Then we need a new InstanceIdentifierBuilder method, which will have a prototype like:

<C extends ChoiceIn<? super T>, N extends ChildOf<? super C> InstanceIdentifierBuilder<N> caseChild(Class<C> caze, Class<N> child);

Hence access to a case's children (which is the problem here) is solved. This does not solve the problem addressing choices or their cases themselves.

Comment by Robert Varga [ 23/May/18 ]

To fix that problem, one of the two needs to budge:

  1. interfaces generated for choices would have to become a DataObject
  2. InstanceIdentifier<T extends DataObject> needs to be lowered to InstanceIdentifier<T extends DataContainer>

The first is not really an option, as DataObject guarantees implementation, whereas there can be no implementation for a choice. That leaves us with 2) as the only option.

That should work, as DataContainers are not subject of ChildOf, hence if you jump to a choice in InstanceIdentifierBuilder, you are stuck and cannot move down. This is fine for read/write, as you can move towards a particular case instantiation (which is a dataobject) via checking 'instanceof'.

The problem here, though, is DataTreeChangeListeners and MDSAL-342: it will suddenly become possible to subscribe to choices and we need to figure out whether that is something we want to allow – we can support it via overwrites, but the conversation around how you navigate downwards from there is ... dicey.

Comment by Robert Varga [ 23/May/18 ]

Hence let's focus this issue on solving addressing case/grouping children. MDSAL-342 then will deal with provide a similar API to arrive to modifications of ambiguous children. MDSAL-310 will then focus on addressability of choices and cases.

Generated at Wed Feb 07 20:08:30 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.