yangtools.git
3 years agoMake YangNamespaceContextNamespace global 47/92947/1 v3.0.x
Robert Varga [Tue, 6 Oct 2020 18:47:55 +0000 (20:47 +0200)]
Make YangNamespaceContextNamespace global

The crux of the problem with not being able to resolve prefixes comes
from the fact we end up reusing the same context for both submodule
and module. Turn the namespace into a global one, keyed by the root
context.

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

3 years agoBump versions to 3.0.18-SNAPSHOT 86/92286/1
Robert Varga [Wed, 26 Aug 2020 08:36:52 +0000 (10:36 +0200)]
Bump versions to 3.0.18-SNAPSHOT

This starts the next development iteration.

Change-Id: I16d1b7986769de734e399acf650bbce68228dc27
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoAdd a specialized token factory 64/92264/2
Robert Varga [Mon, 10 Aug 2020 12:07:00 +0000 (14:07 +0200)]
Add a specialized token factory

Our baseline parsing footprint is rather large. We can improve it
by looking at token component sizes and using distinct token classes.

Aside from CommonToken, which are using as fallbacks for text
handling, we introduce 4 specialized classes, three of them seeing
typical use.

Since these classes use smaller fields to hold lazy state, as well
as eliminate typical invariants, we end up saving around 39MiB (12%)
of AST size in a typical case from the field.

JIRA: YANGTOOLS-1128
Change-Id: I600ae6cbe755212e2d1a15ae3e6b369ed0b3b962
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit f65682b440f3a2767a7852c9b1b3f0d0ea25f95d)
(cherry picked from commit e66e724b7eece352212ddb274d417ffc1c9b49f0)

3 years agoEliminate DQUOT_START/SQUOT_START tokens 52/92252/1
Robert Varga [Sun, 23 Aug 2020 20:53:39 +0000 (22:53 +0200)]
Eliminate DQUOT_START/SQUOT_START tokens

Quoted strings are naturally terminated by end marker, potentially
preceded by DQUOT_STRING/SQUOT_STRING. This renders the corresponding
start tokens really just a academic completeness, costing us memory
while not bringing anything to the table.

Skip generation of these tokens, reducing memory usage by up to 4.5%.

JIRA: YANGTOOLS-1089
Change-Id: I0b7ce9bf292b0dd8475d63869ddfd8d2b86a387c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 92a6c34fae26e54f9cf962228374805198b65059)

3 years agoEliminate quotedString parser construct 43/92243/2
Robert Varga [Sun, 23 Aug 2020 07:10:02 +0000 (09:10 +0200)]
Eliminate quotedString parser construct

Double-quoted strings are very common and having a separate parser
construct is not giving us much for the memory footprint it incurs.

Inline the recursive definition into argument and adjust parsing
code to cope with the change. This results in memory usage improvement
of up to 3.7%.

JIRA: YANGTOOLS-1089
Change-Id: I9fce7d1ed9f8df4bcc602978c66fcfba7bbd8ed8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoFurther optimize YANG statement parsing 40/92240/1
Robert Varga [Sat, 22 Aug 2020 20:26:56 +0000 (22:26 +0200)]
Further optimize YANG statement parsing

Recursive definition of stringPart can easily end up with a large
number of retained objects -- i.e. we get StringPartContext for
each concatenation, with potentially small lists of three tokens.

Furthermore each unquotedString has ends up being typically defined
by a UnquotedStringContext containing a single StringPartContext,
which is clearly wasteful.

The grammar we are looking at is not that complex, hence we can
rewrite it without relying on recursion -- thus improving memory
footprint.

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

3 years agoSpecial-case identifier lexer token 10/92210/1
Robert Varga [Thu, 20 Aug 2020 14:48:41 +0000 (16:48 +0200)]
Special-case identifier lexer token

An unquoted string can be an IDENTIFIER, which is the most common
case anyway. This token does not have to be further validated and
thus it makes sense to special-case it. This has the neat effect
of reducing the depth of our parse tree, too -- bringing memory
usage down by 6.6% versus the original fix.

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

3 years agoRemove an unneeded continue 64/92164/1
Robert Varga [Fri, 14 Aug 2020 16:29:28 +0000 (18:29 +0200)]
Remove an unneeded continue

We have an if/else branch, no need for another continue.

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

3 years agoTake advantage of keyword tokenization 60/92160/2
Robert Varga [Fri, 14 Aug 2020 09:09:05 +0000 (11:09 +0200)]
Take advantage of keyword tokenization

Now that the tokenization has been fixed, we can rely on keyword
context to provide us with neatly split prefix and local name --
hence we do not need to perform concat/split.

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

3 years agoRework YANG lexer/parser 59/92159/2
Robert Varga [Thu, 13 Aug 2020 18:15:06 +0000 (20:15 +0200)]
Rework YANG lexer/parser

The definitions in the parser and lexer are quite arcane and are
actually wrong, not allowing for a number of edge cases, which are
completely valid.

Furthermore the definition of IDENTIFIER is wrong, as it allows /
and : to appear in it -- effectively ruining the tokenization in
parser.

Refactor the lexer to perform correct tokenization in every situation.
This makes it more complicated, but also much more obvious as to
what is going on -- especially with regard as to what decisions
end up being parser's responsibility.

Refactor the parser so it recognizes YANG tokenization constructs,
notably quoted and unquoted strings, and assemble them from lexer
tokens.

JIRA: YANGTOOLS-1089
Change-Id: I34472bf0a7e262d4f633ce271952bbcd7639ef2f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 58de36f365950a14a17b89f4e3ab8e7902090375)

3 years agoReplace block comment with a non-greedy rule 56/92156/1
Robert Varga [Thu, 13 Aug 2020 18:09:10 +0000 (20:09 +0200)]
Replace block comment with a non-greedy rule

