mdsal.git
4 years agoFix string duplication in Ipv6Utils 97/83697/1
Robert Varga [Fri, 16 Aug 2019 11:40:52 +0000 (13:40 +0200)]
Fix string duplication in Ipv6Utils

This is minor code smell, create a method to concentrate common
functionality.

Change-Id: I32fb6c5c29a099885413cf18361e53098593054e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoEliminate 'txt' temporary 87/83687/1
Robert Varga [Thu, 15 Aug 2019 11:29:15 +0000 (13:29 +0200)]
Eliminate 'txt' temporary

This variable is not really needed and the way it is used SpotBugs
reports a (valid) dead local store. Eliminate the variable completely.

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

4 years agoDo not include byte-buddy META-INF in shade 78/83678/2
Robert Varga [Thu, 15 Aug 2019 12:23:33 +0000 (14:23 +0200)]
Do not include byte-buddy META-INF in shade

We do not want to leak module-info.class from byte-buddy, hence
filter all of its META-INF, as it does not provide anything of
value.

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

4 years agoFix use of StringTokenizer methods 70/83670/1
Robert Varga [Thu, 15 Aug 2019 11:21:56 +0000 (13:21 +0200)]
Fix use of StringTokenizer methods

Rather than using Enumeration-related methods (*Element()), use
the methods provided by StringTokenizer (*Token()), which have
the same functionality, but are not down-casted to Object.

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

4 years agoMake AlphabeticallyTypeMemberComparator Serializable 69/83669/1
Robert Varga [Thu, 15 Aug 2019 11:07:20 +0000 (13:07 +0200)]
Make AlphabeticallyTypeMemberComparator Serializable

Comparators are recommended to be serializable, this fulfills
the need.

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

4 years agoFix SpotBugs complaing around locale 68/83668/1
Robert Varga [Thu, 15 Aug 2019 11:05:50 +0000 (13:05 +0200)]
Fix SpotBugs complaing around locale

We are using english locale, which should work across the platform.

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

4 years agoFix InterfaceTemplate documentation 67/83667/1
Robert Varga [Thu, 15 Aug 2019 11:04:26 +0000 (13:04 +0200)]
Fix InterfaceTemplate documentation

InterfaceTemplate will fail to instantiate with a NPE if a null
type is ever passed in. Fix documentation and remove dead code.

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

4 years agoBump versions to 4.0.5-SNAPSHOT 43/83643/1
Robert Varga [Thu, 15 Aug 2019 06:22:59 +0000 (08:22 +0200)]
Bump versions to 4.0.5-SNAPSHOT

This starts the next development iteration.

Change-Id: I844a1b877546024657287839ec4a5464d9ed192d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoOptimize whitespace replacement 00/83600/2
Robert Varga [Tue, 6 Aug 2019 15:27:33 +0000 (17:27 +0200)]
Optimize whitespace replacement

Rather than doing two replacements, use a single two-character
matcher and a single replacement pass. While we're in the area,
also create a SPACE constant and use it where we mean ' ' as a
char (not a string).

Change-Id: I30d7c16074fe172a834ecf1bb0fe30a18fdc6bac
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoUse bulk-close for internal registrations 25/83625/3
Robert Varga [Wed, 14 Aug 2019 14:49:59 +0000 (16:49 +0200)]
Use bulk-close for internal registrations

Rather than using wrapped registrations through the public API,
we really want to first remove all modules and then update the
context (if needed).

JIRA: MDSAL-466
Change-Id: Ib281fff7264b3dd11b222095f8286087cb488002
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoDisable updates when we are stopping 59/83559/4
Robert Varga [Tue, 6 Aug 2019 17:48:05 +0000 (19:48 +0200)]
Disable updates when we are stopping

We should not be propagating bundle updates when we know we are
stopping. This patch marks that knowledge in the tracker.

JIRA: MDSAL-466
Change-Id: Ie4e8b96907a8909150b4080000888d1d10ce8e54
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoDo not lose newlines/tabs from javadoc 30/83430/2
Robert Varga [Tue, 6 Aug 2019 14:24:44 +0000 (16:24 +0200)]
Do not lose newlines/tabs from javadoc

When we are formatting javadoc for a accessor method, we must treat
any newlines/tabs as whitespace and not lose them, otherwise we would
end up with concatenated words.

JIRA: MDSAL-416
Change-Id: I3c0fc296692a141d6787a5cba8b17738a108274e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoFix curly braces 89/83489/2
Robert Varga [Tue, 6 Aug 2019 12:24:20 +0000 (14:24 +0200)]
Fix curly braces

These anonymous classes should be properly spelled out, as should
private constructors.

Change-Id: I314c92660703e68019da0562172ce3e9519ce882
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoReduce use of java.lang constructors 33/83433/2
Robert Varga [Tue, 6 Aug 2019 12:12:19 +0000 (14:12 +0200)]
Reduce use of java.lang constructors

Long/Integer constructors have been deprecated, reduce their use.

Change-Id: I2ce4e63904694d3fe442622b85d831253b4a87fb
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoFix bad javadoc license headers 34/83434/2
Robert Varga [Mon, 5 Aug 2019 14:20:31 +0000 (16:20 +0200)]
Fix bad javadoc license headers

License headers should not be javadocs, fix that up.

Change-Id: I6496008bfa2e8d227de8bb2aab0b2888c3ffed83
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoFixup cast in BindingReflections 32/83432/2
Robert Varga [Tue, 6 Aug 2019 11:37:54 +0000 (13:37 +0200)]
Fixup cast in BindingReflections

Use an explicit typed Class instead of raw class.

Change-Id: I613d81fc3162ee3bea4955aa2afacf728e2cfab6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoFix checkstyle in javadocs 35/83435/1
Robert Varga [Tue, 6 Aug 2019 11:29:45 +0000 (13:29 +0200)]
Fix checkstyle in javadocs

Updated checkstyle is catching more violations, fix them up.

Change-Id: I1048fea86966113184fe49fe707d6d0d328c3508
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoUse refcounting to lower the number of registrations 18/83418/1
Robert Varga [Mon, 29 Jul 2019 11:09:13 +0000 (13:09 +0200)]
Use refcounting to lower the number of registrations

