yangtools.git
4 years agoMake declared statement inheritance a StatementContextBase property 91/87291/1
Robert Varga [Mon, 27 Jan 2020 20:16:55 +0000 (21:16 +0100)]
Make declared statement inheritance a StatementContextBase property

We have inconsistencies between handling of inference-time and build-time
declared statements. When a declared statement is created in reactor,
its declared view will be materialized at the statement itself, not
in the original context.

This means statements which are subject to (even unused!) inference
will create a disconnected declared view. Statements which are not
infered, will correctly reuse declared instances with their origin.

Fix this by making following of getOriginalCtx() an implementation
given in StatementContextBase, resulting in centralized code and
consistent results.

JIRA: YANGTOOLS-652
Change-Id: Id8afb814821398e416afbfc6c9e3aeeb789f94a8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit af62dc4257be32f92c6e8506fa8dabfe8a9976cd)
(cherry picked from commit d121fc53d32b799c493cbe7da6b9d061fe7b9564)

4 years agoFix AbstractResumedStatement reparent 90/87290/1
Robert Varga [Tue, 28 Jan 2020 17:34:29 +0000 (18:34 +0100)]
Fix AbstractResumedStatement reparent

When we are reparenting AbstractResumedStatement we need to make
sure the state is copied correctly. This shows that it cannot
be semantically copied, hence it does not make sense to track
previous/original context.

JIRA: YANGTOOLS-784
Change-Id: Iea3c8117e26bfaf710fcf48aad3f9202f054c036
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit f2b0ab1fd70ff3ade6c8ce0569d3dcce531d06c3)
(cherry picked from commit da0e0a5cfc3e062f9831303991fd43e4b43ee373)

4 years agoMake asserts buildDeclared() more lenient 89/87289/1
Robert Varga [Tue, 28 Jan 2020 15:54:24 +0000 (16:54 +0100)]
Make asserts buildDeclared() more lenient

Declared instance is guarded by completed phase, hence if it is
filled with a value we have completed specified phase (at some point).

This results in fewer memory accesses in case the declared statement
is accessed again.

JIRA: YANGTOOLS-652
Change-Id: Iac21fb6e74268770d91e4b9eefc120b892fd0753
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit e32df17e048c955ef24ef36871a078fec43a3574)
(cherry picked from commit 5d1a99d3b37029df33992a36bba41984393529e4)

4 years agoOptimize Status statement declarations 88/87288/1
Robert Varga [Mon, 27 Jan 2020 23:40:42 +0000 (00:40 +0100)]
Optimize Status statement declarations

As Status has low cardinality we can quite easily improve things
by sharing common instances.

JIRA: YANGTOOLS-1065
Change-Id: Ie404a65bc4a43b0d51e72f011a2aa7a5980c30df
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit f69f568356663d3583f5b2c06a5ba5c7738562fe)
(cherry picked from commit f3ec202944e53864c67990ff580295073311b5d3)

4 years agoCleanup NamespaceStorageSupport/StmtContext API conflict 87/87287/1
Robert Varga [Mon, 27 Jan 2020 17:58:58 +0000 (18:58 +0100)]
Cleanup NamespaceStorageSupport/StmtContext API conflict

StmtContext has a few methods that are logically implemented by
NamespaceStorageSupport. Since NamespaceStorageSupport does not
implements StmtContext (nor should it), these methods happen to
work as they overlap with StmtContextBase's mixin -- and they
cannot be simply found by looking for implementations.

Resolve the naming conflict in the most logical way, thus improving
quality of life for everyone :)

Change-Id: I0186a94699c5945b7140bf57ba9e5900e49019d4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit a1721ffa2582da72cb3000cad5c3d7df8a8878e4)
(cherry picked from commit 4e21b29d53a6876a83d0c54af6da08c6456f398a)

4 years agoOptimize {Position,Value}StatementSupport 86/87286/1
Robert Varga [Tue, 28 Jan 2020 00:10:47 +0000 (01:10 +0100)]
Optimize {Position,Value}StatementSupport

These statements can be interned and are mostly independent, add
baseline implementations which intern empty statements on JVM level.

JIRA: YANGTOOLS-1065
Change-Id: I1fafda7403d743ffa6c5279bd149c161ad78ed33
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 6c440613986f0bac936da8a29c4077aa051415b7)
(cherry picked from commit 354c4d29acfd0c09f7b0aef61775c78c49066028)

4 years agoAdd AbstractBooleanDeclaredStatement/BaseBooleanStatementSupport 85/87285/1
Robert Varga [Mon, 27 Jan 2020 21:11:17 +0000 (22:11 +0100)]
Add AbstractBooleanDeclaredStatement/BaseBooleanStatementSupport

mandatory/config/require-instance/yin-element statements share the
same shape of being stateless boolean holders. Add an explicit
base class, making sure all common declarations end up referencing
the same 4 objects.

JIRA: YANGTOOLS-1065
Change-Id: I0c423ad1fc34c2a4c55c92d246830880a4c8bf9b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 7e5bb201aa0873de5a08707813cff7a24516d17f)
(cherry picked from commit b91e27fedfa1ca36cfaef2762009fd5acb12dc59)

4 years agoAdd InferredStatementContext 76/87276/2
Robert Varga [Sat, 25 Jan 2020 13:24:53 +0000 (14:24 +0100)]
Add InferredStatementContext

SubstatementContext implies definition in source, which adds state
which is not necessary. Introduce a separate class to hold statement
contexts which are created during inference.

In order to prevent code duplication, StmtContext methods whose
implementation is relevant only in RootStatementContext are refactored
to dispatch to specialized implementations, making them final in
the process. This also happens to improve inference speed, as lookups
like getBehaviourRegistry() used to iterate over parent axis to root,
now they are taking a direct shortcut to root (which may be 'this').

Since InferredStatementContext derives a number of methods from
its prototype (such as raw argument, etc.), these details are taken
out of StatementContextBase and moved to AbstractResumedStatement.

InferredStatementContext is about 10% smaller than an equivalent
SubstatementContext, leading to smaller inference memory footprint.

JIRA: YANGTOOLS-784
Change-Id: I62eea1dc92756536444676e8765fedd73375933e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 3880c99eefb4d8104236fdd17da6d5014f61f63e)
(cherry picked from commit a677c0b472ea2b9eaeeb0dbd32af4ae0f1671ec8)

4 years agoExtract AbstractResumedStatement 75/87275/2
Robert Varga [Sat, 25 Jan 2020 11:43:44 +0000 (12:43 +0100)]
Extract AbstractResumedStatement

Separate out data structures related to statement source traversal
into a dedicated class.

This lowers the footprint required to implement StatementContextBase,
as well as lowering clutter around which functionality is related
to which part.

JIRA: YANGTOOLS-652
Change-Id: I811c6fcf3bfba83421609af13dfed8fe445184b9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit d3425a5bdd83c76d186d59f711d3c41cd24c1fee)
(cherry picked from commit 735f3c1d9c2243eac0976e0db7af9d62a4e88f98)

4 years agoFurther optimize OrderedBy effective statement dispatch 74/87274/1
Robert Varga [Mon, 27 Jan 2020 20:26:14 +0000 (21:26 +0100)]
Further optimize OrderedBy effective statement dispatch

Comparing both argument and declared instance is not necessary.
We are using identity comparison, so just do that.

Change-Id: I6e28b9013ae2d056907b52f87cd2813bbcdd23c9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 40132b0512978eecbeae6133ce357b8beb08a5df)