We do not need an explicit mode here, we can just use a non-greedy
match and move on. This simplifies things a bit.

Change-Id: Ieab6d9cec1b17c8d86cda49cfc46a258a569e5e0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 0bf84fba6502cb4bc86f9e558a4a928e6397a793)
(cherry picked from commit d502bccd8f1fd9757b3b4cf59784b7cdb21c8dc4)

3 years agoRework keyword parser rule 46/92046/1
Robert Varga [Tue, 11 Aug 2020 09:38:52 +0000 (11:38 +0200)]
Rework keyword parser rule

A keyword is either a plain identifier, or two identifiers concatenated
through a colon. Make this a bit clearer, aiding debugging of issues.

Also push KeywordContext down to
StatementContextVisitor.getValidStatementDefinition(), so that we can
improve efficiency once IDENTIFIER token has been fixed up.

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

3 years agoRefactor YANG statement parser structure 45/92045/1
Robert Varga [Tue, 11 Aug 2020 08:47:25 +0000 (10:47 +0200)]
Refactor YANG statement parser structure

Current definition leads to leading whitespace being considered
a part of the statement. This leads to misleading line/character
being reported as the start of the statement.

Fix this by introducing a top-level 'file', which encapsulates
at least one statement with its leading/trailing whitespace. The
other parts then come together naturally.

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

3 years agoBump versions to 3.0.17-SNAPSHOT 07/91607/1
Robert Varga [Fri, 24 Jul 2020 05:19:31 +0000 (07:19 +0200)]
Bump versions to 3.0.17-SNAPSHOT

This starts the next development iteration.

Change-Id: I8c736ce067d6abddb99fbd589d4c6280dba60b60
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoBump odlparent to 5.0.11 06/91606/1
Robert Varga [Fri, 24 Jul 2020 05:14:00 +0000 (07:14 +0200)]
Bump odlparent to 5.0.11

Pick up yet another regression fix.

Change-Id: I6036a45e312dd5ccccfd878f3bcadd527bd93594
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoBump versions to 3.0.16-SNAPSHOT 37/91537/1
Robert Varga [Wed, 22 Jul 2020 13:17:26 +0000 (15:17 +0200)]
Bump versions to 3.0.16-SNAPSHOT

This starts the next development iteration.

Change-Id: I692406bdd29aae69415f212d54656ae9d3cd71be
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoBump odlparent to 5.0.10 35/91535/1
Robert Varga [Wed, 22 Jul 2020 12:17:11 +0000 (14:17 +0200)]
Bump odlparent to 5.0.10

Pick up fixed netty.

Change-Id: I6445719c447a38010f17498b99595858e0c13228
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoRevert "Update YANG lexer/parser to accept free-standing '+'" 31/91531/1
Robert Varga [Wed, 22 Jul 2020 11:12:55 +0000 (13:12 +0200)]
Revert "Update YANG lexer/parser to accept free-standing '+'"

This reverts commit 0b7752210c234bd629fcc2e3ed52904427071b0a, as it
causes a regression around "foo" +"foo" construct.

JIRA: YANGTOOLS-1089
Change-Id: Ib5af7a994c19bf99fb5cb2a875063d623cc6c3f7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoBump versions to 3.0.15-SNAPSHOT 60/91360/1
Robert Varga [Fri, 17 Jul 2020 08:15:05 +0000 (10:15 +0200)]
Bump versions to 3.0.15-SNAPSHOT

This starts the next development iteration.

Change-Id: I8ed72a7dfedbd68fc3afb71401e1c50701c4b86d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoUse modifiable List when resolving relative xpath 32/91332/1
Tomas Cere [Tue, 14 Jul 2020 13:05:18 +0000 (15:05 +0200)]
Use modifiable List when resolving relative xpath

When we have split the path into its components, we can end up
compressing them further. Make sure the list is actually mutable.

JIRA: YANGTOOLS-1125
Change-Id: I1d4cd66d2efbb1955bb189763ea09fefeba93d25
Signed-off-by: Tomas Cere <tomas.cere@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 69cb7d1ab7a329e2bd19f538b3d598be91c49f2d)

3 years agoClean up predicates prior to xpath normalization 30/91330/2
Tomas Cere [Wed, 15 Jul 2020 08:43:57 +0000 (10:43 +0200)]
Clean up predicates prior to xpath normalization

Path splitting is not equipped to ignore step predicates, which leads
it to do arrive at the wrong path. Remove any predicates before
embarking on resolving the reference.

JIRA: YANGTOOLS-1126
Change-Id: Ia32836ad1acec0762d9baa7ded5f65fa72f39b93
Signed-off-by: Tomas Cere <tomas.cere@pantheon.tech>
(cherry picked from commit 76fac8f8464bd072d9b26dccddb5450d3716dd51)

3 years agoBump versions to 3.0.14-SNAPSHOT 06/91306/1
Robert Varga [Mon, 13 Jul 2020 20:30:14 +0000 (22:30 +0200)]
Bump versions to 3.0.14-SNAPSHOT

This starts the next development iteration.

Change-Id: I56f2c1c6394c4fdd1617a5806ff671fa74f10550
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoRetain leaf nodes by default 07/89807/3
Robert Varga [Fri, 15 May 2020 07:33:07 +0000 (09:33 +0200)]
Retain leaf nodes by default

The previous backported patch has changed the default behavior
around leaf nodes. Flip the default other way around, resulting
in previous behavior, while still allowing users to opt in into
treating leaf nodes as transient.

JIRA: YANGTOOLS-1019
Change-Id: I67b6c8ffdc563b472a8c822d1aa4100594640645
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoVerify leaf node squashing 06/89806/3
Robert Varga [Fri, 30 Aug 2019 12:11:09 +0000 (14:11 +0200)]
Verify leaf node squashing