The fix for MDSAL-461 has introduced multiple registrations for
each YangModuleInfo, which while correct ends up parsing the same
sources multiple times.

This patch updates the handling to guard against that possibility
by adding an explicit reference counting layer, so that each
instance of YangModuleInfo is registered exactly once.

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

4 years agoBump versions to 4.0.4-SNAPSHOT 98/83298/1
Robert Varga [Mon, 29 Jul 2019 11:12:07 +0000 (13:12 +0200)]
Bump versions to 4.0.4-SNAPSHOT

This starts the next development iteration.

Change-Id: I168f77460463cc5a50521f60bdf79a1e802c0f4a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoBump yangtools to 3.0.4 97/83297/1
Robert Varga [Mon, 29 Jul 2019 11:11:34 +0000 (13:11 +0200)]
Bump yangtools to 3.0.4

We have validated yangtools-3.0.4, bump to the release version.

Change-Id: Ib56bb6b87e8fd8609d86b310a74fde7f491449c3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRemove YangModuleInfo when it is unregistered 71/83071/12
Robert Varga [Tue, 23 Jul 2019 13:47:22 +0000 (15:47 +0200)]
Remove YangModuleInfo when it is unregistered

This patch addresses a FIXME, which was left in the code base
and thus makes sure we do not retain stale class loaders from
explicit registrations.

Unfortunately the design of this class mixes quite a few aspects:
- the ability to build SchemaContext
- the ability to explicitly register YangModuleInfos (with their
  dependencies)
- the ability to implicitly register YangModuleInfos through
  ClassLoadingStrategy.loadClass() failure path
- the ability to create an instance with pre-populated set of entries
  used only for testing/static purposes

The interplay between these aspects is ill-defined, especially
items 2 and 3, hence fixing the issue in most correct way possible
requires redesigning internal state tracking, explicitly
differentiating between the two cases.

JIRA: MDSAL-461
Change-Id: I8f99d3975e971e32b267788a463d9b73bb57e49e
Signed-off-by: Jie Han <han.jie@zte.com.cn>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoExpose IdentityCodec from BindingCodecTree 56/83256/16
Robert Varga [Thu, 25 Jul 2019 19:37:14 +0000 (21:37 +0200)]
Expose IdentityCodec from BindingCodecTree

Transcoding identities is needed to make sense of yangtools
identifiers (such as DatastoreIdentifier) versus binding classes.

Expose this functionality as BindingIdentityCodec from
BindingCodecTree and make use of it.

JIRA: MDSAL-460
Change-Id: I8b4110dd711eb18a2586fd1bd036d09fab13871a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoAdd yanglib-rfc8525 52/83252/20
Robert Varga [Thu, 25 Jul 2019 14:04:28 +0000 (16:04 +0200)]
Add yanglib-rfc8525

This adds the necessary support for constructing mount points
described through RFC8525 (NMDA) YANG Library.

JIRA: MDSAL-463
Change-Id: I22b4449f544e3d0225bac59fa3928ecb434f8f13
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoAdd a yanglib component 49/83249/13
Robert Varga [Wed, 24 Jul 2019 21:08:51 +0000 (23:08 +0200)]
Add a yanglib component

This adds the basic bridging between YANG Library and yangtools,
along with RFC7895 (non-NMDA) implementation. This allows schema
mounts described through RFC7895 to be parsed, when the provided
MountPointContextFactory implementation is fed into the parsers.

JIRA: MDSAL-464
Change-Id: I8092dd874648a4d115a5c16c3bbbbbc2b906419e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoBump yangtools to 3.0.4-SNAPSHOT 48/83248/2
Robert Varga [Thu, 25 Jul 2019 10:11:27 +0000 (12:11 +0200)]
Bump yangtools to 3.0.4-SNAPSHOT

This adopts yangtools-3.0.4 for the improvements made to rfc8528
support infrastructure.

Change-Id: Ic51134f1abdf8120a9071b4aeff7a054c707d941
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoUse checkState() in ModuleInfoBackedContext 09/83209/1
Robert Varga [Tue, 23 Jul 2019 12:03:43 +0000 (14:03 +0200)]
Use checkState() in ModuleInfoBackedContext

This simplifies the code a bit, by performing a checkState()
instead of explicit if/throw.

Change-Id: I1479c664a0f2c68585648df7ef9f3275aed16329
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoDecrease try-catch block size 07/83207/1
Robert Varga [Tue, 23 Jul 2019 10:33:23 +0000 (12:33 +0200)]
Decrease try-catch block size

We do not want to cover the registration process in (catch Exception),
as that will mask other failures.

Change-Id: I7942e5be1671b396a7daca117538e4d275d604cb
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRemove trailing semicolons 98/83198/1
Robert Varga [Mon, 22 Jul 2019 13:21:48 +0000 (15:21 +0200)]
Remove trailing semicolons

These are throwing off sonar, remove them to keep it happy

Change-Id: I2cd19e34825916721512f956bcfc678953ebfb6f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoReorganize ModuleInfoBackedContext 92/83092/1
Robert Varga [Thu, 18 Jul 2019 09:08:30 +0000 (11:08 +0200)]
Reorganize ModuleInfoBackedContext

This is just a shuffle of methods, cleaning up the structure
of the file, making things more discoverable.

JIRA: MDSAL-461
Change-Id: Ibf80248cd91880cc0169e1d9a86eb6a95b2f7860
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoUse ActionNodeContainer.findAction() 48/82948/4
Robert Varga [Mon, 8 Jul 2019 09:21:40 +0000 (11:21 +0200)]
Use ActionNodeContainer.findAction()

This removes custom-coded lookup in favor of the common utility
method.

Change-Id: Ib2524b9bc8ef0a650dd1b78d694c250dffaae893
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoBump yangtools to 3.0.3 95/82895/4
Robert Varga [Fri, 21 Jun 2019 05:16:48 +0000 (07:16 +0200)]
Bump yangtools to 3.0.3

This picks up the latest yangtools release.

Change-Id: I5baeb81e3d947ba30f887ffd17ea437ec5f51fd3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoAdd rfc8525 to docs 84/83084/1
Robert Varga [Thu, 18 Jul 2019 05:39:10 +0000 (07:39 +0200)]
Add rfc8525 to docs

Previous patch omitted adding the new artifact to docs, fix that.