4 years agoIntroduce AbstractModelStatement 73/87273/1
Robert Varga [Sun, 26 Jan 2020 18:08:32 +0000 (19:08 +0100)]
Introduce AbstractModelStatement

Since we now have abstract classes for both declared and effective
worlds, it is useful tie the implementations together, so that it
both share vtable where ModelStatement methods are concerned.

Also unify substatement list handling between the two implementations,
sharing the utility methods to do so.

JIRA: YANGTOOLS-1065
Change-Id: I52849b2afa6a20478a980ba0992dbcc338941dd9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 713fdd926360af53c70c871f441be23ef0927889)

4 years agoReuse OrderedByEffectiveStatement instances 72/87272/1
Robert Varga [Sun, 26 Jan 2020 19:18:37 +0000 (20:18 +0100)]
Reuse OrderedByEffectiveStatement instances

This is a low-cardinality statement for which we are already reusing
declared instances. This extends that support to cover effective
instances based on the shared declared instances.

Also ditch the use of EnumMap -- while it works, we only have two
values, which is easily taken care of by a switch statement.

JIRA: YANGTOOLS-1065
Change-Id: I43f135c9dec443b1b46b5517fa98f2c08af3d877
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit b235e6290637ae2decf53015012807026bb849db)

4 years agoOptimize simple declared statements 71/87271/1
Robert Varga [Sun, 26 Jan 2020 13:05:42 +0000 (14:05 +0100)]
Optimize simple declared statements

Our declared statements weigh in at 32/56 bytes each, which is
a bit wasteful for what they are doing -- and it all boils down to
class hierarchy.

Introduce AbstractDeclaredStatement, which provides structural
base to implement them with minimal footprint. Initial conversion
includes simple statements, which can be implemented in 16/24 bytes.

OrderedBy statement also takes advantage of low cardinality of its
argument to further eliminate footprint in regular YANG use.

JIRA: YANGTOOLS-1065
Change-Id: I6ea57a7260d3e33108c6c77c1ce120937181796f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit ab3c2696f4b6ebc62529570ba39110876c3a3c98)

4 years agoAdd default effectiveSubstatements() implementation 70/87270/1
Robert Varga [Sun, 26 Jan 2020 17:32:13 +0000 (18:32 +0100)]
Add default effectiveSubstatements() implementation

AbstractEffectiveStatement subclasses can benefit from a common
implementation, reducing code duplication. This organization
mirrors the layout of AbstractDeclaredStatement.

JIRA: YANGTOOLS-1065
Change-Id: I869958ad8a154df0d6f66c91108631ef54aad2b8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit faae563ab28dbfe2fd9763448359cf113d400368)

4 years agoExpand reactor documentation a bit 69/87269/1
Robert Varga [Sat, 25 Jan 2020 11:33:22 +0000 (12:33 +0100)]
Expand reactor documentation a bit

The reactor can use every sliver of documentation it can get, provide
at least a few words.

Change-Id: I2ccfa558f2ba4bfa63505308f6e4131e8634ab4e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 9cb8b0439ed2c70053719685ad86fb0e26714374)

4 years agoOptimize isConfiguration()/isIgnoringConfig() interplay 68/87268/1
Robert Varga [Sat, 25 Jan 2020 10:29:21 +0000 (11:29 +0100)]
Optimize isConfiguration()/isIgnoringConfig() interplay

Now that we have coalesced these two states into a flag field,
their interplay is more apparent -- isIgnoringConfig() is always
checked before isConfiguration() and if it is set, it also implies
isConfiguration() is also set.

Using flags allows us to express this implication by simply setting
the right bits. This results in fewer flag operations performed and
a more direct dispatch between methods.

isConfiguration() is also improved to access parent.isConfiguration()
only when necessary, improving performance when a config substatement
is present.

JIRA: YANGTOOLS-652
Change-Id: Ifb18ee16e33e93de4300cc80e4ba67a9ae40bbde
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 7cb2365fa775c4b3026aa77662d34fddbda30b60)

4 years agoOptimize SubstatementContext size 67/87267/1
Robert Varga [Fri, 24 Jan 2020 14:11:01 +0000 (15:11 +0100)]
Optimize SubstatementContext size

Class layout of SubstatementContext contains a set of flags in
StatementContextBase and SubstatementContext, both of which end up
being padded -- wasting 2-10 bytes in the padding alone.

Moving configuration/ignoreConfig/ignoreIfFeature to
StatementContextBase and allocating them as individual bits allows
us to eliminate internal losses in most cases, resulting in net
savings of 8 bytes per instance in the common case (64bit VM), i.e.
4.5-8.3%.

JIRA: YANGTOOLS-652
Change-Id: Ic63f75e9e8c1c25445bc7904c08a5691d1470b67
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 79244c9c657423d5cf853952e6e00d1f687749ea)

4 years agoDrop StmtContextUtils. qualifier 83/87183/1
Robert Varga [Mon, 27 Jan 2020 19:42:45 +0000 (20:42 +0100)]
Drop StmtContextUtils. qualifier

This is a distraction -- all these methods are local.

Change-Id: I8328ebf18b620141d95b227d885d4dd14282f11d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 351145a6df9944bc97572f5a99759cab9b5ef5ff)

4 years agoUse ImmutableMap for single namespaces 64/87164/3
Robert Varga [Mon, 27 Jan 2020 11:31:15 +0000 (12:31 +0100)]
Use ImmutableMap for single namespaces

It is extremely common for statement contexts to have exactly one
namespace (i.e. ChildSchemaNodeNamespace). Tracking that in a HashMap
is not very memory-efficient (nor performance-efficient), as we will
end up allocating all the HashMap internals.

Separate out the single-namespace case and use an ImmutableMap singleton
to hold the namespace -- which saves ~65MiB in a reference test case
accounding for ~6% of scratch memory used (~3% total used).

JIRA: YANGTOOLS-652
Change-Id: Ie2b1faeb4c966c20be0818d3b54aa7c8367f0c58
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoMigrate StmtContext javadoc 32/87132/1
Robert Varga [Fri, 24 Jan 2020 08:55:40 +0000 (09:55 +0100)]
Migrate StmtContext javadoc

Move documentation blocks from StatementContextBase to method
definitions in StmtContext.

Change-Id: I569ae4a99ef0e90b72dcb341ccbf30cf010e76a5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoMove common code 17/87117/1
Robert Varga [Thu, 23 Jan 2020 16:36:18 +0000 (17:36 +0100)]
Move common code

We have a single line which is duplicated, move it to common code.

Change-Id: I738168386ea0efb7c7bab11e23aa219e076b564b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoAbstractEffectiveModule should retain statement order 89/87089/1
Robert Varga [Wed, 22 Jan 2020 16:14:26 +0000 (17:14 +0100)]
AbstractEffectiveModule should retain statement order

AbstractEffectiveModule is using HashSet for its temporary storage,
which makes statement order dependent on hashCode() rather than
declaration order.

Make sure we use LinkedHashSet, thus not losing the order.

Change-Id: Ie46c28c051f861c1aabc34f7aa5e4293f7d38cea
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoDo not tolerate duplicate identities 82/87082/1
Robert Varga [Wed, 22 Jan 2020 13:25:15 +0000 (14:25 +0100)]
Do not tolerate duplicate identities

We have a unit test asserting identity definition squashing -- which
really is papering over the parser accepting the identities.

As per RFC7950, identity declarations must be unique, and we should
report them through normal SourceException.