There is a very slight possiblity of somebody playing tricks
to inject Leaf node with a DataContainerChild value, in which case
decoding would break. Verify this does not happen.

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

3 years agoFixup LazyLeafOperations 05/89805/3
Robert Varga [Fri, 30 Aug 2019 08:58:33 +0000 (10:58 +0200)]
Fixup LazyLeafOperations

LazyLeafOperations.isEnabled() allows code to query whether leaf nodes
are being treated as expendable, hence assumptions about them being
equal on identity can be violated. We retrofit the check into tests we
modified before.

Furthermore users of getValue() expect it to work with identities,
even when it is being specialized to a Collection. The expectation here
is that the same collection will be returned from NormalizedNode,
which we are violating. Fix this up by introducing a new implementation
class, which hides this difference and defers equality to the backing
map.

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

3 years agoDo not retain leaf nodes in containers by default 04/89804/3
Robert Varga [Tue, 27 Aug 2019 14:04:55 +0000 (16:04 +0200)]
Do not retain leaf nodes in containers by default

Leaf nodes are observed to dominate our memory footprint. This
patch modifies immutable implementations of NormalizedNodeContainers
such that they eliminate any leaf nodes when they are stored, retaining
only the encapsulated value. Leaf nodes are then re-created on access
as needed.

Note this changes two aspects of operation:

1) looking up a leaf will yield a new object every time it is invoked,
   hence callers must not rely on on returned objects to be identical.

2) getValue() is operating on the backing map's entrySet() and requires
   its transformation. This means that multiple iterations over values
   will not necessarily yield same objects.

Neither of these violates effective immutability contract of NormalizeNode,
as the returned objects will compare as equal.

This behavior can be switched off at runtime by setting the system property:

    org.opendaylight.yangtools.yang.data.impl.schema.nodes.lazy-leaves=false

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

3 years agoBump odlparent to 5.0.9 97/91297/1
Robert Varga [Mon, 13 Jul 2020 11:56:19 +0000 (13:56 +0200)]
Bump odlparent to 5.0.9

Pick up latest upstream upgrades.

Change-Id: I7f545ba7298d52ba8b0a3967ea5a718c3b1cfc16
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoFix YangConstants.RFC6020_YIN_MEDIA_TYPE 65/90965/1
Robert Varga [Tue, 7 Jul 2020 17:53:14 +0000 (19:53 +0200)]
Fix YangConstants.RFC6020_YIN_MEDIA_TYPE

The definition and reference are wrong here, fix that up.

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

3 years agoUpdate YANG lexer/parser to accept free-standing '+' 36/90936/2
Robert Varga [Fri, 17 Apr 2020 18:01:36 +0000 (20:01 +0200)]
Update YANG lexer/parser to accept free-standing '+'

The lexer is not quite accurate, as it does not allow for strings
starting with a '+' when not quoted. Fix this up, relaxing the
rules.

JIRA: YANGTOOLS-1089
Change-Id: Ifaf9c65966b43f26f37fc88a11d77fc9f43d2c8c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 04ed60d275521fd6e6ee57d5b1ce4e6a519d2e35)

3 years agoDisconnect StmtNamespaceContext from statement 21/90821/2
Robert Varga [Mon, 29 Jun 2020 21:24:15 +0000 (23:24 +0200)]
Disconnect StmtNamespaceContext from statement

Retaining a reference to any StmtContext is not good, as we end
up retaining the entire build context from each parsed XPath. Make
sure we maintain a simple disconnected YangNamespaceContext
implementation at each root.

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

3 years agoDo not retain namespace context when not needed 20/90820/1
Robert Varga [Mon, 29 Jun 2020 19:51:04 +0000 (21:51 +0200)]
Do not retain namespace context when not needed

If we have not recorded presence of a literal expression, there
is no legal way we can be asked to resolve a literal to either
a QName or a YangInstanceIdentifier.

Track creation of YangLiteralExprs, so that we can ditch the
namespace context we will not need it.

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

3 years agoEliminate use of ImmutableList 11/90811/1
Robert Varga [Mon, 29 Jun 2020 10:18:15 +0000 (12:18 +0200)]
Eliminate use of ImmutableList

We can use a simple array, as we are only iterating over this
list.

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

3 years agoFix javadoc to comply with JDK14 04/90804/1
Robert Varga [Fri, 26 Jun 2020 19:57:44 +0000 (21:57 +0200)]
Fix javadoc to comply with JDK14

JDK14 has a stricter default doclet. Fix issues reported by it so
that the code can be compiled with JDK14.

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

3 years agoClean up AntlrXPathParser a bit 09/90709/1
Robert Varga [Wed, 24 Jun 2020 12:04:31 +0000 (14:04 +0200)]
Clean up AntlrXPathParser a bit

This cleans up instantiation so we can better communicate parser
state to the resulting expression.

JIRA: YANGTOOLS-1115
Change-Id: I111926b76f88ca2c4023cdd41b77d56768c38497
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 0826ac2f735ecfa1d51cc297e155865e39e636c1)
(cherry picked from commit cf012978b61d6dd39d442cfa3484481667196532)

3 years agoAdd YangInstanceIdentifier.create(PathArgument) 08/90708/1
Robert Varga [Thu, 25 Jun 2020 14:26:39 +0000 (16:26 +0200)]
Add YangInstanceIdentifier.create(PathArgument)

This is a short-circuit version of the varargs create(), which is
slighly faster.

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

3 years agoFix reference to odl-antlr4 80/90580/1
Robert Varga [Mon, 22 Jun 2020 19:14:21 +0000 (21:14 +0200)]
Fix reference to odl-antlr4