JIRA: MDSAL-462
Change-Id: I48e3f66e9d261f624c66a12ceb13856e0edab3cd
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoAdd RFC8525 ietf-yang-library model 80/83080/2
Robert Varga [Wed, 17 Jul 2019 15:54:47 +0000 (17:54 +0200)]
Add RFC8525 ietf-yang-library model

This is a NMDA-updated version of the model.

JIRA: MDSAL-462
Change-Id: Id82bf47439b6c726f352e3fa8a5628a88ec70b96
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoBump byte-buddy to 1.9.14 66/82966/1
Robert Varga [Mon, 8 Jul 2019 19:04:06 +0000 (21:04 +0200)]
Bump byte-buddy to 1.9.14

https://github.com/raphw/byte-buddy/releases/tag/byte-buddy-1.9.13
https://github.com/raphw/byte-buddy/releases/tag/byte-buddy-1.9.14

Change-Id: Ibef83b93b914945f48902ad54df822a656d41df2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRemove unneeded null check 46/82946/1
Robert Varga [Mon, 8 Jul 2019 09:24:06 +0000 (11:24 +0200)]
Remove unneeded null check

We are performing a null and an instanceof check, where the latter
can also serve as a a null check. Remove the explicit null check.

Change-Id: Iac43aae00d8832cb7ade2f45041375451d5bedf4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRemove unneeded temporary variables 45/82945/1
Robert Varga [Mon, 8 Jul 2019 09:16:24 +0000 (11:16 +0200)]
Remove unneeded temporary variables

getRpcs/getNotifications() result is only ever iterated over,
we do not need a full Set.

Change-Id: If066a9cbdba098116a3e8aa1a22b0ff05bf35df4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoMark API bundles with Automatic-Module-Name 22/82922/3
Robert Varga [Wed, 3 Jul 2019 23:04:38 +0000 (01:04 +0200)]
Mark API bundles with Automatic-Module-Name

This patch updates core API packages to interact with JPMS, so
that they become automatic modules.

Change-Id: I9aa2f7dd7a82c9d7eaf4080d541db19991446da4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoMake LogicalDatastoreType a WritableObject 21/82921/3
Robert Varga [Wed, 3 Jul 2019 22:37:53 +0000 (00:37 +0200)]
Make LogicalDatastoreType a WritableObject

This is a low-cardinality enum, which we need to serialize quite
often. Make it a simple WritableObject, so users can get common
handling. One specific user is sal-remoterpc-connector, which
needs to be able to serialize DOMDataTreeIdentifier.

JIRA: CONTROLLER-1894
Change-Id: Iee4610e093639629039a2e21ab1cfc852b756169
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoBump odlparent to 5.0.1 94/82894/1
Robert Varga [Fri, 21 Jun 2019 05:16:10 +0000 (07:16 +0200)]
Bump odlparent to 5.0.1

This picks up the latest odlparent release.

Change-Id: I72ce6fda88b8acf51e534e8366b590ae66cd8de4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoFix augmented action code generation 87/82887/2
Robert Varga [Tue, 2 Jul 2019 11:49:06 +0000 (13:49 +0200)]
Fix augmented action code generation

When an action is introduced as part of an augment statement, we
attempt to generate it in the augmented module, which refuses to
generate its input/output statements, leading to a NPE.

This patch updates codegen to ignore augmenting actions in the
augmented module and process them as part of augmentation.

JIRA: MDSAL-459
Change-Id: Ibd7d7abc5ec1eec6d32ee1885da00a0de69b2445
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoResolve bits/union nested type naming 44/82744/3
Robert Varga [Tue, 25 Jun 2019 13:07:06 +0000 (15:07 +0200)]
Resolve bits/union nested type naming

The cases where we allocate an enumeration, bits or union type
for a leaf-like construct (leaf, leaf-list) need to handle an
edge case -- JLS does not allow nested classes to be named the
same as the enclosing class.

Enumeration case was already handled in
AbstractGeneratedTypeBuilder, this patch extends that support
to handle bits and union.

JIRA: MDSAL-458
Change-Id: Idc19b179274c7973ed205ffdae1d2242cbd2dbf6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRemove unused Matcher 43/82743/2
Robert Varga [Wed, 26 Jun 2019 11:20:33 +0000 (13:20 +0200)]
Remove unused Matcher

DOT_MATCHER is not used anywhere, remove it.

Change-Id: Ibc9cbdab0d9008cfd63522db951c93843ea20a66
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoReuse SUCCESS_FUTURE 88/82688/2
Robert Varga [Mon, 24 Jun 2019 15:36:40 +0000 (17:36 +0200)]
Reuse SUCCESS_FUTURE

Rather than allocating new temporary objects reuse a constant
we have handy.

Change-Id: I3b27eb1cc75c967e4f880e2c5f287c040276f674
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRemove use of getKeyValues() 81/82681/2
Robert Varga [Mon, 24 Jun 2019 10:32:26 +0000 (12:32 +0200)]
Remove use of getKeyValues()

This adjusts callers of deprecated method, fixing warnings and
allowing better integration in future.

Change-Id: I6f5bb82af22cfa94e7c532f596c813058b3511d4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoModuleInfoBackedContext cache 79/82679/1
Robert Varga [Mon, 24 Jun 2019 09:21:26 +0000 (11:21 +0200)]
ModuleInfoBackedContext cache

ModuleInfoBackedContext can be effectively cached based on
the set of class loading strategy and infos that go into it. This
patch adds such a cache.

JIRA: MDSAL-418
Change-Id: Icbb7ac5270c76c374a6e839010090a002b0ab176
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoMigrate ModuleInfo cache to BindingReflections 72/82672/3
Robert Varga [Sun, 23 Jun 2019 21:54:34 +0000 (23:54 +0200)]
Migrate ModuleInfo cache to BindingReflections

Reflections are using a cache already, so adding another one does
not really hurt. This allows code reuse between our test suite
and downstreams.

JIRA: MDSAL-418
Change-Id: Id4474a0754f33b880afaff333279969f947df494
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoAdd CDI annotations to mdsal-binding-dom-adapter 88/79888/18
Michael Vorburger [Thu, 24 Jan 2019 21:47:07 +0000 (22:47 +0100)]
Add CDI annotations to mdsal-binding-dom-adapter