JIRA: YANGTOOLS-1075
Change-Id: I98ce8615bcdb502cb79caa23fc9c3a127f850ea9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoBump versions to 3.0.10-SNAPSHOT 76/86976/2
Robert Varga [Thu, 16 Jan 2020 12:52:00 +0000 (13:52 +0100)]
Bump versions to 3.0.10-SNAPSHOT

This starts the next development iteration.

Change-Id: Ia7f60e3cc9b19164aaf9d477e71363b5fea5fa54
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoBump odlparent to 5.0.5 67/86967/1
Robert Varga [Thu, 16 Jan 2020 11:14:54 +0000 (12:14 +0100)]
Bump odlparent to 5.0.5

This adopts odlparent-5.0.5, along with the fix to SFT.

Change-Id: I633249e53068db5f638ef48c90cc0e47abf20fd2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoBump versions to 3.0.9-SNAPSHOT 14/86914/2
Robert Varga [Wed, 15 Jan 2020 07:55:14 +0000 (08:55 +0100)]
Bump versions to 3.0.9-SNAPSHOT

This starts the next development iteration.

Change-Id: I98864e26fc847fa96199f734e5b02bd26fbb3b6a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoCheck if we are operating in a grouping before issuing a warning 98/86898/4
Robert Varga [Tue, 14 Jan 2020 16:30:09 +0000 (17:30 +0100)]
Check if we are operating in a grouping before issuing a warning

If we are examining a list in a grouping, we should not be issuing
a warning, as we do not know where that grouping is going to be
instantiated.

Once we determine that a warning may be appropriate, walk statement
contexts upwards, searching for a grouping -- if we find one, just
bail out without any warning.

JIRA: YANGTOOLS-957
Change-Id: If54b05cc444f19f56c6f8b4f931d85b0b270b4ac
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoDeprecate DataNodeIterator 92/86892/2
Robert Varga [Tue, 14 Jan 2020 14:56:18 +0000 (15:56 +0100)]
Deprecate DataNodeIterator

This class is used in two places only, where each of the places
only needs specific type of nodes. Expose utility methods for
those two cases and a general tranverser method from SchemaNodeUtils
and deprecate DataNodeIterator.

Change-Id: I4fdc47e16fe2ea7e6f042bb80fe869657ee93fac
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit adf41b25c82b005f66a0de86a8e3c8a8a455cf76)

4 years agoOptimize DataNodeIterator.hasNext() 91/86891/2
Robert Varga [Tue, 14 Jan 2020 14:18:42 +0000 (15:18 +0100)]
Optimize DataNodeIterator.hasNext()

This does not quite make sense, but can be optimized to only quickly
look at the collection.

Change-Id: Iabc8414ff712126699f54c02f5aaf9506c4f3f6b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 1adcabecdcab85b6ed657271758560fc5eeb917f)

4 years agoDeprecate AbstractEffectiveContainerSchemaNode 88/86888/1
Robert Varga [Mon, 13 Jan 2020 15:02:40 +0000 (16:02 +0100)]
Deprecate AbstractEffectiveContainerSchemaNode

With ContainerEffectiveStatementImpl refactored, this class does not
have a direct user and can thus be folded into
AbstractEffectiveOperationContainerSchemaNode.

Deprecate it for removal, so that it does not accidentally pick up
any new users.

JIRA: YANGTOOLS-1065
Change-Id: Ie078b2de0161798a7580e125b19955cebeb1d525
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit cf0eac6a6dbfad52a4fdbceecf0ac41646b0d631)

4 years agoRefactor ContainerEffectiveStatementImpl 87/86887/1
Robert Varga [Mon, 13 Jan 2020 12:42:04 +0000 (13:42 +0100)]
Refactor ContainerEffectiveStatementImpl

The story here is very similar to ListEffectiveStatementImpl,
with the additional simplifications that containers are pretty
much same.

Size reduction from this refactor ends up being typical 104 bytes
to 40 bytes typical, eliminating a bunch of static collections
in the process.

JIRA: YANGTOOLS-1065
Change-Id: I1050c4e8f82f60274c78e810fc31896daccba389
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit bbdfd546e8f79773f2162717f607551bb79fcbda)

4 years agoDeprecate AbstractEffectiveMustConstraintAwareSimpleDataNodeContainer 86/86886/1
Robert Varga [Mon, 13 Jan 2020 12:46:44 +0000 (13:46 +0100)]
Deprecate AbstractEffectiveMustConstraintAwareSimpleDataNodeContainer

With ListEffectiveStatementImpl gone, this class does not have a direct
user and can thus be folded into AbstractEffectiveContainerSchemaNode.

Deprecate it for removal, so that it does not accidentally pick up
any new users.

JIRA: YANGTOOLS-1065
Change-Id: I70b4f11941d248f44dbb8fc146bf5564193b368d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 6be4080cc62f637314debf0b4ccd8e7cc8f905f1)

4 years agoRefactor ListEffectiveStatementImpl 85/86885/1
Robert Varga [Sun, 12 Jan 2020 18:12:09 +0000 (19:12 +0100)]
Refactor ListEffectiveStatementImpl

ListEffectiveStatement implementation is immensely big -- it takes
anywhere between 112 and 224 bytes (120 typical), most of which are
really only indices on substatements, which we can construct on demand.

Applying mixin + layout classes here allows us to drop the size of
these statements to 40/48 bytes typical, with 88 bytes worst case.

The effect on retained memory is ~12% memory foot print reduction,
driven by both reduction of number of ImmutableSets and reduced object
size.

JIRA: YANGTOOLS-1065
Change-Id: Iebcf16b500a874dff94bb21b6f9f59bf056fea51
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit fb9318d77d36a605497c3d12a5fc602a0ed2265f)

4 years agoRefactor Leaf(List)EffectiveStatementImpl 84/86884/1
Robert Varga [Wed, 8 Jan 2020 23:22:32 +0000 (00:22 +0100)]
Refactor Leaf(List)EffectiveStatementImpl

Leaf(List)EffectiveStatementImpl costs 88 bytes each instance in common
Linux deployment. This turns out to be unnecessary, as be can easily
drop the size to 32/40 (48 worst) bytes by splitting out well-known
constants. This can represent as much as 10% savings on retained heap.

Since the two statements are sharing mapping towards SchemaNode world,
we introduce EffectiveStatementMixins -- utility bridge interfaces,
which are implementing aspects of DocumentedNode and its subclasses
in terms of EffectiveStatement and some mixed-in state.

JIRA: YANGTOOLS-1065
Change-Id: Icdafc4a196d86d2a493a44523bc81b1024854acb
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 59f98cbf8ef79ecab8ee6d7c5141704142b0f40a)

4 years agoFix statement support generic arguments 83/86883/1
Robert Varga [Mon, 13 Jan 2020 22:32:44 +0000 (23:32 +0100)]
Fix statement support generic arguments

StatementSupport implementations should be specifying exact effective
statement, so that EffectiveStatement is correctly tied into the support.

This leads to less generic arguments, making the code easier to read
and more predictable in results.

Change-Id: I24c611035731124315778f834e1a6d6f6a779e0f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 7bb6ae1269659c12efc127b97cc750ed81ecaac6)

4 years agoCleanup AugmentEffectiveStatementImpl 82/86882/1
Robert Varga [Mon, 13 Jan 2020 21:08:54 +0000 (22:08 +0100)]
Cleanup AugmentEffectiveStatementImpl

NamespaceRevisionAware is derived from a QName, hence we can store
the namespace/revision as a QNameModule, saving us a field.