This is a slight mistake, we should be referencing the feature
through a range.

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

3 years agoBump versions to 3.0.13-SNAPSHOT 43/90543/1
Robert Varga [Mon, 22 Jun 2020 06:47:11 +0000 (08:47 +0200)]
Bump versions to 3.0.13-SNAPSHOT

This starts the next development iteration.

Change-Id: I12f03d5c3a8b6429e6208bfde0be40b037102bff
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoBump odlparent to 5.0.8 41/90541/1
Robert Varga [Sun, 21 Jun 2020 14:16:29 +0000 (16:16 +0200)]
Bump odlparent to 5.0.8

Pick up SFT improvements from upstream.

Change-Id: I2ec144f2029460890c7b150d23e2c1f7fadeed65
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoBackport yang-data-codec-binfmt to v3.0.x 17/90517/3
Robert Varga [Fri, 19 Jun 2020 10:48:40 +0000 (12:48 +0200)]
Backport yang-data-codec-binfmt to v3.0.x

This is a straight backport of all the changes done in 4.0.x
time-frame, so that we have the same codebase available in 3.0.x
stream.

JIRA: YANGTOOLS-1035
Change-Id: If661bd31df527832de7c52cc85420073b87e390f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoSpeed up YangParser.addLibSource() 28/90428/1
Robert Varga [Fri, 12 Jun 2020 06:36:49 +0000 (08:36 +0200)]
Speed up YangParser.addLibSource()

Since we are adding a single source only, we can go through
the single-argument method, making things a tad more efficient.

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

3 years agoAdd CrossSourceStatementReactor javadocs 27/90427/1
Robert Varga [Fri, 12 Jun 2020 06:32:05 +0000 (08:32 +0200)]
Add CrossSourceStatementReactor javadocs

Clarify interface contracts based on current behavior. Also add
a single-argument addLibSource().

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

3 years agoSpeed up YangParser.addSource() 26/90426/1
Robert Varga [Fri, 12 Jun 2020 06:32:34 +0000 (08:32 +0200)]
Speed up YangParser.addSource()

Since we are adding a single source only, we can go through
the single-argument method, making things a tad more efficient.

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

3 years agoFix Status encoding 91/90391/1
Robert Varga [Tue, 4 Feb 2020 18:55:12 +0000 (19:55 +0100)]
Fix Status encoding

We assigned wrong bits for Status.OBSOLETE, leading wrong value being
reported.

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

3 years agoAllow list elements to be interleaved 57/90357/1
Jamo Luhrsen [Sun, 31 May 2020 05:29:52 +0000 (22:29 -0700)]
Allow list elements to be interleaved

If a list node A is parsed then list node B and another list with A
is given after, it fails to parse as a duplicate.

Skip checking for duplicate nodes if the node being parsed is found
to correspond to ListEffectiveStatement.

JIRA: YANGTOOLS-1107
Change-Id: I4dae263a1e41444db7a6cce6eb958f397c801070
Signed-off-by: Jamo Luhrsen <jluhrsen@gmail.com>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit eb4617a9867325921e0fd9660898c3fc4dfc8d11)

3 years agoDeprecate ListEntryNodeDataWithSchema.forSchema() 55/90355/1
Robert Varga [Tue, 9 Jun 2020 12:35:07 +0000 (14:35 +0200)]
Deprecate ListEntryNodeDataWithSchema.forSchema()

This method should not be visible from outside of the package,
make sure we remove it.

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

3 years agoSplit out addCompositeChild(CaseSchemaNode) 54/90354/1
Robert Varga [Tue, 9 Jun 2020 11:50:15 +0000 (13:50 +0200)]
Split out addCompositeChild(CaseSchemaNode)

Choices seem to have this special case, which we should be able to
wire without an explicit cast in most cases.

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

3 years agoClean up variable initialization 53/90353/1
Robert Varga [Tue, 9 Jun 2020 11:34:04 +0000 (13:34 +0200)]
Clean up variable initialization

We can make local variable final and non-null, improving logic
flow in this method.

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

3 years agoAdd YangInstanceIdentifier.coerceParent() 07/90307/1
Robert Varga [Fri, 5 Jun 2020 15:41:08 +0000 (17:41 +0200)]
Add YangInstanceIdentifier.coerceParent()

There are a number of YangInstanceIdentifier users who perform
checks (or otherwise ensure) that YangInstanceIdentifier they are
dealing with is non-empty and hence its getParent() method cannot
possibly return null. These users still interact with methods
which explicitly require a non-null YangInstanceIdentifier -- hence
it would be useful to provide a bridge method which performs this
validation.

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

3 years agoAdd MultipleEntryDataWithSchema interface 03/90303/1
Robert Varga [Fri, 5 Jun 2020 13:54:51 +0000 (15:54 +0200)]
Add MultipleEntryDataWithSchema interface

We are sharing essentially the same code in both JSON and XML
parsers, where we really to make this common code exposed from
appropriate NodeDataWithSchema.

Centralizing the interface contract and implementations allows us
to ditch external users of CompositeNodeDataWithSchema.addChild(),
which is now deprecated.

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

3 years agoAdd test for union with identity XML codec issue 87/90287/2
Anna Bencurova [Wed, 3 Jun 2020 16:28:36 +0000 (18:28 +0200)]
Add test for union with identity XML codec issue

JIRA: YANGTOOLS-1108
Change-Id: Ib33d1865c138474eae8b6fbf04c50688d8a4809a
Signed-off-by: Anna Bencurova <Anna.Bencurova@pantheon.tech>
(cherry picked from commit 48b7827d5cb4d0506e33f0060a4a81b3a0618116)