This annotates core classes, so they can be used via CDI.

JIRA: MDSAL-418
Change-Id: Ia943dd10cad35481ef742400c79491c1d092c6c7
Signed-off-by: Michael Vorburger <vorburger@redhat.com>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoFlatten submodule hierarchy for YangModuleInfo 70/82470/4
Anna Bencurova [Mon, 10 Jun 2019 12:55:49 +0000 (14:55 +0200)]
Flatten submodule hierarchy for YangModuleInfo

YANG inherently contains modules and submodules, where submodules
do not really have further submodules. While YANG 1.0 allowed
inclusion of submodules in other submodules, and that is modeled
in yang-model-api, this practice has been deprecated with YANG 1.1.

If we are faced with multiple such includes, for example both
module and submodule including a second submodule, we could end up
generating superfluous classes, just to represent the second
submodule twice (once for module's purposes and once for submodule's
purposes) -- hence when all of them are collected recursively, we
would end up with two distinct instances for the same source.

Since submodules are not directly visible outside of the main class,
this hierarchy is not public API and is a purely internal thing.

This patch re-organizes generation so that we present all submodules
as dependencies of the main module, which automatically solves the
problem, while also making for nicer class layout, as we do not get
multiply-nested classes.

JIRA: MDSAL-457
Change-Id: Ic78edaf852f3497f3c4c96fdca3a77de30b7f8c1
Signed-off-by: Anna Bencurova <Anna.Bencurova@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoFix superfluous warning 59/82559/2
Robert Varga [Tue, 18 Jun 2019 20:07:54 +0000 (22:07 +0200)]
Fix superfluous warning

We can end up warning about choices which are not cached, just
because we have a miss. Fix this up so that we properly handle
rejected caching.

Change-Id: I90589e50a749c65226a1e174409e9fd744d7bc30
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoCheck registration being closed 37/82537/1
Robert Varga [Tue, 30 Apr 2019 03:35:41 +0000 (05:35 +0200)]
Check registration being closed

Check if the registration has been closed before firing events.
This way we stop delivering events a bit sooner, improving shutdown
speed and correctness.

JIRA: MDSAL-429
Change-Id: I533f2b07e8cd14597c29d2d3d9c11c44a1bb7ff5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoBump yangtools to 3.0.2 95/82495/1
Robert Varga [Wed, 12 Jun 2019 00:44:37 +0000 (02:44 +0200)]
Bump yangtools to 3.0.2

The release brings a number of improvements, bring it in.

Change-Id: I1bbbb09cea86f1d73119ae3948dba4f9e362a485
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoBump versions to 4.0.3-SNAPSHOT 55/82355/2
Robert Varga [Fri, 31 May 2019 14:06:54 +0000 (16:06 +0200)]
Bump versions to 4.0.3-SNAPSHOT

This starts the next development iteration.

Change-Id: I8220119b4898fbc8c6a49d13eac79f4080c729e4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoUse cached AugmentationIdentifiers in BindingRuntimeContext 52/82352/2
Robert Varga [Fri, 31 May 2019 10:55:50 +0000 (12:55 +0200)]
Use cached AugmentationIdentifiers in BindingRuntimeContext

AugmentationIdentifiers allocated from BindingRuntimeContext
end up being used across the system. This ensures we squash
instances to system-wide cache.

Change-Id: I0d75dc8815f86cb1dda13ef118ceb9b6455a31e3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoImprove getResolvedAugmentationSchema() 51/82351/1
Robert Varga [Fri, 31 May 2019 10:11:08 +0000 (12:11 +0200)]
Improve getResolvedAugmentationSchema()

This method is used for instantiating prototypes, from whence
it is used all over the place. Sharing a single instance allows
us to slightly improve lookups.

Change-Id: I93eb21ef83aef80ab0f26614950ebb042a7473ed
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoDo not use NodeIdentifierWithPredicates constructors 50/82350/1
Robert Varga [Fri, 31 May 2019 10:02:14 +0000 (12:02 +0200)]
Do not use NodeIdentifierWithPredicates constructors

This migrates all callers to use the static factory methods.

Change-Id: I36f983fb14c9ee61ddcfc152b7f9e106b9178624
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoBump yangtools to 3.0.1 48/82348/1
Robert Varga [Fri, 31 May 2019 08:18:36 +0000 (10:18 +0200)]
Bump yangtools to 3.0.1

Pull in the release yangtools version.

Change-Id: I00061f0f724472606489061a72dab61bcd0ad531
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoAllow using ImmutableLists when returning binding objects 84/81884/7
Robert Varga [Thu, 2 May 2019 19:48:03 +0000 (21:48 +0200)]
Allow using ImmutableLists when returning binding objects

The general contract of MD-SAL is that we do not leak mutable
collections, as that leads to concurrency issues and provides
an avenue for inconsistencies leaking in.

Unfortunately we have had three offenders, which were using
plain ArrayLists to represent data -- and thus could be used
to subvert our efforts.

This patch adds the ability to use proper ImmutableLists, so that
the data they produce is truly immutable. This also helps footprint
of single-value lists, as those are squashed to a more efficient
implementation.

The default remains the use of mutable lists, but the immutable
versions can be activated through setting system property

org.opendaylight.mdsal.binding.dom.codec.impl.compat-mutable-lists

The property acts as an opt-out, i.e. it is in effect unless it is
specifically set to "false"

JIRA: MDSAL-446
Change-Id: I9d7ebab827314b66539534f8d8200a64ee9b4aff
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoAdd binding support for anydata nodes 39/82239/5
Robert Varga [Fri, 24 May 2019 15:42:43 +0000 (17:42 +0200)]
Add binding support for anydata nodes

These nodes are following essentially the same blueprint as
anyxml nodes. Unlike anyxml nodes, we need specific implementation
support to allow streaming the nodes.

JIRA: MDSAL-438
Change-Id: I7ff081c58a9e5198762c67cbb908beec0bae144b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoBump yangtools to 3.0.1-SNAPSHOT 57/82257/2
Robert Varga [Mon, 27 May 2019 19:04:05 +0000 (21:04 +0200)]
Bump yangtools to 3.0.1-SNAPSHOT

Preliminary bump of yangtools to 3.0.1, allowing us to take
advatage of incoming interfaces.