JIRA: YANGTOOLS-1065
Change-Id: I5026ba79fe28686b6d8d05390db558f2b30845b8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit ee4fe090b11c24a74e15c186bdea074c1d4abd3d)

4 years agoRefactor KeyEffectiveStatementImpl 81/86881/1
Robert Varga [Thu, 9 Jan 2020 17:04:07 +0000 (18:04 +0100)]
Refactor KeyEffectiveStatementImpl

KeyEffectiveStatementImpl costs 32 bytes each instance in common
Linux deployment. This turns out to be unnecessary, as be can easily
drop the size to 16/24 bytes, based on whether the key is referenced
in the same module as it is defined.

The method we do this by is to provide 4 distinct implementations,
based on 2x2 matrix of locality w.r.t declared statement (same module
means we can can reuse declared argument) and number of substatements
-- "key" with a substatement is exceedingly unlikely, hence we can
usually not store substatements.

JIRA: YANGTOOLS-1065
Change-Id: Id1235131a8568236870521cb988e730a233ea96c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 11d4ce226da8231118f5480ef5884b8e079ff437)

4 years agoRefactor simple effective statements 80/86880/1
Robert Varga [Wed, 8 Jan 2020 20:21:16 +0000 (21:21 +0100)]
Refactor simple effective statements

Currently DescriptionEffectiveStatementImpl takes 32 bytes in typical
Linux environment, which is not much, but for well-documented models this
can amount to 8% of the cost of a SchemaContext.

The primary cause is of course is inlining of groupings, but even if that
is fixed we will end up with at least one instance for each description,
so sizing here is important.

We can get rid of this cost by decomposing the implementation by known
DescriptionEffectiveStatement invariants, so that we end up with using
16 (typical) or 24 bytes in the same environment. Worst case size is
reduced to 24 (typical) or 32 bytes (from 48). The overall benefit is
expected to be around 4% SchemaContext size.

Apply the same refactor to reference, contact, belongs-to, ordered-by,
default, error-app-tag, error-message, prefix, presence, reference, units.

JIRA: YANGTOOLS-1065
Change-Id: Ic8da0c38cd89ae10c66ebb70719cf582cb0f627b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 312068b3e5eca1b3c336fa029a5a81c7b6a031c0)

4 years agoGeneralize findFirstEffectiveSubstatement() 52/86852/1
Robert Varga [Fri, 10 Jan 2020 22:43:20 +0000 (23:43 +0100)]
Generalize findFirstEffectiveSubstatement()

There is no point in restricting what instances we can seach for,
make sure we can work with any class.

Change-Id: Ia8834fd5a7550295b861d3494b5a343d760d3e86
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 974385ed778393e2b28c3ef771ced6c3337c543c)

4 years agoUse parallel stream to process YANG text files 51/86851/1
Robert Varga [Tue, 7 Jan 2020 23:21:49 +0000 (00:21 +0100)]
Use parallel stream to process YANG text files

When we are examining local YANG files, we are also performing
first step of parsing to determine what the module/revision is
without relying on the file name. This process can take quite
some time if the models are large and/or there are many of them.

Since each file is independent at this stage, use a parallel
stream (and hence common FJ pool) to perform this task in multiple
threads before moving on to processing.

JIRA: YANGTOOLS-1062
Change-Id: I31cee2aa7f313052565ba723cf4c52566821a625
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit fcb529766049a3ab75cd9a0de4603c0a815c5a0b)

4 years agoFix {Length,Range}Statement retaining ArrayLists 28/86828/1
Robert Varga [Thu, 9 Jan 2020 15:06:16 +0000 (16:06 +0100)]
Fix {Length,Range}Statement retaining ArrayLists

We want the statement argument to be immutable, make sure this
is so, incidentally reducing footprint, too.

Change-Id: I5e3353ad885ab3cc9eef910d2d4bff1db9eabcf0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRelease YangParser from ProcessorModuleReactor 99/86799/1
Robert Varga [Tue, 7 Jan 2020 22:23:12 +0000 (23:23 +0100)]
Release YangParser from ProcessorModuleReactor

Once we have built the SchemaContext, we should not be retaining
the YangParser instance, as it contains a reference to
BuildGlobalContext, which in turn holds all the scratch data
used during SchemaContext assembly.

Throw all of that away as soon as we have a SchemaContext.

JIRA: YANGTOOLS-1061
Change-Id: Idbc4ab91861e3e7581daa3cebceb0fa49823a028
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit de31cd1e591ab1a83ca3fafd20220d3937463b8a)

4 years agoAdd missing test assertions 52/86652/1
Robert Varga [Mon, 30 Dec 2019 21:24:03 +0000 (22:24 +0100)]
Add missing test assertions

While the test has shown the exception no longer occurs, it should
also make assertions. Add that.

JIRA: YANGTOOLS-1060
Change-Id: Id3f864f769c3ac845fe5ed3501fba24502206202
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 1b8b4019c928ff50f63f778d49f6744c7f12923d)

4 years agoSpeed up YT891 test 43/86643/2
Robert Varga [Mon, 30 Dec 2019 14:59:06 +0000 (15:59 +0100)]
Speed up YT891 test

Rather than parsing SchemaContext multiple times, just use @BeforeClass
to initialize it once.

Change-Id: I4c9e5c30a2767bab35133557121e0ff1710e688c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit d76d0664c6090138b90d3e184746d5f9af64b3ea)

4 years agoPropagate 'absolute path' invariant 42/86642/2
Robert Varga [Mon, 30 Dec 2019 11:56:23 +0000 (12:56 +0100)]
Propagate 'absolute path' invariant

Since we are checking whether an expression is absolute or not,
we can hook onto our internal methods, improving performance a bit
and reducing reliance on PathExpressionImpl.

Change-Id: I1e73f9f5ac2652b57517bdfc1631ba49e98396f0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit f3eb0e79d578eca88c4a19841300dfe7288bf314)

4 years agoRemove duplicate checkState() 41/86641/2
Robert Varga [Mon, 30 Dec 2019 11:54:00 +0000 (12:54 +0100)]
Remove duplicate checkState()

The only caller already checks for the path being absolute, there
is no need to check twice.

Change-Id: I24a038ccfe73b47ceaa13e65f3ea3b74c1a3176f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit d3700afdd16b8f486e4d401e07649dc76aa8e1bf)

4 years agoCollapse SchemaContextUtil.typeDefinition() 40/86640/2
Robert Varga [Mon, 30 Dec 2019 11:36:34 +0000 (12:36 +0100)]
Collapse SchemaContextUtil.typeDefinition()

We have TypedDataSchemaNode to hold the leaf/leaf-list trait of
having a type. This allows us to ditch some code duplication.

Change-Id: I959ff6a8f997e557736a081f89df6c16b69e1270
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 12c1e8fdac8294e5636dd82b8b2c39a3d3a8c3f5)

4 years agoDefer path stripping 39/86639/2
Robert Varga [Mon, 30 Dec 2019 11:29:31 +0000 (12:29 +0100)]
Defer path stripping

If we are passed a relative path, we end up first stripping it
and then realizing it's relative. Invert the order, making absolute
proper invariant.

Change-Id: Ic272ac83a9df9d2343b1cd8c5f71debdcdc0faad
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 0236f96b973675555087801c0d786d7f19eee8f1)

4 years agoRemove useless SchemaContextUtil. qualification 38/86638/2
Robert Varga [Mon, 30 Dec 2019 11:27:39 +0000 (12:27 +0100)]
Remove useless SchemaContextUtil. qualification