3 years agoCheck unions for instance-identifier types 86/90286/1
Robert Varga [Thu, 4 Jun 2020 12:11:05 +0000 (14:11 +0200)]
Check unions for instance-identifier types

If an instance-identifier type is encountered within a union, we
end up going to TypeDefinitionAwareCodec, which is not equiped to
handle the complexities of XML-encoding instance identifiers. Make
sure we do perform a check to side-step this problem.

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

3 years agoCheck unions for identityref types 85/90285/1
Robert Varga [Thu, 4 Jun 2020 11:06:06 +0000 (13:06 +0200)]
Check unions for identityref types

If an identityref type is encountered within a union, we end up
going to TypeDefinitionAwareCodec, which is not equiped to handle
the complexities of XML-encoding identityrefs. Make sure we do
perform a check to side-step this problem.

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

3 years agoSeparate out correct QName-bearing serialization method 78/90278/1
Robert Varga [Thu, 4 Jun 2020 10:54:41 +0000 (12:54 +0200)]
Separate out correct QName-bearing serialization method

We want to start deprecating .toString()-based codec, hence we want
to separate the happy path out.

JIRA: YANGTOOLS-1108
Change-Id: Ic5fa79c0649a73583eac4c043bd4c8b4b6b60bc0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 7176c6b8f99f4d434634ae941a34c69397f253c1)

3 years agoImprove error message in UnionXmlCodec 77/90277/1
Robert Varga [Thu, 4 Jun 2020 10:45:24 +0000 (12:45 +0200)]
Improve error message in UnionXmlCodec

We are missing a space before value, which would not be properly
delineated.

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

3 years agoPropagate type to XMLStreamWriterUtils 76/90276/1
Robert Varga [Thu, 4 Jun 2020 10:14:59 +0000 (12:14 +0200)]
Propagate type to XMLStreamWriterUtils

We have a useless checkArgument here, which is impossible to hit
if we structure this just right.

JIRA: YANGTOOLS-1108
Change-Id: I589da629526026fa09c0dda9c11f0bd5516941a0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 22384c114cd763c21096f8d673c7ca7dae24b549)

3 years agoTeach SchemaAwareApplyOperation about anydata/anyxml 01/90001/1
Robert Varga [Wed, 27 May 2020 10:12:40 +0000 (12:12 +0200)]
Teach SchemaAwareApplyOperation about anydata/anyxml

When we encounter an anydata/anyxml element in schema, we should
not be ignoring it, cascading to a silent failure, but rather
treat it as a leaf-like node.

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

3 years agoSimplify AbstractNodeContainerModificationStrategy 60/89960/1
Robert Varga [Tue, 26 May 2020 11:37:29 +0000 (13:37 +0200)]
Simplify AbstractNodeContainerModificationStrategy

Since we have NormalizedNodeContainer and we know this type, we
can eliminate a few casts, checks and warning suppressions by
retaining proper type safety.

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

3 years agoFix an error message typo 57/89957/1
Robert Varga [Tue, 26 May 2020 10:11:22 +0000 (12:11 +0200)]
Fix an error message typo

We are missing a space here, making it hard to decode what
the source is. Fix that.

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

3 years agoBump versions to 3.0.12-SNAPSHOT 51/89751/1
Robert Varga [Thu, 14 May 2020 14:00:59 +0000 (16:00 +0200)]
Bump versions to 3.0.12-SNAPSHOT

This starts the next development iteration.

Change-Id: I89effda1276c927d0881398eaaa60a9e4fc2b0fd
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoBump odlparent to 5.0.7 50/89750/1
Robert Varga [Thu, 14 May 2020 13:24:49 +0000 (15:24 +0200)]
Bump odlparent to 5.0.7

Adopt latest updates from upstream.

Change-Id: Ib99a6ec44c07daf8138a525dc032d2d2e2e5d5dd
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoOptimize LazyContainerNode.getChild() 75/89275/1
Robert Varga [Wed, 22 Apr 2020 14:29:20 +0000 (16:29 +0200)]
Optimize LazyContainerNode.getChild()

This just trims bytecode a bit by using an expression.

Change-Id: I20f8b6e10f42ff20f188f20991fbe0a8f0159396
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoAdd NormalizedNodeContainer.size() 66/89266/1
Robert Varga [Wed, 22 Apr 2020 11:32:23 +0000 (13:32 +0200)]
Add NormalizedNodeContainer.size()

While the size of children is available through getValue(), it
is not completely efficient, as it may be forcing instantiation of
a Map.values() view.

Add NormalizedNodeContainer.size() to provide a more efficient way
of accessing this property. This has immediate benefits on both
MinMaxElementsValidation as well as general InMemoryDataTree
transaction performance.

JIRA: YANGTOOLS-1101
Change-Id: I607c2872645850400e4f242152059958729666b2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 9fc5fe4197ae53e7e07ca79421fb3dec72c6d0d9)

4 years agoFix relative xPath resolution for leafref types 06/89106/2
miroslav.kovac [Fri, 13 Mar 2020 13:49:23 +0000 (14:49 +0100)]
Fix relative xPath resolution for leafref types

If we have a leaf of type leafref with relative path that crosses
through case and choice schema nodes.

This stems from the historic disconnect about how the path should
be handled: it needs to be resolved in the context of walking the
data tree, not schema tree. That means that choice/case nodes are
not part of the path in the expression and therefore need to be
skipped over.

JIRA: YANGTOOLS-1100
Change-Id: I9908c91b0068f52f4b6719545c738d7c39e2a228
Signed-off-by: miroslav.kovac <miroslav.kovac@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoDo not issue duplicate warnings for lists missing keys 14/89014/2
Robert Varga [Thu, 9 Apr 2020 16:41:16 +0000 (18:41 +0200)]
Do not issue duplicate warnings for lists missing keys