Change-Id: Ia3b16e1fd57bffc665c1527eb9153fd2cb87f042
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoAdd a simplified SimpleDOMActionResult constructor 36/82236/1
Robert Varga [Fri, 24 May 2019 14:59:11 +0000 (16:59 +0200)]
Add a simplified SimpleDOMActionResult constructor

If the user is not providing any errors, it should be a fair
game to provide just the value.

Change-Id: Iac7e5133fbe09f0e50d72597530b520778d341f5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoGroupingDefinitionDependencySort needs to consider actions 86/82086/2
Robert Varga [Wed, 15 May 2019 12:01:19 +0000 (14:01 +0200)]
GroupingDefinitionDependencySort needs to consider actions

In order to be able to correctly process actions/notifications
which can refer to other groupings, we must properly sort them
within each module.

To do that, GroupingDefinitionDependencySort must consider
uses nodes within them to properly construct the dependency
graph.

JIRA: MDSAL-448
Change-Id: I627702e39b1ab235b1c77ceaa2717ee03b3b2e39
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoDo not issue immediate build when looking up grouping 83/82083/1
Robert Varga [Wed, 15 May 2019 11:52:34 +0000 (13:52 +0200)]
Do not issue immediate build when looking up grouping

If we fail to find a grouping, we will end up with a NPE which
does not provide any information. Move the .build() call so that
the proper ISE kicks in.

JIRA: MDSAL-448
Change-Id: I57d6a74074b49def9bbc814732cfc48cd5265072
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoFix two typos 99/81999/1
Robert Varga [Sat, 11 May 2019 10:00:43 +0000 (12:00 +0200)]
Fix two typos

A simple comment typo and a mistakenly-private constructor.

Change-Id: Iea4d40c23c0a1141c90c7bdbc2ab70cafed689af
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoTake advantage of AbstractAugmentable 51/81851/18
Robert Varga [Wed, 1 May 2019 14:34:35 +0000 (16:34 +0200)]
Take advantage of AbstractAugmentable

Rather than hand-rolling Augmentable implementations, take advantage
of AbstractAugmentable as the holder of augmentations -- reducing
the amount of generated code.

Since this leads to generated code not being exposed to augmentation(),
we can now rename the generic argument there to a full-compliant
name.

JIRA: MDSAL-445
Change-Id: I2459489074e9e50e82bd9d1c8eb051f9833b7a0b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoBump version for 4.0.2-SNAPSHOT 77/81977/1
Robert Varga [Fri, 10 May 2019 05:12:33 +0000 (07:12 +0200)]
Bump version for 4.0.2-SNAPSHOT

This starts the next development cycle.

Change-Id: If2604811deaf39ce6258d278299b1b1804f39dc8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoAllow SnapshotBackedReadTransaction customization 43/81943/6
Robert Varga [Tue, 7 May 2019 13:03:57 +0000 (15:03 +0200)]
Allow SnapshotBackedReadTransaction customization

In some specific cases we need to customize abort-like handling,
which is already implemented for write-like transactions, but is
not present for read-only transaction.

This patch adds the capability to attach a close() handler and
makes sure AbstractSnapshotBackedTransactionChain takes advantage
of it.

JIRA: CONTROLLER-1879
Change-Id: Ic7027956556b5dd25120ee81613a6151e5dbc501
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoExclude byte-buddy from features 42/81942/1
Robert Varga [Tue, 7 May 2019 12:34:24 +0000 (14:34 +0200)]
Exclude byte-buddy from features

While shade-plugin installs a dependency-reduced pom.xml, maven
does not see that but rather the original, hence we need to
explicitly exclude byte-buddy so as not to leak it.

JIRA: MDSAL-444
Change-Id: I58e6a22b94cc46ebfff7c9fe63ffaf135971da71
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoDo not compare NormalizedNodes in CodecDataObject 30/81930/3
Robert Varga [Tue, 7 May 2019 08:58:24 +0000 (10:58 +0200)]
Do not compare NormalizedNodes in CodecDataObject

Binding DTOs can be shared across instantiations -- for example
groupings. If we are comparing different instantiations, they
can have different namespaces and thus NormalizedNodes do not
compare as equal -- but Binding considers them equal.

JIRA: MDSAL-442
Change-Id: I9838692a046045b3a7e520bd363bfe54b94a6e66
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoMake sure mdsal-eos-dom-simple activates 32/81932/2
Robert Varga [Tue, 7 May 2019 09:53:02 +0000 (11:53 +0200)]
Make sure mdsal-eos-dom-simple activates

Controller packaging of local components requires that the single-node
EOS instance properly activates. This patch fixes that.

Change-Id: I7808c2f517b62c3627d4075fe201739707895923
JIRA: CONTROLLER-1584
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoRevert "Check registration being closed" 07/81907/2
Robert Varga [Mon, 6 May 2019 14:33:29 +0000 (16:33 +0200)]
Revert "Check registration being closed"

This reverts commit 819aef314ba0fc931ca46c0f39d4f70ff49d3540, as
it needs some more work downstream.

Change-Id: I2e98375990e7c5a3ce5bf2f97f31bf090d0f635f
JIRA: MDSAL-429
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoFix memory leak in BA mount service 98/81898/2
Robert Varga [Sun, 5 May 2019 18:15:19 +0000 (20:15 +0200)]
Fix memory leak in BA mount service

The cache used in BA mount service uses weakKeys() so the keys
(DOM mountpoint) could be GCed when no except cache, referenced
them).

However the values in the cache (BA mountpoint) also kept a reference
to the key, so the key was never weakly reachable and thus never GCed
resulting in a memory leak.

This is especially visible in case of frequent reconnects of netconf
mountpoints where after every reconnect a new DOM mountpoint is
created, requiring a new BA mountpoint creating new entry in the
cache of BA mount service.

This patch updates the entire suite of adapters, as it is shared
across all instances.

Change-Id: I9c109dd6d499d6185842d6a1ad5a59d75565af5c
Signed-off-by: Maros Marsalek <mmarsalek@frinx.io>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoAdd RFC8520 models 99/81899/1
Robert Varga [Sun, 5 May 2019 19:42:58 +0000 (21:42 +0200)]
Add RFC8520 models

This adds the models defined in RFC8520.