This trims a few lines, making navigation easier.

Change-Id: I42bef346e774d9bd1173092bdefcd68e400b9a5e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit fb51bb5aaa4caaa862995a61447f91a4fe6bf08c)

4 years agoFix SchemaContextUtils.findDataSchemaNode() namespace handling 37/86637/2
Robert Varga [Sun, 29 Dec 2019 08:11:29 +0000 (09:11 +0100)]
Fix SchemaContextUtils.findDataSchemaNode() namespace handling

If we encounter a qualified identifier in a path define in a submodule
which uses a prefix defined in the submodule only (without a matching
import in the main module), we would end up not being able to resolve
the prefix.

Ever since we integrated YANGTOOLS-969, this is not necessary, as the
parser resolves all qualified identifiers, as per PathExpression API
contract.

Take advantage of this fact, reducing the amount of re-parsing we do
for historic reasons, completely removing the need to resolve prefixes.

JIRA: YANGTOOLS-1060
Change-Id: Id761d103f1070738624cd0ef1865270e4b884be2
Signed-off-by: miroslav.kovac <miroslav.kovac@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 53450187df51937ffd75ff59946abdaec1bbddaf)

4 years agoAdd another alternative SchemaContextUtil.findDataSchemaNode() 36/86636/1
Robert Varga [Mon, 30 Dec 2019 08:11:16 +0000 (09:11 +0100)]
Add another alternative SchemaContextUtil.findDataSchemaNode()

We have a number of call sites which are using the XPath variant
of SchemaContextUtil.findDataSchemaNode() in context where the
complexity is not warranted.

Introduce utility methods to migrate those callers to a simplified
version which takes resolved QNames (but does not use SchemaPath),
reducing proliferation of PathExpressionImpl.

JIRA: YANGTOOLS-1060
Change-Id: Id645563733af448f42ecdc62b26205c1a97a2216
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 0c48f313a0e06974816cf0d114a83ad1139219b4)

4 years agoClean up SchemaContextUtilTest 20/86620/1
Robert Varga [Sun, 29 Dec 2019 13:09:03 +0000 (14:09 +0100)]
Clean up SchemaContextUtilTest

There is no need to parse YANG files multiple times, just use
@BeforeClass to resolve invariants.

JIRA: YANGTOOLS-1052
Change-Id: Id290aec957b5f70bcdaa7e020799783b02b23c28
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 536a5d80bf67f2630adf7765a2ab83644efff3d4)

4 years agoMove SchemaContextUtilTest 19/86619/1
Robert Varga [Sun, 29 Dec 2019 12:45:46 +0000 (13:45 +0100)]
Move SchemaContextUtilTest

We now have the proper place to hold this unit test, move it to
yang-model-util. Also split out tests which rely on pure mocking
so that they run in yang-model-util instead.

JIRA: YANGTOOLS-1052
Change-Id: Ic736621c7ec2f55ee45d608866f7a581a6d60ef6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 0ba26f769c753bad2e9eabea5ae04a1ffc22305b)

4 years agoClean up openconfig-version test resources 18/86618/1
Robert Varga [Sun, 29 Dec 2019 12:28:39 +0000 (13:28 +0100)]
Clean up openconfig-version test resources

This moves the test resources so they are not scattered across
two directory hierarchies.

Change-Id: I202f415b8f7366047a691f80c1899b6d2875a4a7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit c005231c76c371a4b144993aa90a63d90587925b)

4 years agoRemove useless UnsupportedOperationException throws 17/86617/1
Robert Varga [Sun, 29 Dec 2019 09:28:13 +0000 (10:28 +0100)]
Remove useless UnsupportedOperationException throws

Utility methods have a private constructor, there is no need to
explicitly guard against instantiation.

Change-Id: I93562128b61f051510245de5fe78226508f571b8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit f429749a59a10820b1bad0e9c3502ceac2ec1d07)

4 years agoUse findTargetNode() in findDataSchemaNode() 13/86613/1
Robert Varga [Sun, 29 Dec 2019 08:47:18 +0000 (09:47 +0100)]
Use findTargetNode() in findDataSchemaNode()

This removes a bit of duplication by sharing the code path with
relative resolver.

Change-Id: Icb619aca8d87ade490066fd8c6abe0d2a96dec96
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 57a7f87c3115454aba47299d797da48a1227c9b2)

4 years agoIssue an info message when a config=true list does not have keys 00/86600/1
Robert Varga [Sat, 28 Dec 2019 10:09:37 +0000 (11:09 +0100)]
Issue an info message when a config=true list does not have keys

RFC7950 section 7.8.2 places an explicit requirement that lists
representing configuration (i.e. config=true) must define at least
one key.

This restriction does make sense in contexts like NETCONF, but is
generally not needed in OpenDaylight. Since it hurts model
interoperability, add a message pointing this violation out.

JIRA: YANGTOOLS-957
Change-Id: If29078e51aa1ec55fa070f263755f15147ad835f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit e9061a5ad89661154190aa7703b1de95a5fb528e)

4 years agoFix PathExpressionParser predicate path handling 73/86573/1
Robert Varga [Wed, 25 Dec 2019 20:58:24 +0000 (21:58 +0100)]
Fix PathExpressionParser predicate path handling

Handling of a predicate was wrong in that the right-handside
involving a current() call did not correctly predicates.

This turns out to be a simple typo in two places, fix it and add
an explicit test.

JIRA: YANGTOOLS-1053
Change-Id: I54bac10cdd508503ad896edd628ffa436173ca6b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 90457a20b9d0f6a7652563781d04c19002d29a4e)

4 years agoFix InterningLeafSetNodeBuilder check 67/86567/1
Robert Varga [Wed, 25 Dec 2019 11:23:09 +0000 (12:23 +0100)]
Fix InterningLeafSetNodeBuilder check

The instanceof check is wrong, as pointed out by SpotBugs, as we
want to check for LeafListSchemaNode not LeafSetNode.

Change-Id: If538beca159c100621d5661dc8dced5c1051dfe9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoTrim deref() argument 61/86561/1
Robert Varga [Tue, 24 Dec 2019 21:55:41 +0000 (22:55 +0100)]
Trim deref() argument

When we are evaluating a deref() call we need to make sure we
strip the string completely, otherwise we would arrive at incorrect
path.

JIRA: YANGTOOLS-1050
Change-Id: I36b45677243bcb8ccbf91f8813f082dbddee2a6a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 2e7e6dc6ee82447a286e4df18415de4bff6c2b4e)

4 years agoCorrect deref() leafref handling 59/86559/2
Robert Varga [Mon, 23 Dec 2019 19:06:56 +0000 (20:06 +0100)]
Correct deref() leafref handling

deref() invocation requires the target node to actually be examined,
derefenced and any subsequent path evaluated on top of it.

We correct the implementation to account for correct derefence and
add a UT for a confusing test case. This is implemented using
YangParserTestUtils in a separate internal artifact, hence future
test cases are easy to implement.

JIRA: YANGTOOLS-1050
Change-Id: I0777da339577f93ecc2786f5beab40b29554fe0e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 2ef2f65082021eab8213c4a9e0d71a2cc42a6962)

4 years agoAllow Errata 5617 expressions in leafref 58/86558/1
Robert Varga [Mon, 24 Jun 2019 16:01:16 +0000 (18:01 +0200)]
Allow Errata 5617 expressions in leafref