We currently are issuing the config list warning for each instantiated
site, which ends up flooding our logs, as BGPCEP takes advantage of our
lenience -- leading to 3400+ warnings.

Make sure we flag each original list only once, suppressing other
instances of the violation. This presumably will provide enough guidance
while keeping the noise to a sane amount (~200 warnings).

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

4 years agoRefactor string unescaping 13/89013/1
vladyslav.marchenko [Fri, 6 Mar 2020 13:29:22 +0000 (15:29 +0200)]
Refactor string unescaping

Add explicit tests and rework unescaping of double-quoted strings
so that we do not use arcane patterns.

JIRA: YANGTOOLS-1079
Change-Id: I3b8bd13f260f13796492d19aea35c4c3f27760fc
Signed-off-by: vladyslav.marchenko <Vladyslav.Marchenko@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit f8501e012a6585adc523f51d064dfa61ec9ea24e)

4 years agoImprove list key presence checks 43/88843/1
Robert Varga [Tue, 31 Mar 2020 13:21:03 +0000 (15:21 +0200)]
Improve list key presence checks

A few statements are explicitly not part of instantiated tree, but
rather define a different data tree instance, which may be related
the instantiated tree.

We checked only for groupings, but we need to also consider input,
output and notification statements.

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

4 years agoAdd DataTreeCandidateInputOutput 27/88627/1
Robert Varga [Wed, 18 Mar 2020 10:27:54 +0000 (11:27 +0100)]
Add DataTreeCandidateInputOutput

DataTreeCandidate is a yangtools concept, which is commonly
serialized by users of DataTree. Make sure we support its serialization
in the binary stream -- importing the implementation from controller
as of e66759266dc43d5f58b2837aca5047b42c205e4a.

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

4 years agoBump versions to 3.0.11-SNAPSHOT 35/88335/1
Robert Varga [Fri, 6 Mar 2020 16:50:04 +0000 (17:50 +0100)]
Bump versions to 3.0.11-SNAPSHOT

This starts next development iteration.

Change-Id: Icfad603afd3005f08e2a6b199f2eb67135eac401
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoBump odlparent to 5.0.6 29/88329/2
Robert Varga [Fri, 6 Mar 2020 12:46:14 +0000 (13:46 +0100)]
Bump odlparent to 5.0.6

This adopts latest Sodium-stream odlparent version, fixing a few
issues. Updated checkstyle tooling is finding a few violations,
which we also fixup.

Change-Id: I1e8f1511ab566ed7a02dbd79b022a301e0ef92c6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoFilter registered listeners 74/88174/2
Robert Varga [Sat, 29 Feb 2020 11:18:28 +0000 (12:18 +0100)]
Filter registered listeners

There is a small race window where the registration could be marked
as unregistered and not removed from the map. Check that condition
before letting the listener through.

Change-Id: I1938e6459faaaadf69bc7907ba6ba71e65fe9e8f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoDo not instantiate a Consumer for registration 73/88173/2
Robert Varga [Sat, 29 Feb 2020 10:51:34 +0000 (11:51 +0100)]
Do not instantiate a Consumer for registration

Taking a Consumer forces us to instantiate it to capture listeners
Set. We can do the same by simply moving the reference away. For
safety we only get a Collection<?>, for which remove(Object) is just
what we want.

Change-Id: I4f3bd473a75dabee1d1a31e10cf0fefe57c4896b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoAdd ListenerRegistry.clear() 72/88172/2
Robert Varga [Sat, 29 Feb 2020 10:30:28 +0000 (11:30 +0100)]
Add ListenerRegistry.clear()

There are callers who mean to only clear the registry for which
they are accessing the public view. Provide a method to do that
and mark getRegistrations() as deprecated.

Change-Id: I73b18443c505e7c7cea7efec627cc87196793d46
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoAdd AbstractRegistration.notClosed() 71/88171/1
Robert Varga [Sat, 29 Feb 2020 11:17:07 +0000 (12:17 +0100)]
Add AbstractRegistration.notClosed()

This is a utility method useful for stream integration.

Change-Id: I6408cc25a1a10f010fc4f42ee83d50db31ca8bfa
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoQName namespace is always non-null 17/88117/2
Robert Varga [Fri, 28 Feb 2020 06:20:08 +0000 (07:20 +0100)]
QName namespace is always non-null

Simplify QName.toString() by realizing the namespace is guaranteed
to be non-null.

Change-Id: I06d2ab019fe9a9542e4ca3114235af6b6db42db1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoAdd inject annotations 24/87924/1
Robert Varga [Thu, 20 Feb 2020 07:45:15 +0000 (08:45 +0100)]
Add inject annotations

Add @Singleton to activation factories, so that they get
recognized by DI frameworks.

Change-Id: Ic7955fc712946a1477512416c84ac2c97e6ae5ad
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoSplit processStatement a bit more 86/87786/1
Robert Varga [Thu, 13 Feb 2020 16:18:29 +0000 (17:18 +0100)]
Split processStatement a bit more

Split out the slow path (of allocating a statement) into a separate
method, so that the main entrypoint is more easily inlineable.

JIRA: YANGTOOLS-652
Change-Id: Iccae60e336915e06d64731e3fe4aa278cba90996
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoSplit StatementContextVisitor.processStatement() 85/87785/1
Robert Varga [Thu, 13 Feb 2020 10:38:30 +0000 (11:38 +0100)]
Split StatementContextVisitor.processStatement()

This method is needlessly large and directly-recursive. Split it
up into two methods, allowing both to be smaller.