JIRA: MDSAL-430
Change-Id: I5a0100d63ee8d69934748c508ab46f16f828809d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoMove common bridging code 97/81897/1
Robert Varga [Sun, 5 May 2019 17:52:19 +0000 (19:52 +0200)]
Move common bridging code

Since we'll want to be bridging from multiple class generators,
move the common bridging code into a common interface.

JIRA: MDSAL-443
Change-Id: I1aa7d70ae302d737bb960c06629da5ffe0123fc0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoHide CodecDataObjectGenerator subclasses 95/81895/1
Robert Varga [Sun, 5 May 2019 17:31:33 +0000 (19:31 +0200)]
Hide CodecDataObjectGenerator subclasses

These classes should not be visible, hide them.

JIRA: MDSAL-443
Change-Id: I598c50d5de6e700e76988052d3e6747de933deb0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoBind CodecDataObject string instances 77/81877/2
Robert Varga [Thu, 2 May 2019 14:13:33 +0000 (16:13 +0200)]
Bind CodecDataObject string instances

Heap analysis of the classes we generated on top of CodecDataObject
indicates we have an unnecessarily-large class constant pool. This
boils down our usage of string constants we pass back to
CodecDataObject -- which are coming from QName, but are not guaranteed
to be interned.

Aside from increasing heap consumption, this has a downside of not
requiring deep string comparisons during lookup -- which we want to
avoid if at all possible.

This patch updates generation strategy to create explicit constant
fields, which are bound to direct references to Strings used in
QNames -- resulting in the same objects being used.

JIRA: MDSAL-442
Change-Id: I10ef4ae49525d3f45076260e9438863b5830cf9a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoDo not inline NodeContextSuppliers 67/81867/4
Robert Varga [Wed, 1 May 2019 20:46:04 +0000 (22:46 +0200)]
Do not inline NodeContextSuppliers

As it turns out, NodeContextSuppliers really need to be coming
from parent, as we can be rehosting objects into different
namespaces -- in which case a single object will need to be
interpreted in terms of the NodeContextSupplier in its parent,
i.e. with a different schema.

This patch undoes most of Iaf227e78d2b6546d34c2133fc31912c0a8dde4b3
and I9e24c30535c536d70b4eb60035b5aa744fc6ec9d, in that
NodeContextSuppliers are not inlined as constants, but rather
looked up.

Unlike the previous lookup by method name, we are using localName
and Class, just as we do in stremers and hence we are reusing
indices which support streamers.

The ability to inlike NodeContextSuppliers is retained, but since
DataObjectContext does not have enough information from
BindingRuntimeContext, this facility is not used.

JIRA: MDSAL-443
Change-Id: I82bff8657845bdab27aa3aa8c24a949c4758f1bb
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoOptimize DataObjectCodecContext memory footprint 72/81872/1
Robert Varga [Thu, 2 May 2019 10:27:58 +0000 (12:27 +0200)]
Optimize DataObjectCodecContext memory footprint

Examining heap dumps while working on MDSAL-442/MDSAL-443 revealed
a slight inefficiency in DataObjectCodecContext: we are forcing
byStreamClass's entrySet to be instantiated for the purposes of
copying it into byBindingArgClassBuilder.

This patch corrects the mistake by using byStreamClassBuilder
as the source of copied entries -- which holds the same content,
but we will be throwing it away.

Furthermore byStreamClass and byBindingArgClass are only distinct
when we have a choice child, hence we also run comparison on the
two builders and reuse byStreamClass if they are equal.

Change-Id: Ie58367f7cc899d49da7f78cd0d4e70fbb064ae99
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoFix raw type warnings in CodecDataObjectBridge 71/81871/1
Robert Varga [Thu, 2 May 2019 06:23:33 +0000 (08:23 +0200)]
Fix raw type warnings in CodecDataObjectBridge

CodecDataObjectGenerator is generic, use a wildcard type to prevent
raw type warnings.

JIRA: MDSAL-444
Change-Id: I1d8dffce449a7129e59cc3a70400056fd843b15c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoDefend against nulls in ValueContext 61/81861/2
Robert Varga [Wed, 1 May 2019 17:18:57 +0000 (19:18 +0200)]
Defend against nulls in ValueContext

We should never attempt to deserialize null values for keys,
defend against them.

Change-Id: I6439bb6ce22da11476cd4f8bd89e3ec04c05ba96
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoIntroduce AbstractAugmentable 50/81850/5
Robert Varga [Wed, 1 May 2019 14:29:00 +0000 (16:29 +0200)]
Introduce AbstractAugmentable

Binding generated code hand-implements handling of augmentations,
which leads to some amount of duplicated code, but notably a lot
of distinct implementations of Augmentatable.augmentation().

We can improve the situation by providing a simple base class which
holds an immutable map of augmentations implementing
AugmentationHolder and Augmentable interfaces.

JIRA: MDSAL-445
Change-Id: I693cd4fbec3d236f039e01448dc4994722b5582d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoDo not use ClassToInstanceMap in AugmentableCodecDataObject 53/81853/2
Robert Varga [Wed, 1 May 2019 15:05:46 +0000 (17:05 +0200)]
Do not use ClassToInstanceMap in AugmentableCodecDataObject

ImmutableClassToInstanceMap is implemented using delegation,
which means we end up allocating one more object than we really
need and are also adding an indirection.

Drop back to using a plain ImmutableMap, so as to reduce memory
pressure.

JIRA: MDSAL-442
Change-Id: I6832eb8f012a2d003d3a2158009305a09f6c7832
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoIgnore dependency-reduced-pom.xml 49/81849/2
Robert Varga [Wed, 1 May 2019 14:33:57 +0000 (16:33 +0200)]
Ignore dependency-reduced-pom.xml

dependency-reduced-pom.xml is created as part of the shading process,
make sure we ignore it in the workspace.

JIRA: MDSAL-444
Change-Id: If85fc6493b4d47201d9a5c6a7fdfb09c32a003c8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoDo not retain java.lang.reflect.Method in ValueNodeCodecContext 29/81829/2
Robert Varga [Tue, 30 Apr 2019 15:39:28 +0000 (17:39 +0200)]
Do not retain java.lang.reflect.Method in ValueNodeCodecContext