This updates PathExpression interface to allow expressing
leafref paths which start with a deref(...) function call,
as proposed by https://www.rfc-editor.org/errata/eid5617.

This unfortunately necessitates breaking the API contract of this
interface, as the original object model could not express these.

JIRA: YANGTOOLS-968
Change-Id: I3a193d338de5a82b95d2dd6cc5200e77032e67d9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Signed-off-by: Peter Suna <peter.suna@pantheon.tech>
(cherry picked from commit 2788395b6edecb26c9c2e59b2ab94275e8276987)

4 years agoForce path expression parsing consume all data 47/86547/1
Robert Varga [Sun, 22 Dec 2019 10:20:29 +0000 (11:20 +0100)]
Force path expression parsing consume all data

We really need to make sure we do not end up ignoring part of the
expression just because our rules are not exhaustive. This adds
the appropriate test and fix in grammar.

JIRA: YANGTOOLS-1049
Change-Id: I85278f0cd109897459be1db029fafbc95e203201
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 8dc8c85e43be7c78a8aa4081d970e924b9757b3f)

4 years agoMark yang-maven-plugin as thread-safe 17/86417/1
Robert Varga [Fri, 13 Dec 2019 08:16:25 +0000 (09:16 +0100)]
Mark yang-maven-plugin as thread-safe

The plugin can be executed in multiple projects concurrently,
mark it as such.

Change-Id: I600e733299a7db87dc8040bef89c97ecf9f5f568
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit b8a6ab55af0f9894736bfbf0d4c0bae7dda4f249)

4 years agoFix JDK11 compilation 57/86357/2
Robert Varga [Wed, 11 Dec 2019 20:34:09 +0000 (21:34 +0100)]
Fix JDK11 compilation

This fixes up a javac inference problem, which is completely fine
as we can drop down to java.lang.Object, which we'll be casting
anyway.

Change-Id: I5ce990970607a917d20130a0ecf71a107b3cc0ac
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoBump versions to 3.0.8-SNAPSHOT 56/86356/1
Robert Varga [Wed, 11 Dec 2019 17:52:11 +0000 (18:52 +0100)]
Bump versions to 3.0.8-SNAPSHOT

This starts the next development iteration.

Change-Id: I800560d1a06de2b0b45ee0af6a3685732a613e3b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoBump odlparent to 5.0.4 55/86355/1
Robert Varga [Wed, 11 Dec 2019 17:51:16 +0000 (18:51 +0100)]
Bump odlparent to 5.0.4

This picks up the latest fixes.

Change-Id: Iecf40d92d46d68b746b02e2817aabd2de28a3b2c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRemove intermediate checking maps 19/86019/1
Robert Varga [Tue, 26 Nov 2019 16:57:27 +0000 (17:57 +0100)]
Remove intermediate checking maps

We are enforcing schema tree validity, which is a superset of
the intermediate checks being done in these constructors. Remove
these maps.

JIRA: YANGTOOLS-1043
Change-Id: I88c6b00794fcc31970571bd72a0f57ecb9bd9a19
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 6ba759ce6949dfa7ebbaf90a2a937674f3c52542)

4 years agoEliminate childNodes map 18/86018/1
Robert Varga [Mon, 25 Nov 2019 15:06:50 +0000 (16:06 +0100)]
Eliminate childNodes map

Both AbstractEffectiveDocumentedDataNodeContainer and
AbstractEffectiveModule are subclasses of
AbstractSchemaEffectiveDocumentedNode, which contains schema tree
index.

As all DataSchemaNodes have to strictly be a subset of the schema
tree, we can ditch the dedicated index and simply perform a lookup
on the schema tree followed by a check for DataSchemaNode.

JIRA: YANGTOOLS-1043
Change-Id: I79d5b8ceeb6c16aef162eda9c2a8430b7a9c98f7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 3a3b4422017da67c4f37c06b2e286c3a69c6d0c1)

4 years agoCentralize must contraint definitions 17/86017/1
Robert Varga [Mon, 25 Nov 2019 14:11:16 +0000 (15:11 +0100)]
Centralize must contraint definitions

A number of statemnts can contain must expressions, which we are
tracking separately in each class. This adds common superclasses
to hold the common definition, reducing the amount of duplication.

JIRA: YANGTOOLS-1040
Change-Id: Id5733b62838f484350094456452c7a1d0039f3f2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 0d63e62a11945ade7371bb4667cf65409336f54c)

4 years agoCentralize unknownNodes 16/86016/1
Robert Varga [Mon, 25 Nov 2019 12:54:17 +0000 (13:54 +0100)]
Centralize unknownNodes

We have a number of statements which collect unknown nodes, which
are specified by DocumentedNode. Centralize them as close as possible
in the utility class hierarchy.

JIRA: YANGTOOLS-1040
Change-Id: I337fb684b557269926e641d86d6afd609b2dce57
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 805ce8dc5e98b90427de0cc49fad70d7054635a6)

4 years agoRefactor AbstractEffectiveModule 15/86015/1
Robert Varga [Tue, 26 Nov 2019 11:27:57 +0000 (12:27 +0100)]
Refactor AbstractEffectiveModule

AbstractEffectiveModule has a number of special cases in its
constructor, effectively adding behavior based on expected subclass.

Furthermore its layout does not correctly propagate declared/effective
substatements towards superclass, leading to partially-populated
data/schema tree namespaces.

This patch moves the special handling bits to subclasses, making
AbstractEffectiveModule properly agnostic of whether it is used as
a ModuleEffectiveStatement or SubmoduleEffectiveStatement.

For the mechanics of including submodule effective statements into
the main module we introduce ModuleStmtContext, which performs the
semantic addition, thus all StmtContexts are properly visible as if
they were declared in the main module.

JIRA: YANGTOOLS-1042
Change-Id: Ice9609c2db82981ec9156d076f8a02bc637181b9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 32b112dc64848d9c1cf0ea227109ca9a1265e2e7)

4 years agoFix XPath binary expressions 03/86003/1
Robert Varga [Tue, 26 Nov 2019 23:54:43 +0000 (00:54 +0100)]
Fix XPath binary expressions

AntlrXPathParser.parseRelationalExpr() is consuming acquiring
the operator twice, which leads to iterator state mismatch:

Caused by: java.util.NoSuchElementException
    at java.util.ArrayList$Itr.next (ArrayList.java:999)
    at org.opendaylight.yangtools.yang.xpath.impl.AntlrXPathParser.nextOperator (AntlrXPathParser.java:640)
    at org.opendaylight.yangtools.yang.xpath.impl.AntlrXPathParser.parseRelationalExpr (AntlrXPathParser.java:561)
    at org.opendaylight.yangtools.yang.xpath.impl.AntlrXPathParser.parseRelational (AntlrXPathParser.java:431)
    at org.opendaylight.yangtools.yang.xpath.impl.AntlrXPathParser.parseEquality (AntlrXPathParser.java:310)
    at org.opendaylight.yangtools.yang.xpath.impl.AntlrXPathParser.parseAnd (AntlrXPathParser.java:299)
    at org.opendaylight.yangtools.yang.xpath.impl.AntlrXPathParser.parseExpr (AntlrXPathParser.java:281)
    at org.opendaylight.yangtools.yang.xpath.impl.AntlrXPathParser.parseExpr (AntlrXPathParser.java:261)
    at org.opendaylight.yangtools.yang.xpath.impl.AntlrXPathParser$Qualified.parseExpression (AntlrXPathParser.java:151)

Fix this by properly reusing operator we have already acquired.