JIRA: YANGTOOLS-652
Change-Id: Ie3aab06cf66e8423a03fab6debebde7efbfcb2c1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoTurn ArgumentContextUtils into an abstract class 84/87784/1
Robert Varga [Thu, 13 Feb 2020 02:54:28 +0000 (03:54 +0100)]
Turn ArgumentContextUtils into an abstract class

Having this as a non-enum is actually better, as we can defer
loading of version-specific subclasses as needed.

JIRA: YANGTOOLS-1079
Change-Id: Ie6024b9f551823cf8f3ac5b51d2563c0c816ab36
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoSeparate out ArgumentContextUtils.normalizeDoubleQuoted() 83/87783/1
Robert Varga [Thu, 13 Feb 2020 00:31:42 +0000 (01:31 +0100)]
Separate out ArgumentContextUtils.normalizeDoubleQuoted()

appendString() is really just a lexer-to-logic dispatch method,
which we may end up moving. Even if not, it provides benefits
in being small and well auditable, as well as being readily
inlineable.

A nice side-effect here is that we get the control over both
whitespace and unescaping, which makes it obvious we can check
for existing escapes and then go into dealing with them, with
a known position of the first backslash.

JIRA: YANGTOOLS-1079
Change-Id: I157795634eb6caea10a819feb4a50fb9b394b267
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoOptimize ArgumentContext parsing 82/87782/1
Robert Varga [Wed, 12 Feb 2020 22:10:25 +0000 (23:10 +0100)]
Optimize ArgumentContext parsing

Looking for strings is overly-pessimistic, as it forces allocation
of an intermediate list -- which we do not need, as we really want
to just invoke our method on appropriate methods.

Furthermore IDENTIFIER tokens are much more common than STRING, so
we want to make the decision for the correct codepath without any
bias -- and a switch statement does exactly that.

On top of that IDENTIFIER tokens do not need any further processing,
we just short-circuit to returning the token string.

JIRA: YANGTOOLS-1079
Change-Id: Ia1bf7e39d35b16b2e68f4f132cd14d60ce89492e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRefactor ArgumentContextUtils 81/87781/1
Robert Varga [Wed, 12 Feb 2020 21:21:19 +0000 (22:21 +0100)]
Refactor ArgumentContextUtils

This is a static utility class, whose behavior depends on YANG
version. Refactor it into an enum, which expresses the differences
in terms of two separate subclasses, so that JIT can make the right
decisions.

Also mark spots for follow-up improvements.

JIRA: YANGTOOLS-1079
Change-Id: I1bc1dad7c0a313065d32174578ccbe941a9f3e3a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoCheck for existence of slash before trimming 80/87780/1
Robert Varga [Tue, 7 Jan 2020 16:29:45 +0000 (17:29 +0100)]
Check for existence of slash before trimming

Rather than creating multiple matchers for no good reason at all,
check if the string contains a backslash character before going
in and performing escaping.

JIRA: YANGTOOLS-652
Change-Id: I77fb02bad4ffb13a8393956c56b15ebe3e1dbf3f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoMove SourceSpecificContext.lookupDeclaredChild() 79/87779/1
Robert Varga [Thu, 13 Feb 2020 12:24:57 +0000 (13:24 +0100)]
Move SourceSpecificContext.lookupDeclaredChild()

This method is only used from StatementContextWriter and it is
not touching any SourceSpecificContext state. Move it to its sole
caller as a private method returning a nullable.

JIRA: YANGTOOLS-652
Change-Id: Ib05581b2edcca213734748e31d17d0b7caeb9a92
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoDo not try to finish already completed phase 78/87778/1
Robert Varga [Fri, 14 Feb 2020 10:49:36 +0000 (11:49 +0100)]
Do not try to finish already completed phase

Profiling shows that completion of substatement phases is the most
expensive operation we are performing. This stems from the fact
that inference is reactive and eager -- hence at we can attempt
to complete a particular phase against a statement multiple times.

Each time we will end up also walking all children (and their
children), attempting to complete the phase -- even when a particular
child has already successfully completed it.

This exposes a slight issue in our logic, as we have always assumed
child statements need to go through all the phases with us -- which
has not been true due to 'typedef' statements reuse, which would
end up being churned through phase complete (but always end with
EFFECTIVE_MODEL completed).

Fix both issues by checking whether the statement has executed
requested (or a subsequent) phase before going into actual phase
execution. This also requires that any substatements added to
a statement transition to the parent's completed phase before they
are made visible -- otherwise we could could end up with a statement
tree whose root has completed EFFECTIVE_MODEL, but not all of its
substatements have, triggering state violation assertions.

JIRA: YANGTOOLS-1082
Change-Id: Id6ed0d7feefc6d838c055e9690db69ae26633d95
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoSplit up tryToCompletePhase() 77/87777/1
Robert Varga [Fri, 14 Feb 2020 09:52:07 +0000 (10:52 +0100)]
Split up tryToCompletePhase()

This method is incredibly hot, split it up so that it is easier
to optimize as well as profile.

JIRA: YANGTOOLS-652
Change-Id: I3f87a00061c5f45f80364de3ba1a249beaa25b7f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoEffectiveStatements track StatementContextBase 76/87776/1
Robert Varga [Fri, 14 Feb 2020 14:10:22 +0000 (15:10 +0100)]
EffectiveStatements track StatementContextBase

While StatementContextBase.effective is declared to hold Mutable
contexts, in reality it should only ever hold StatementContextBase
(or whatever is the lowest reactor base class).

Add explicit verification, allowing us to eliminate an instanceof
check in completeChildren().

JIRA: YANGTOOLS-1082
Change-Id: Ic25d056492dba49e2dd8042d3de9e79443369738
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoSplit onPhaseCompleted() 75/87775/1
Robert Varga [Fri, 14 Feb 2020 22:54:08 +0000 (23:54 +0100)]
Split onPhaseCompleted()