We only require method references during DataObjectCodecContext,
after which all we need is their name -- hence we index the map
by Method, as we can get the name from there and we can derive
the former string from the underlying schema, just as we did
before.

Change-Id: Icfb6bc3b89ce313ae054e773bd566c03c16d8a31
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoCheck registration being closed 11/81811/2
Robert Varga [Tue, 30 Apr 2019 03:35:41 +0000 (05:35 +0200)]
Check registration being closed

Check if the registration has been closed before firing events.
This way we stop delivering events a bit sooner, improving shutdown
speed and correctness.

JIRA: MDSAL-429
Change-Id: Id3ce6be0b8b15f4d95a3f54ac9880447a2551833
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoDo not use bound MethodHandle in DataObjectCodecContext 26/81826/2
Robert Varga [Tue, 30 Apr 2019 13:08:30 +0000 (15:08 +0200)]
Do not use bound MethodHandle in DataObjectCodecContext

Binding the MethodHandle means we are actually creating two
methodhandles, which is wasteful. Add a dummy CodecDataObject
constructor argument, unifying constructor signatures and allowing
us to use a single methodhandle, passing 'this' at the single
call site.

JIRA: MDSAL-444
Change-Id: Idd94638eb42d219b7370463d91dad3d00409bd5e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoAdd support for EventInstantAware notifications 80/81580/11
Robert Varga [Thu, 11 Apr 2019 21:11:17 +0000 (23:11 +0200)]
Add support for EventInstantAware notifications

This patch adds support for transmitting DOMEvent contents to
Binding Notifications through the EventInstantAware interface.

The design is such that binding-dom-adapter recognizes DOMEvent
and extracts the instant from it and uses the appropriate codec
call to instantiate a proxy Notification.

On codec side of things, the NotificationCodecContext maintains
a distinct Proxy, which also implements EventInstantAware and
when asked to create a proxy with an instant uses that instead
of the usual LazyDataObject to handle it. In order to make things
seamless and to not impact other LazyDataObject users, this
alternative proxy is serviced by an intermediate InvocationHandler,
which checks if the call is to eventInstance() and if not, it will
delegate to the normal LazyDataObject instance.

JIRA: MDSAL-282
Change-Id: I0dda9a55e4da6231c9bd3be03121a236ce187e47
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoSwitch NormalizedNode->Binding codegen to ByteBuddy 78/81778/35
Robert Varga [Tue, 23 Apr 2019 20:28:22 +0000 (22:28 +0200)]
Switch NormalizedNode->Binding codegen to ByteBuddy

This patch switches code generation for streamers and codec-based
binding objects to use ByteBuddy instead of Javassist.

While this increases the size of our jar considerably, it is
leads to more maintainable and safer code.

JIRA: MDSAL-444
Change-Id: Ib810dd0df6e569b0bb20603a5b0f0180c28ec25c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoTeach BindingNormalizedNodeCache to cache leaf type objects 90/79990/32
Robert Varga [Thu, 11 Apr 2019 15:40:28 +0000 (17:40 +0200)]
Teach BindingNormalizedNodeCache to cache leaf type objects

This adds the final bits to enable CachingNormalizedNodeSerializer
to actually cache leaf objects.

JIRA: MDSAL-407
Change-Id: I39bac36395f4e6809342d48a375d441b49cbc3b8
Signed-off-by: Jie Han <han.jie@zte.com.cn>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoMark YangSchemaUtils for removal 91/81791/2
Robert Varga [Fri, 26 Apr 2019 14:24:40 +0000 (16:24 +0200)]
Mark YangSchemaUtils for removal

This class seems to be unused, mark it for removal consideration
in the next release.

Change-Id: I468167a64e641815ddfd951ced0a19d25d9eb734
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoRework DataObjectSerializer implementations 09/81709/20
Robert Varga [Sat, 20 Apr 2019 12:03:42 +0000 (14:03 +0200)]
Rework DataObjectSerializer implementations

This patch rework generation of DataObjectSerializers to base
them on a common superclass and generates them into a target
CodecClassLoader.

This removes pollution of class loaders, while maintaining the
same level of functionality with slightly less byte code.

It also cleans up external interfaces, as the serializers
generation is a purely-internal implementation detail and is not
exposed to outside world -- hence this patch deprecates all
classes and interfaces involved in that former leak.

JIRA: MDSAL-401
Change-Id: I80daff7e05e7487af7dca4e4bdae6b2893c97037
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoDrop a FIXME in DataContainerCodecPrototype 93/81793/3
Robert Varga [Fri, 26 Apr 2019 19:36:30 +0000 (21:36 +0200)]
Drop a FIXME in DataContainerCodecPrototype

Acquisition of the backer is in the hot path now, hence we should
consider if we can safely remove or relax the volatile read here.

Change-Id: I9efe3cd2f45ab97f6c4c9bcc8f18e4cf62542b60
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoCache NodeContextSuppliers in CodecDataObject 15/81715/8
Robert Varga [Tue, 23 Apr 2019 10:26:47 +0000 (12:26 +0200)]
Cache NodeContextSuppliers in CodecDataObject

The binding between DataContainerCodecContext and CodecDataObject
is required only to support decoding child leaves, where we are
looking offset-based lookup.

Since each method has a fixed offset, which directly corresponds
to a NodeContextSupplier, we can short-circuit this lookup by
resolving NodeContextSupplier for each method into constant and
then pass it down to CodecDataObject -- thus side-stepping any
lookups and allowing the constant to be properly propagated.

That unfortunately means we need to initialize the generated class
early, so the fields are resolved in a well-controlled environment
-- for which we are using Customizer.customizeLoading() coupled
with a thread-local context managed by CodecDataObjectBridge.

JIRA: MDSAL-443
Change-Id: I9e24c30535c536d70b4eb60035b5aa744fc6ec9d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoOptimize CodecDataObject dispatch 08/81708/8
Robert Varga [Mon, 22 Apr 2019 20:47:43 +0000 (22:47 +0200)]
Optimize CodecDataObject dispatch

Now that we are in control of our interface between the DataObject
facade and DataObjectCodecContext rather than being forced to work
off of method name, we can optimize the dispatch towards
NodeContextSupplier (and DataObjectCodecContext size) by using
simple offsets to identify which method is being invoked.