JIRA: YANGTOOLS-1045
Change-Id: I757412278eae2d92ff2422782d666cce5bca0720
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit d1af6cd6063d8ee88caa09a78989dcedea9139d6)

4 years agoSquash self-steps when parsing expression 02/86002/1
Robert Varga [Wed, 27 Nov 2019 00:17:33 +0000 (01:17 +0100)]
Squash self-steps when parsing expression

There is no point to repeat self-reference steps, make sure we
skip them when creating a location path. This results in slightly
smaller expressions as well as more obvious comparisons.

JIRA: YANGTOOLS-1045
Change-Id: If681dce2a6bc7155965fed91c47f19f2c541805a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 63b3f4804b408d86a27a6dbe80c21ea7cca921b0)

4 years agoDetect duplicate groupings in operation definitions 90/85990/2
Robert Varga [Tue, 26 Nov 2019 17:13:47 +0000 (18:13 +0100)]
Detect duplicate groupings in operation definitions

It seems we have been missing a namespace check here, fix that.

Change-Id: Ic6e99dfab8c6c3cfef64e519ffd84a0d6fc242a7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 10f235e5787693ee88c187782a9f37f25f45fae4)

4 years agoSpeed up confict detection 89/85989/2
Robert Varga [Tue, 26 Nov 2019 17:01:15 +0000 (18:01 +0100)]
Speed up confict detection

Instead of using Set.contains() before issuing an Set.add() and
ignoring its value, we just add the statement and check the return
value -- if it returns false, we know we have detected a conflict.

Change-Id: I3113c344056b9d745c1cdcccd6d61f68cbe9eafa
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit caad8dd49ee920d4484205af127d1c09bc81b8c9)

4 years agoRework EffectiveStatementBase statement order restoration 88/85988/2
Robert Varga [Tue, 26 Nov 2019 10:03:27 +0000 (11:03 +0100)]
Rework EffectiveStatementBase statement order restoration

Rather than relying on mutation of effective substatements when we
are building an effective statements (and thus requiring StmtContext
to be StatementContextBase), use simple filtering to implement
statement ordering.

This limits the scope of mutable state, explains what is going
on and allows use of different StmtContext implementations.

JIRA: YANGTOOLS-1042
Change-Id: I84a2517ef0ce666fbc2f2c6faa3b0d0a43eef6eb
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 75276bc6d944ff002de8149108d60603349d49c6)

4 years agoRemove Collection2.filter() from EffectieStatementBase 69/85969/1
Robert Varga [Tue, 26 Nov 2019 08:30:26 +0000 (09:30 +0100)]
Remove Collection2.filter() from EffectieStatementBase

We use the filtered collection only to iterate in a for loop, hence
it is more efficient to move the filter into the loop itself,
eliminating an intermediate collection.

Change-Id: I0cc944b3cedd0758d713f394f2d3360d44c26e66
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 3c0a8648375738abf50bc93cce5537af85cdec74)

4 years agoAdd AbstractEffectiveDocumentedNodeWithoutStatus 68/85968/1
Robert Varga [Mon, 25 Nov 2019 12:07:44 +0000 (13:07 +0100)]
Add AbstractEffectiveDocumentedNodeWithoutStatus

We have a number of statements which are specified to be DocumentedNode,
but not DocumentedNode.WithStatus. These are handled by subclassing
DeclaredEffectiveStatementBase and repeated logic looking up description
and reference.

Introduce AbstractEffectiveDocumentedNodeWithoutStatus, which acts as
a plain DocumentedNode implementation without also implying WithStatus
and retrofits this class to all users.

JIRA: YANGTOOLS-1040
Change-Id: Ied1794c4fbd8ca27a4add1d2245fdfb10d8104cb
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 96d12ee2688b296760c29597d44140a34ca762cf)

4 years agoResync javadoc links 81/85881/1
Robert Varga [Wed, 20 Nov 2019 08:01:55 +0000 (09:01 +0100)]
Resync javadoc links

This re-synchronizes links to upstreams to match odlparent.

Change-Id: Ibc514a9aa5eb5f068561772b91061567796ed171
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit e387afabb5c8713c2421d3e33ce1ae4efbf5a04a)

4 years agoSeparate out {Identity,Equality}QueuedNotificationManager 35/85735/2
Robert Varga [Fri, 16 Aug 2019 16:00:47 +0000 (18:00 +0200)]
Separate out {Identity,Equality}QueuedNotificationManager

There are use cases where we would like to use QNM on equality, i.e.
we do not realy have a listener instance, but rather a key to somewhere
else. That other place operates on equality, which makes it incompatible
with the current semantics.

This splits out the baseline queueing logic in from NotificationManager
interface, so that it can be reused to implement different execution
concepts.

QueuedNotificationManager is realized on top of it, so that the baseline
interface is implemented in AbstractQueuedNotificationManager and then
specialized to different lookups.

JIRA: YANGTOOLS-1038
Change-Id: I1123d21664a20ff380ccb7db7096801915491f6e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 807d0868fa0e9b81332ea12d8fe19f81f88efc08)

4 years agoDeprecate LoggingThreadUncaughtExceptionHandler for removal 98/85598/1
Robert Varga [Mon, 4 Nov 2019 10:46:40 +0000 (11:46 +0100)]
Deprecate LoggingThreadUncaughtExceptionHandler for removal

This class creates leaks SLF4J API as an API dependency, which is
rather wrong. Deprecate it for removal.

Change-Id: I29c43855742928782851a45e9b76b9ea4d74aad3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 30b71099adfe2de0e671e18481cdd4c2dfae118e)

4 years agoNormalize predicate order in ImmutableNodes.fromInstanceId() 95/85595/1
Robert Varga [Tue, 5 Nov 2019 13:04:56 +0000 (14:04 +0100)]
Normalize predicate order in ImmutableNodes.fromInstanceId()

The only user of this method is NETCONF, which requires predicates
to be ordered in the order of key definition, as per XML encoding
rules.

Make sure we re-create NodeIdentifierWithPredicates in the schema
definition order if the provided order does not already match it.

JIRA: YANGTOOLS-1037
Change-Id: I57c389eeecb9680062be8b56c834eb569e7d3d3b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 4f869bbe2f963d9168eb659bc1761bfd174e6ab3)

4 years agoExpose underlying schema from DataContainerNormalizationOperation 91/85591/1
Robert Varga [Tue, 5 Nov 2019 12:19:21 +0000 (13:19 +0100)]
Expose underlying schema from DataContainerNormalizationOperation

For the purposes for normalizing data child order we will need to
access the underlying schema in a type-safe manner -- this adds
the mechanics to do so.

JIRA: YANGTOOLS-1037
Change-Id: Id52bd0988405429fbee87a88bb2c9d1de093fb30
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit ee532866b58374349522c42e77f575fb9f99ba03)

4 years agoRename ListItemNormalization 89/85589/1
Robert Varga [Tue, 5 Nov 2019 12:06:28 +0000 (13:06 +0100)]
Rename ListItemNormalization

This is a confusing name, as it should match the NormalizedNode-speak,
i.e. MapEntry* and UnkeyedListEntry*. This fixes up the names, so it is
clear what node a particular class refers to.

JIRA: YANGTOOLS-1037
Change-Id: I82d57efa13b5571a4d8ca92d81b3c0955811aa7a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit ff6881c0f70e27c4f9a717a3d923afa07a5fe580)