This is a hot method, hence we want to aid inlining as much as
possible. Profiling is also helped by separating callback logic
into a separate method.

JIRA: YANGTOOLS-652
Change-Id: I1ab80b50db131879326b3ae1de7e4746ede92071
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoTrim buildEffective() bytecode 74/87774/1
Robert Varga [Fri, 14 Feb 2020 22:55:40 +0000 (23:55 +0100)]
Trim buildEffective() bytecode

This method is hot as hell, let's make sure it's also as small as
possible to aid inlining.

Change-Id: I0540a7efac1037cabb49190eb55da9ad022bc9d2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoOptimize AbstractResumedStatement.buildDeclared() 73/87773/1
Robert Varga [Sat, 15 Feb 2020 02:25:40 +0000 (03:25 +0100)]
Optimize AbstractResumedStatement.buildDeclared()

Optimize bytecode size of buildDeclared() by off-loading actual
work to loadDeclared(). Improves inlining and improves tracing
visibility -- which shows that the cache has about 90% cach hit
rate.

Change-Id: If09d417ab5257bf6651b94da2506695a6ced0104
JIRA: YANGTOOLS-652
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRelease statement source upon Effective Model completion 68/87468/1
Robert Varga [Wed, 5 Feb 2020 19:50:53 +0000 (20:50 +0100)]
Release statement source upon Effective Model completion

Once we have an effective model, we do not need to access statement
source, hence we can let it be GC'd.

JIRA: YANGTOOLS-652
Change-Id: I5c7024c4709a7b97bf061cd5f02d923319378011
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoDo not expand schema tree values 83/87383/2
Robert Varga [Mon, 3 Feb 2020 03:02:11 +0000 (04:02 +0100)]
Do not expand schema tree values

When we are constructing a dataTree from a schemaTree, we do not want
to operate on the ImmutableMap result, as that results in the values
view being retained. This amounts to unnecessary overhead, as we
typically do not need this view and it should be materialized only
if it is needed.

JIRA: YANGTOOLS-652
Change-Id: I3d1d689366a48822324c442da184496d9c6d873b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRemove MinElements(Effective)StatementImpl 87/87387/1
Robert Varga [Mon, 3 Feb 2020 11:05:28 +0000 (12:05 +0100)]
Remove MinElements(Effective)StatementImpl

These classes are unused after refactor, remove them.

JIRA: YANGTOOLS-652
Change-Id: Id0792ed2476ae11b138817cb1f50acd1eb6841ae
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRefactor min-elements statement implementations 81/87381/1
Robert Varga [Mon, 3 Feb 2020 10:27:54 +0000 (11:27 +0100)]
Refactor min-elements statement implementations

Migrate MinElements(Effective)Statement to improve their memory
footprint.

JIRA: YANGTOOLS-652
Change-Id: Iddf0d2d61d304eadefbf4433d4bd8f731aa4cefa
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRefactor organization statement implementations 80/87380/1
Robert Varga [Mon, 3 Feb 2020 09:58:29 +0000 (10:58 +0100)]
Refactor organization statement implementations

Migrate Organization(Effective)Statement to improve their memory
footprint.

JIRA: YANGTOOLS-652
Change-Id: If677ade7943fa9dd1b2cc5b9ee216049a9c04145
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRemove unused statement implementations 35/87335/2
Robert Varga [Fri, 31 Jan 2020 16:08:42 +0000 (17:08 +0100)]
Remove unused statement implementations

These classes have been rendered unused, remove them.

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

4 years agoRefactor namespace implementation classes 34/87334/1
Robert Varga [Fri, 31 Jan 2020 15:52:15 +0000 (16:52 +0100)]
Refactor namespace implementation classes

Refactor our implementation classes, so that we lower their footprint.
Since we are in the area, also update argument parser so that it reports
illegal names through SourceException.

Change-Id: I88c154cac3b6397434356304ba5af09aee984246
JIRA: YANGTOOLS-1065
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRefactor fraction-digits implementation classes 33/87333/1
Robert Varga [Fri, 31 Jan 2020 13:20:15 +0000 (14:20 +0100)]
Refactor fraction-digits implementation classes

Refactor our implementation classes, so that we end up sharing
declared/effective instances as much as possible.

JIRA: YANGTOOLS-1065
Change-Id: I2bdf8d30f9d2fd734a536001906b1f6f0af09f41
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoPopulate SubmoduleEffectiveModule with import namespaces 23/87323/1
Robert Varga [Sun, 19 May 2019 19:39:47 +0000 (21:39 +0200)]
Populate SubmoduleEffectiveModule with import namespaces

In case we are exporting a submodule, we need to find matching
imports -- just as they are constructed for ModuleEffectiveStatement.

This is then used in YangTextSnippet with appropriate resolver,
adding an explicit test.

JIRA: YANGTOOLS-992
Change-Id: Ie86cd8ff50f598fe1868f576f9f7e5a8ab2e5c5d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoEnable spotbugs in yang-model-export 22/87322/1
Robert Varga [Thu, 22 Aug 2019 12:44:39 +0000 (14:44 +0200)]
Enable spotbugs in yang-model-export

SpotBugs is getting confused by our use of checkArgument, not
understanding we will catch nulls. Refactor the code removing
the violation and remove enforcement override.

Change-Id: I787359c01f2761448cb4f3d33aea0baf5e642ed8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoMark AbstractListStatementSupport methods final 19/87319/1
Robert Varga [Fri, 31 Jan 2020 10:25:53 +0000 (11:25 +0100)]
Mark AbstractListStatementSupport methods final

These mathods are intended to be final, mark them as such.

Change-Id: I69f1b217a3cde0db658234643649bfef1d5672f9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>