On the generated code side of things, this lowers the pressure we
exert on the constant pool by using simple integers instead of
strings.

On the DataObjectCodecContext side, we ditch a Map in favor of a
simple array -- thus lowering memory overhead while also speeding
up dispatch, as it no longer is a Map lookup, but rather straight
get from an offset.

This necessitates special-casing key() method a bit, but the benefits
outweigh the (slight) ugliness we bring in.

JIRA: MDSAL-442
Change-Id: Iaf227e78d2b6546d34c2133fc31912c0a8dde4b3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoSpeed up BindingReflections.getAugmentations() 28/81728/2
Robert Varga [Wed, 24 Apr 2019 09:05:38 +0000 (11:05 +0200)]
Speed up BindingReflections.getAugmentations()

One of the ways in which we can acquire augmentations is through
AugmentationHolder interface. While this is handled through
AugmentationFieldGetter.getGetter(), that is not really efficient
as it requires indirection through multiple implementations.

Since AugmentationFieldGetter is a package-internal implementation
detail, factor the check out into BindingReflections, where it can
execute directly. This not only improves locality, but also allows
us to remove one AugmentationFieldGetter implementation, resulting
in bimorphic invocation.

Change-Id: I15584dbe6151a70d13a766f27b927f598a5d21ba
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoGenerate DataObject codec implementation 54/81654/30
Robert Varga [Mon, 15 Apr 2019 11:50:58 +0000 (13:50 +0200)]
Generate DataObject codec implementation

With the advent of CodecClassLoader we can safely instantiate
codec-specific implementations of binding interfaces instead
of relying on dynamic proxies.

This has several advantages:
- we do not generate a proxy class in public space, hence our mess
  will undergo normal GC rules
- generated code is a normal final class, hence we can inherit
  method implementations from interfaces and subclasses
- for each instance, we do not require a proxy and an invocation
  handler, so we instantiate only one object
- there is no reflection in the invocation path, hence JIT has
  full (and direct) visibility and can perform all of its magic

This patch DataObject support to use this approach, with
(Augmentable)CodecDataObject forming the base class.

The result is a bit more complex than the OpaqueObject case, but
also offers several advantages over the LazyDataObject approach
it replaces:
- nonnullFoo() methods are inherited from the binding interface,
  hence the presence of binding-dom-codec does not prevent CHA
  analysis from concluding there is only a single implementation
  -- thus allowing rapid devirtualization. This also means that
  DataContainerCodecContext no longer needs to track those methods
  or do anything.
- Augmentable interfaces are supported by a separate superclass,
  which implements AugmentationHolder, resulting in augmentations
  field being held only if the binding interface is augmentable
- getters and Identifiable.key() values are held in dedicated
  fields of the generated object. This leads to them being properly
  cached in all cases, hence invoking a getter after an
  equals/hashCode() operation will reuse the cached value if it
  was populated
- since we are using plain fields, data access does not involve
  walking a ConcurrentHashMap, further improving performance

The amount of generated code is kept at a minimum -- methods
just invoke CodecDataObject's method, passing it the ARFU
corresponding to the field as a constant -- and rely on the
compiler to inline the call, so that constants are propagated.

JIRA: MDSAL-442
Change-Id: I6acc34ab6b2cc62fd26dc34275259494ac4541fb
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoExpand class customization capabilities 11/81711/5
Robert Varga [Tue, 23 Apr 2019 08:27:51 +0000 (10:27 +0200)]
Expand class customization capabilities

This expands CodecClassLoader.Customizer with the ability to
cross-reference generated classes, so a generated class can
depend on another generated class -- which can potentially live
in a different classloader. This capability is required to support
stream writers, as they delegate to each other.

JIRA: MDSAL-401
JIRA: MDSAL-443
Change-Id: I446dcfe10c742c670f2021123acab600a28c2514
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoSpeed up DataContainerCodecPrototype.get() a bit 12/81712/4
Robert Varga [Tue, 23 Apr 2019 09:38:33 +0000 (11:38 +0200)]
Speed up DataContainerCodecPrototype.get() a bit

We can use less byte code to initialize both the local handle
and the cache field.

Change-Id: I362d0125836c6d962c4366c03ba76ae244fc54e5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoGenerate OpaqueObject implementation 53/81653/19
Robert Varga [Mon, 15 Apr 2019 08:02:03 +0000 (10:02 +0200)]
Generate OpaqueObject implementation

With the advent of CodecClassLoader we can safely instantiate
codec-specific implementations of binding interfaces instead
of relying on dynamic proxies.

This has several advantages:
- we do not generate a proxy class in public space, hence our mess
  will undergo normal GC rules
- generated code is a normal final class, hence we can inherit
  method implementations from interfaces and subclasses
- for each instance, we do not require a proxy and an invocation
  handler, so we instantiate only one object
- there is no reflection in the invocation path, hence JIT has
  full (and direct) visibility and can perform all of its magic

This patch does that for OpaqueObject, which results extremely
simple generated classes: they just subclass a ForeignOpaqueObject
and add the target binding interface.

JIRA: MDSAL-442
Change-Id: I2be5bb88f9557375f517415d6bec9f68e803628c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoAdd codec support for anyxml classes 43/81643/19
Robert Varga [Sun, 14 Apr 2019 09:25:17 +0000 (11:25 +0200)]
Add codec support for anyxml classes

ForeignOpaqueData and ForeignOpaqueObject provide generalized
support for proxying over to yang.data.api.ForeignDataNode, hence
supporting anydata/anyxml in all possible object models.

The codec tree is extended with BindingOpaqueObjectCodecTreeNode,
which supports all OpaqueObjects, with the restriction that only
AnyXmlNodes (i.e. those with DOMSource object model) are supported
due to streaming restrictions in NormalizedNodeStreamWriter.

JIRA: MDSAL-285
Change-Id: I9192008ae169cf49a98f64a218a33d470d134eae
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoAdd support for anyxml node code generation 89/81589/15
Robert Varga [Tue, 9 Apr 2019 21:43:40 +0000 (23:43 +0200)]
Add support for anyxml node code generation

This adds the support for generating OpaqueObject interfaces
based on anyxml nodes.

JIRA: MDSAL-437
Change-Id: Iee4f32449f73833b31444c7659047471758d0c88
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>