4 years agoAdd static ArgumentUtils XPath integration 47/85447/2
Robert Varga [Tue, 29 Oct 2019 21:44:25 +0000 (22:44 +0100)]
Add static ArgumentUtils XPath integration

YANG parser needs to interpret when/must expressions so that they
can be used by downstreams in their effective view.

We add static binding of rfc7950.stmt to an implementation of
YangXPathParserFactory. This makes it clear we do not need to
actually store URIs to make things useful, hence we deprecate
URIStringToImportPrefix namespace.

JIRA: YANGTOOLS-966
Change-Id: Iaf771ad5e0bcdd058fe537ed67d5c9e4e6556e81
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 74ce3034bd665b107918ca25693760d6aa629ef9)

4 years agoAdd YangXPathExpression.getYangVersion() 46/85446/1
Robert Varga [Wed, 30 Oct 2019 20:21:10 +0000 (21:21 +0100)]
Add YangXPathExpression.getYangVersion()

Retrofit awareness of features contained in a particular expression,
so that runtime can properly evaluate them.

Also update parser to intercept RuntimeExceptions and turn them into
checked XPathExpressionExceptions.

JIRA: YANGTOOLS-1036
Change-Id: I7beab757d6f8fa45f9064a77b6c20f2076903b8e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit ff01f3e5609c9527cfcc6823c3c20683fa6fc3a6)

4 years agoExpose minimum YANG version for YangFunction 34/85434/1
Robert Varga [Wed, 30 Oct 2019 13:44:56 +0000 (14:44 +0100)]
Expose minimum YANG version for YangFunction

Not all YangFunctions are available when we are operating in RFC6020
mode. This patch exposes the minimum YANG version from YangFunction,
so it can be checked at runtime.

JIRA: YANGTOOLS-1036
Change-Id: Ieedd58202dd14be9da7cd079c5180e92450c9e5b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit d360dda9dc1fd55ecb6bf02be98e385948270068)

4 years agoReinstate "Check for nested augmentations" 61/85361/1
Robert Varga [Tue, 22 Oct 2019 20:20:00 +0000 (22:20 +0200)]
Reinstate "Check for nested augmentations"

This reverts commit 02fa7531709e3c4599bc9ec23dc605a21a711bc1, effectively
re-applying 759e69d85991edb987a760165adb83fa3f2ab67b.

We also add the mechanics needed to walk the copy history backwards, as
needed to understand the copy process.

JIRA: YANGTOOLS-956
Change-Id: I96b3afb30fdcd326ef9b780ff02ccc7f1c94e07e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 801a53da5a59219883bb1141d2e8191c11b65f47)

4 years agoAdd lenient JsonParserStream 46/85346/1
serngawy [Tue, 15 Oct 2019 20:00:59 +0000 (16:00 -0400)]
Add lenient JsonParserStream

It is beneficial to have the JSON parser ignore unknown constructs,
so that all other data gets parsed successfully.

This patch adds JsonParserStream.createLenient() to return such
parsers.

JIRA: YANGTOOLS-1034
Change-Id: I5ec9dbbf6dc52270bf83d7c4ed6c4d16181f74a7
Signed-off-by: serngawy <m.elserngawy@gmail.com>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 50ba8458e9b8eb48cd47ecf8d0a0f6fb1d83d812)

4 years agoAdd OperationAsContainer @NonNull annotations 89/85289/1
Robert Varga [Sat, 19 Oct 2019 07:05:46 +0000 (09:05 +0200)]
Add OperationAsContainer @NonNull annotations

This makes working with the class easier a bit.

Change-Id: Ica69b5517b5feb9a55c20dbb9fe465ad9081ba23
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 1da8c1070b926b27cc0028173038235a43c5c4bb)

4 years agoBump versions to 3.0.7-SNAPSHOT 30/85230/1
Robert Varga [Sat, 19 Oct 2019 07:52:48 +0000 (09:52 +0200)]
Bump versions to 3.0.7-SNAPSHOT

This starts the next development iteration.

Change-Id: Ib1e4da0d9ab30bd0d64887990b276df815750e72
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoBump odlparent to 5.0.3 24/85224/1
Robert Varga [Sat, 19 Oct 2019 06:32:05 +0000 (08:32 +0200)]
Bump odlparent to 5.0.3

This picks up latest updates.

Change-Id: I7c52bc99029342c2381635952a0f7be02a64a813
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoFix foldable trigraphs 23/85223/1
Robert Varga [Fri, 18 Oct 2019 08:22:27 +0000 (10:22 +0200)]
Fix foldable trigraphs

Sonar correctly points out the expression can be simplified, this
patch does exactly that.

Change-Id: I0ea51d18d551be0f4bd416d7b18da3eb543e0244
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 71892d4c8f435650eeef99f276884f7c2a3d57bd)

4 years agoCleanup code smells reported by sonar 22/85222/1
Robert Varga [Fri, 18 Oct 2019 08:02:28 +0000 (10:02 +0200)]
Cleanup code smells reported by sonar

We are duplicating code here, so introduce a check-and-cast method
and use that from the 5 callsites.

Change-Id: Ic1b734f62cb2d79b8dd28a1fcee76cbffea72c33
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 8e1209717df9fe7dfd9bb7a8be1e245e12501ba3)

4 years agoDisable slf4j SSL link 21/85221/1
Robert Varga [Fri, 11 Oct 2019 12:01:15 +0000 (14:01 +0200)]
Disable slf4j SSL link

slf4j does not provide apidocs over TLS, link HTTP site instead.

Change-Id: I2158c043a2d9e810a329587159fc6af9d57d8e56
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 2a357e7ca8e27873ef49e3bb1f754c92fcea1ca9)

4 years agoFix Decimal64.equals() 34/85034/1
Robert Varga [Thu, 10 Oct 2019 10:29:23 +0000 (12:29 +0200)]
Fix Decimal64.equals()

There is a typo here, which would end up not comparing objects
properly.

Change-Id: I5cfe31887b109bbe7be6e564078f250ea6b61747
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 3670f3b1080d917bd1bec4611e75a9b345b06023)

4 years agoLeafEffectiveStatement should be a DataTreeEffectiveStatement 07/85007/1
Robert Varga [Tue, 8 Oct 2019 11:21:14 +0000 (13:21 +0200)]
LeafEffectiveStatement should be a DataTreeEffectiveStatement

This is a conflicting model, which should understand it has conflicting
children.

JIRA: YANGTOOLS-857
Change-Id: I1bca05f9a3f053419d518ef2c9966978901b419f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 3c57ac547d198bf5cb6d358519789a028cd63623)

4 years agoCleanup yang-data-impl antlr configuration 99/84999/1
Robert Varga [Tue, 8 Oct 2019 19:31:44 +0000 (21:31 +0200)]
Cleanup yang-data-impl antlr configuration

This fixes up a long-standing issue with how antlr is configured,
fixing javadoc plugin interaction in the process.

Change-Id: I5c6ad385196f237b5a5eae110948cbf2ae2792e5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 598731773fb790c059d300266b2732278b99c11a)

4 years agoCleanup yang-xpath-impl antlr configuration 98/84998/1
Robert Varga [Tue, 8 Oct 2019 19:28:16 +0000 (21:28 +0200)]
Cleanup yang-xpath-impl antlr configuration

This fixes up a long-standing issue with how antlr is configured,
fixing javadoc plugin interaction in the process.

Change-Id: I4c94aa50c44dc5fc6268d94739e50ef27e868cde
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 7c2f7b53352ed27c745e661579132eea66f4c25e)