mdsal.git
5 years agoBump yangtools to 2.1.7 04/79404/1
Robert Varga [Thu, 10 Jan 2019 10:18:44 +0000 (11:18 +0100)]
Bump yangtools to 2.1.7

This realigns odlparent/yangtools versions and brings in some
minor improvements.

Change-Id: If46369a9be7976f905dd4c3ebf26e984328c489f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoRevert "Simplify ClassLoadingStrategy implementations" 01/79401/2
Robert Varga [Thu, 10 Jan 2019 10:06:25 +0000 (11:06 +0100)]
Revert "Simplify ClassLoadingStrategy implementations"

This reverts commit 75181ffcf7c147a22330a8817af89aecdaf8149c,
which breaks blueprint, as it does not mix with default methods.

Change-Id: Ic53ddc49ec60430b92124e52e3a670da8ff4f5a0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoFixup version bump 02/79402/1
Robert Varga [Thu, 10 Jan 2019 10:10:09 +0000 (11:10 +0100)]
Fixup version bump

I again forgot to perform a complete version bump, this fixes it
up so we have proper .4-SNAPSHOT versions.

Change-Id: I750b41c188cf00b164997fdd928c5db906d6bb63
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoBump to odlparent 4.0.8 54/79354/2
Stephen Kitt [Wed, 9 Jan 2019 14:34:22 +0000 (15:34 +0100)]
Bump to odlparent 4.0.8

Change-Id: I930ea20715ed91acf2e8ebb2e9b253bacff71eda
Signed-off-by: Stephen Kitt <skitt@redhat.com>
5 years agoMove blueprint code into place 16/79316/5
Robert Varga [Tue, 8 Jan 2019 15:35:55 +0000 (16:35 +0100)]
Move blueprint code into place

This moves the contents of opendaylight/blueprint into a new
component, mdsal-blueprint-binding. While the structure is created,
the component is not yet plugged into the build system, which will
be done in subsequent patches.

JIRA: MDSAL-413
Change-Id: I1c11f2947cc6e5061e4de1ff8b4a4ca803b97c36
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoRemove redundant type declarations 79/76879/6
Stephen Kitt [Thu, 11 Oct 2018 10:47:47 +0000 (12:47 +0200)]
Remove redundant type declarations

Type inference improved since we wrote this code, hence we can
ditch the explicit types.

Change-Id: I44ae2c841820b6e8e4b05d06b45d9123c7b6db70
Signed-off-by: Stephen Kitt <skitt@redhat.com>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoAttach aggragate javadocs to aggregator 51/79051/4
Robert Varga [Wed, 26 Dec 2018 00:12:34 +0000 (01:12 +0100)]
Attach aggragate javadocs to aggregator

This allows us to point users to our aggregated javadocs, hence
they do not fish for them. This means, though, that we have to
install the aggregator.

Change-Id: Ic5c190a612dd7a679f3b98114652dc3af670b487
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoMove mdsal-trace into its place 69/75569/5
Robert Varga [Tue, 8 Jan 2019 11:51:33 +0000 (12:51 +0100)]
Move mdsal-trace into its place

This is code incoming from the controller, we need to integrate it
into mdsal structure. This patch performs the preliminary move out
of opendaylight/md-sal directory.

While this code is being built, it is not part of the feature
repository yet, so as not to interfere with controller's
odl-mdsal-trace feature.

JIRA: MDSAL-412
Change-Id: I04cf3dcda5d990f5b1e45a3b3ecf15978a0db958
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoUse the new constructor of 'Disruptor' instead of a deperecated one 89/79089/5
Jie Han [Sun, 30 Dec 2018 07:13:18 +0000 (15:13 +0800)]
Use the new constructor of 'Disruptor' instead of a deperecated one

Rather than passing a pre-configured ThreadPool, we use a ThreadFactory
to instantiatiate the Disruptor.

Since we require an executor to dispatch subscription listeners,
create a separate thread pool to execute them on.

Change-Id: I75605a5deadc477bc91f275b5fd04d7907fbd631
Signed-off-by: Jie Han <han.jie@zte.com.cn>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoBump odlparent to 4.0.7 82/79082/3
Robert Varga [Thu, 27 Dec 2018 15:57:47 +0000 (16:57 +0100)]
Bump odlparent to 4.0.7

This fixes Java11 SFT compatiblity.

Change-Id: I3645e3f1284962e4670b4b71ed8edb72ad81e22f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoSimplify ClassLoadingStrategy implementations 85/78985/6
Robert Varga [Sat, 22 Dec 2018 01:19:15 +0000 (02:19 +0100)]
Simplify ClassLoadingStrategy implementations

loadClass(Type) has only one implementation, which defers to
loadClass(String). Promote that impleentation to default, simplifying
other potential implementations.

Change-Id: Idef5da25e10490fce2174dee7a6c031f71cc741c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoMove README.adoc to README.md 29/79029/1
Robert Varga [Mon, 24 Dec 2018 18:21:05 +0000 (19:21 +0100)]
Move README.adoc to README.md

Also add badges.

Change-Id: I9158dd7c391990c7074f642814498a19440e07f1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoBump version to .4-SNAPSHOT 09/79009/1
Robert Varga [Sun, 23 Dec 2018 10:23:52 +0000 (11:23 +0100)]
Bump version to .4-SNAPSHOT

This starts 3.0.4-SNAPSHOT development.

Change-Id: Ifb0a03e6ad9d648ac5e9eebce19d3844b25b25ce
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoBump yangtools to 2.1.6 53/78953/3
Robert Varga [Fri, 21 Dec 2018 16:07:17 +0000 (17:07 +0100)]
Bump yangtools to 2.1.6

This bumps the yangtools version to align it with odlparent-4.0.5.

Change-Id: I639889f1247dba53c318d3ccd33e2cb82a68be86
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoFix GroupingDefinitionDependencySort javadoc 00/79000/1
Robert Varga [Sat, 22 Dec 2018 19:42:44 +0000 (20:42 +0100)]
Fix GroupingDefinitionDependencySort javadoc

A minor cleanup of javadocs.

Change-Id: I35aea055317de2a44ca2d60fef585ad4df3dbf6c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoRefactor ModuleInfoBackedContext a bit 96/78996/3
Robert Varga [Sat, 22 Dec 2018 15:05:29 +0000 (16:05 +0100)]
Refactor ModuleInfoBackedContext a bit

The try/catch block is overly broad, reduce it to clarify that
a duplicate package is ignored without further actions.

Change-Id: I38a4f1d8f173b593ddb6c83d27b025cada926931
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoFix a javadoc typo 95/78995/3
Robert Varga [Sat, 22 Dec 2018 15:11:54 +0000 (16:11 +0100)]
Fix a javadoc typo

Simple typo in javadoc, fix it.

Change-Id: I37cdd22d0a73630f6d45072b61efba4d43061079
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoBump to yangtools-2.1.6-SNAPSHOT 97/78997/1
Robert Varga [Sat, 22 Dec 2018 18:24:34 +0000 (19:24 +0100)]
Bump to yangtools-2.1.6-SNAPSHOT

This is for early integration before the regular release is promoted.

Change-Id: I33e64b02e385d5e302467242579f994e491e305e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoUse commons-lang3 from odlparent 93/78993/1
Robert Varga [Sat, 22 Dec 2018 17:28:14 +0000 (18:28 +0100)]
Use commons-lang3 from odlparent

odlparent-4.0.5 ships various third-parties wrapped in features,
use odl-apache-commons-lang3 instead of packaging it ourselves.

Change-Id: Idaa9f249e50b5e2aaa2f2562111a3e635b334031
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoUse disruptor from odlparent 92/78992/1
Robert Varga [Sat, 22 Dec 2018 17:22:50 +0000 (18:22 +0100)]
Use disruptor from odlparent

odlparent provides lmax-disruptor packaging, use that instead of
packaging it ourselves.

Change-Id: I38ad75b50c7613b674e4aa65c80192e85a7fc40c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoRemove commons-lang3 dependency 91/78991/1
Robert Varga [Sat, 22 Dec 2018 17:22:11 +0000 (18:22 +0100)]
Remove commons-lang3 dependency

mdsal-binding-dom-codec does not need this dependency, remove it.

Change-Id: I464594cf64599c1d15578c40c0d54252e006384f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoBump to odlparent 4.0.5 56/78956/2
Stephen Kitt [Fri, 21 Dec 2018 16:40:24 +0000 (17:40 +0100)]
Bump to odlparent 4.0.5

Change-Id: I68edc89602d424de7b61e24cf42db674c8364b15
Signed-off-by: Stephen Kitt <skitt@redhat.com>
5 years agoDowngrade mdsal-binding-generator-impl dependencies 72/78972/2
Robert Varga [Fri, 21 Dec 2018 21:12:52 +0000 (22:12 +0100)]
Downgrade mdsal-binding-generator-impl dependencies

mdsal-binding-generator-impl does not need yang-data-impl,
only yang-data-api. Downgrade the dependency.

Change-Id: I8ac5c20f43237cb6a811a4556752f236e6c61217
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoFixup (DOM)DataTreeChangeListener a bit 62/78662/5
Jie Han [Wed, 12 Dec 2018 01:09:37 +0000 (09:09 +0800)]
Fixup (DOM)DataTreeChangeListener a bit

According to comments of
https://git.opendaylight.org/gerrit/#/c/77070/

 - replace 'onInitialData' with 'onEmptyInitialData' in
    (DOM)DataTreeChangeListener
 - fixup javadoc description

Change-Id: I50a1b903c365157265512eefce9811cbdd3d6350
Signed-off-by: Jie Han <han.jie@zte.com.cn>
5 years agoBump to odlparent 4.0.4 06/78906/2
Stephen Kitt [Fri, 21 Dec 2018 08:54:06 +0000 (09:54 +0100)]
Bump to odlparent 4.0.4

Change-Id: I6c3bf062614b6817e1a2bfe7e7f7e94c44683852
Signed-off-by: Stephen Kitt <skitt@redhat.com>
5 years agoAllow Binding/DOM/Binding shortcuts to be disabled 16/78816/4
Robert Varga [Sat, 15 Dec 2018 13:14:33 +0000 (14:14 +0100)]
Allow Binding/DOM/Binding shortcuts to be disabled

This adds a property-driven knob, which allows the various shortcuts
we take when crossing binding-dom-adapter to be completely disabled.

Using the knob is useful for testing and making sure applications
correctly follow the YANG model they are written against.

Change-Id: I9836304fe7878b80c769b88914300fbcf3fe08b5
JIRA: MDSAL-409
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoMass-migrate fields to Immutable collections 08/78808/1
Robert Varga [Fri, 14 Dec 2018 20:09:26 +0000 (21:09 +0100)]
Mass-migrate fields to Immutable collections

This follows errorprone/Google recommendation of keeping fields
Immutable{List,Map,Set}. It has the tiny advantage of resulting
in invokevirtual vs. invokeinterface.

Change-Id: I53d55c1909d93021370d6f411284a89cab62b4f8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoImprove conflicting error message 96/78796/1
Robert Varga [Fri, 14 Dec 2018 12:15:58 +0000 (13:15 +0100)]
Improve conflicting error message

In the unlikely event we conflict on a constant, it is nice to know
what name it has.

Change-Id: Ie775779c350e6621917d0212978f6aa2f28c32f3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoCleanup BaseYangTypes 95/78795/1
Robert Varga [Fri, 14 Dec 2018 12:01:49 +0000 (13:01 +0100)]
Cleanup BaseYangTypes

We can make direct references to constants exposed from Types,
as well as eliminate a static initializer by exploiting fluent
nature of ImmutableMap.builder();

Change-Id: If045e15375bc7c35c2f7e72dafde59a7baa07317
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoAdd CodeHelpers.throwInvalidRange() specializations 68/78768/2
Robert Varga [Thu, 13 Dec 2018 19:07:37 +0000 (20:07 +0100)]
Add CodeHelpers.throwInvalidRange() specializations

Range-checking code can (and does) emit checks based on primitive
types, hence it is forcing a boxing operation.

Provide overloaded methods to allow generated code to bind to both
int- and long-based specializations, resulting is less byte code
being generated.

Change-Id: If6d3cc04c3f7d3d3d5fb3ad3a10f3c3d8f813654
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoBump yangtools to 2.1.5 40/78640/1
Robert Varga [Tue, 11 Dec 2018 09:33:13 +0000 (10:33 +0100)]
Bump yangtools to 2.1.5

Brings in the latest fixes and improvements.

Change-Id: I5a9aa33355aa8a21b857411d9945c696438ec0ab
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoDo not import javax.annotation 33/78333/4
Robert Varga [Sat, 1 Dec 2018 22:11:20 +0000 (23:11 +0100)]
Do not import javax.annotation

javax.annotation.RegEx has retention=runtime, hence we need to
suppress javax.annotation import until we migrate to something
else. Also fix binding2, which uses other JSR305 annotations.

Change-Id: I506fe8d11c0d3ec683cc09c4c9b8f5506c809163
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoDisable binding2 javadoc under Java 11 34/78334/4
Robert Varga [Sat, 1 Dec 2018 22:20:52 +0000 (23:20 +0100)]
Disable binding2 javadoc under Java 11

javadoc fails to find generated .txt package, leading to a failure
to resolve imports. Sacrifice javadocs to let Java 11 through.

Change-Id: Ifd6fa576f38d08d1d12ffc7aeeced1762a021beb
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoSuppress RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE 32/78332/2
Robert Varga [Sat, 1 Dec 2018 22:13:02 +0000 (23:13 +0100)]
Suppress RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE

spotbugs does not grok Java 11 try-with-resources desugaring,
forcing us to suppress this warning.

Change-Id: Ia840cdd03932ae543fe66931f55d6b3c1b2d4697
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoSeparate out single-key Identifiable handling 10/78110/13
Robert Varga [Sun, 25 Nov 2018 15:01:34 +0000 (16:01 +0100)]
Separate out single-key Identifiable handling

We can further optimize IdentifiableItemCodec by separating
out the common case of a single-key from multiple-keys.

This allows us to specialize ImmutableMapTemplates we use for
the two cases, more efficiently binding to
NodeIdentifierWithPredicates constructor.

Furthermore we can specialize key constructor invocation such
that we directly invoke the constructor for single-key identifiers,
without the need to iterate and allocate arrays.

JIRA: MDSAL-387
Change-Id: I2fc26dc7285bfb3fe829b8b0efd9937daf6fbc8d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoBump versions to 3.0.3-SNAPSHOT 05/78205/2
Robert Varga [Tue, 27 Nov 2018 11:14:49 +0000 (12:14 +0100)]
Bump versions to 3.0.3-SNAPSHOT

This starts the next development iteration.

Change-Id: Id51d991b957c1fe58ac64f6c64384baa7bd6fcc6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoAdjust minor version to 1.0.2-SNAPSHOT 02/78202/2
Robert Varga [Tue, 27 Nov 2018 10:57:03 +0000 (11:57 +0100)]
Adjust minor version to 1.0.2-SNAPSHOT

This makes it a lot easier to bump versions.

Change-Id: Ib2e3870f9b1868869907998e382147b89a27f828
JIRA: MDSAL-381
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoFix up release old producers to avoid memory leak 01/76501/22
han [Sun, 30 Sep 2018 08:49:54 +0000 (16:49 +0800)]
Fix up release old producers to avoid memory leak

- It should close all correlative old 'InMemoryDOMDataTreeShardProducer'
  when close a 'ShardedDOMDataTreeProducer', or a memory leak happens
  for repeatly creating and closing the same producer as well as in the
  case of attach/detach subshards.

JIRA: MDSAL-386
Change-Id: I9c6ad6b63de4dfc7b75a315fce23a5da3be9d06d
Signed-off-by: Jie Han <han.jie@zte.com.cn>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoFix ClassTemplate.hashCode() alignment 98/78198/2
Robert Varga [Tue, 27 Nov 2018 09:39:09 +0000 (10:39 +0100)]
Fix ClassTemplate.hashCode() alignment

We missed four spaces, making the output look ugly. Fix that.

Change-Id: I44cf863a9478db8d1ab4f90c4cf2d766d576f554
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoTeach MethodSignature about default methods 02/78102/9
Robert Varga [Fri, 23 Nov 2018 18:30:11 +0000 (19:30 +0100)]
Teach MethodSignature about default methods

MethodSignature dates back to Java 7 days and has no notion of
interface-default methods. Retrofit the support, as it may come
handy when dealing with various aspects of codegen.

Also propagate the knowledge of them into java-api-generator, so
that we have a cleaner nonnull method generation and new default
methods do not break Builder{Generator,Template} assumptions.

JIRA: MDSAL-18
JIRA: MDSAL-396
Change-Id: I12ea42d096ee50ae61f908e9f9347c45883f66b3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoOptimize IdentifiableItemCodec 73/78073/8
Robert Varga [Fri, 23 Nov 2018 00:30:08 +0000 (01:30 +0100)]
Optimize IdentifiableItemCodec

ImmutableMapTemplate allows us to instantiate space-efficient
ImmutableOffsetMaps very quickly, because we know exactly what
keySet() we are going to use, including our preferred ordering.

Use this class to instantiate keyValueContexts and also create
NodeIdentifierWithPredicates.

JIRA: YANGTOOLS-917
Change-Id: I087083fe4e1914bb5d8e58b9e378ebda9e070793
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoUse internal classes for codecs 21/78121/3
Robert Varga [Sun, 25 Nov 2018 18:39:00 +0000 (19:39 +0100)]
Use internal classes for codecs

As we are exposing codecs through package-private interfaces, there
is no point in hiding the implementation class. This helps JIT to
devirtualize the calls.

Change-Id: I74262f76380c27c3cfbc6af2d97d69bd4f57bf9e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoBind invoker method handle to constructor 09/78109/2
Robert Varga [Sun, 25 Nov 2018 15:15:23 +0000 (16:15 +0100)]
Bind invoker method handle to constructor

We only ever pass the constructor method handle to the invoker,
hence we can make this a constant by binding the invoker handle
to the constructor -- saving us a field.

Change-Id: I547f7eac202389aa0f7308266b2f3a451a2f83a3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoBump yangtools to 2.1.4 93/78093/5
Robert Varga [Fri, 23 Nov 2018 13:26:30 +0000 (14:26 +0100)]
Bump yangtools to 2.1.4

This release brings about ImmutableMapTemplate, which we'll use
to improve IdentifiableItemCodec.

Change-Id: I2a873d7987fd77f03213a744ae5a75d094e4d96f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoClean up pom of mdsal-binding-test-model a bit 46/78046/1
Jie Han [Thu, 22 Nov 2018 11:51:37 +0000 (19:51 +0800)]
Clean up pom of mdsal-binding-test-model a bit

- Remove duplicated dependecy and exclution.
- Enable spotbugs

Change-Id: I9bcd76d7fcf1ae1447bbf4f0b698f6f24bc24279
Signed-off-by: Jie Han <han.jie@zte.com.cn>
5 years agoUpdate WriteOperations/TypedTransaction API design 67/77467/27
Robert Varga [Fri, 2 Nov 2018 21:17:39 +0000 (22:17 +0100)]
Update WriteOperations/TypedTransaction API design

Overloading merge/put methods with a boolean prevents a quick
identification of users of costly operations. Moreover, the
documentation (and contract) does not completely reflect behaviour
as all purely-structural elements undergo automatic lifecycle:
for example non-presence containers are created as needed and
removed when they are no longer needed.

Update the design by deprecating boolean-taking methods in favor
of mergeParentStructureAnd{Merge,Put}, which are now implemented
as defaults. This will allow us to migrate users first and then
remove those methods in 4.0.0 timeframe.

Also update documentation to discourage the use of these methods,
as they have significant performance cost.

JIRA: MDSAL-382
Change-Id: I878863797dab01a1adfa2164a0ab0583b0641163
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoFix InterfaceGenerator confusion with RPC method names 93/77893/7
Robert Varga [Fri, 16 Nov 2018 11:31:15 +0000 (12:31 +0100)]
Fix InterfaceGenerator confusion with RPC method names

The refactor in method generation has caused a regression where
we erroneously mark RPC methods with @Nullable. Fix this by checking
that the method has zero arguments.

JIRA: MDSAL-18
Change-Id: Id497eb0a7954ee85c9c22919dd3fa814dd788d5e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoOptimize single-property ClassTemplate hashCode() 19/77919/5
Robert Varga [Sun, 18 Nov 2018 20:12:08 +0000 (21:12 +0100)]
Optimize single-property ClassTemplate hashCode()

When we have a single property, it does not make sense to generate
anything aside from delegation to the field, without any additional
arithmetic.

While this changes hashCode() results, these are still consistent
and for bonus points save ourselves some amount of bytecode and make
concentrate some common template code.

JIRA: MDSAL-400
Change-Id: I2035acd30d7c9653fcf7d9af4abcad9032ab795c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoIndex nonnull/getter methods by String 90/77890/9
Robert Varga [Fri, 16 Nov 2018 09:20:45 +0000 (10:20 +0100)]
Index nonnull/getter methods by String

Looking up by String offers slight advantage over Method lookup,
because we'll end up with a constant hashCode() over objects which
are guaranteed to be interned.

This rework implies we no longer get to have a map whose keySet
reflects property methods -- which is fine, as the keyset would
take up more memory than a plain array, so we retain the methods
in an array -- hence this ends up being a net win in both cases.

Furthermore it flushes out the fact that nonnull methods should
not really cache their result -- for example if the user performs
a nonnull() access and then runs hashCode(), we'll end up performing
two decodes, as nonnull() cache will not be picked up by hashCode().

We therefore construct nonnull->getter String map, which we consult
on nonnull accesses and only wrap it without caching. This has
the benefit of keeping the cache smaller while maintaining its
effectiveness.

JIRA: MDSAL-398
Change-Id: I36526ce15735d4ef8e4ba847bcc24ea69b950e94
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoDo not box result twice 20/77920/1
Robert Varga [Sun, 18 Nov 2018 20:58:17 +0000 (21:58 +0100)]
Do not box result twice

result is an int while both cache and return type are Integer,
instantiate a local variable to hold the boxed value so we not
box twice.

Change-Id: I659b60b40d0d1dfa1eee25d214af4a096bf3e60e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoUse ImmutableMaps for lazy augmentations initialization 99/77799/5
Robert Varga [Wed, 14 Nov 2018 15:40:29 +0000 (16:40 +0100)]
Use ImmutableMaps for lazy augmentations initialization

Rather than tracking lookups in two separate ConcurrentMaps, we
perform locked atomic updates in copy-on-write immutable structure.

The two lookup maps are kept in ImmutableMaps, which offer tighter
packing and do not incur any further volatile reads beyond getting
a reference to them.

This results in lower memory overhead, as the maps are more tightly
packed and also biases performance towards the dominant use case,
which is pure lookups.

JIRA: MDSAL-391
Change-Id: I65ecb25a5d364040be44df144000d1bbbc2a922e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoIndex cached data by method name 76/77876/3
Robert Varga [Fri, 16 Nov 2018 07:15:42 +0000 (08:15 +0100)]
Index cached data by method name

Method.hashCode() is not a constant, whereas String.hashCode() is
pre-computed (for interned Strings). As Method.getName() is guaranteed
to be interned and getters have zero arguments, a method's name
is enough to uniquely identify the corresponding piece of data.

Therefore use Method.getName() to index cachedData.

Change-Id: Ie9fec477bd7346042e3700695588bc526fd56dac
JIRA: MDSAL-398
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoSwitch on method names 75/77875/4
Robert Varga [Fri, 16 Nov 2018 06:51:27 +0000 (07:51 +0100)]
Switch on method names

Method names are guarateed to be interned by the JVM, hence their
hashCode is O(1) -- making them a prime target for a switch statement,
which side-steps the need to run String.equals() slow path most of
the time.

JIRA: MDSAL-398
Change-Id: Ie57c2f9fd8c3757ec08e1be945b08d66ebbcff4e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoSwitch on parameterCount 74/77874/3
Robert Varga [Fri, 16 Nov 2018 06:47:39 +0000 (07:47 +0100)]
Switch on parameterCount

The else case here assumes parameterCount being 1, make that explicit,
resulting in cleaner code.

JIRA: MDSAL-398
Change-Id: Ie3fa47de6b1630e98a426da69bb6c6d2b6b4b026
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoUse Method.getParameterCount() 73/77873/3
Robert Varga [Fri, 16 Nov 2018 06:38:51 +0000 (07:38 +0100)]
Use Method.getParameterCount()

Java 8 introduced this method, which bypasses array cloning done
by getParameterTypes(), making it more efficient. Take advantage
of it.

JIRA: MDSAL-398
Change-Id: Id5d4972ba20d63a8ff79e4adbdf6d2adbfce0b87
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoDefine getImplementedInterface name in BindingMapping 68/77868/1
Robert Varga [Fri, 16 Nov 2018 06:34:37 +0000 (07:34 +0100)]
Define getImplementedInterface name in BindingMapping

This moves the definition from LazyDataObject to a common place,
so we have one place which defines it. Also remove unused Throwable
declaration.

Change-Id: Icfbc861419fca3b207e9aebfc2b00ddf8a1fc38f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoFixup lookup of DOMDataTreePrefixTableEntry 14/76814/13
han [Wed, 10 Oct 2018 02:55:13 +0000 (10:55 +0800)]
Fixup lookup of DOMDataTreePrefixTableEntry

- Make sure to return the entry with value present.

Change-Id: Ib37def7a8593516e1623ca0b1b34ef997790c754
Signed-off-by: Jie Han <han.jie@zte.com.cn>
5 years agoCache mismatched augmentations 24/77724/3
Robert Varga [Tue, 13 Nov 2018 14:13:41 +0000 (15:13 +0100)]
Cache mismatched augmentations

Address a FIXME around caching of mismatched augmentations, as it
seems openflowplugin is doing this on purpose.

The cache is expected to be needed infrequently in terms of associated
objects as well as modified infrequently, hence we use a space-efficient
ImmutableMap.

JIRA: MDSAL-388
Change-Id: Id86d8c713ee1014d9d4867558032ba3ccd51fc45
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoIntroduce ReadOperations.exists() 39/77739/3
Robert Varga [Tue, 13 Nov 2018 18:18:30 +0000 (19:18 +0100)]
Introduce ReadOperations.exists()

This method exists in the DOM API, but for some reason it was left
out if the Binding API. Introduce it as default methods riding on
the read() method and override them in all known implementations,
so the request is efficiently routed.

Change-Id: Id56332d6f720396305ac68e40554e62fd17c34fb
JIRA: MDSAL-389
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoGenerate nonnull default wrappers for list getters 27/77627/11
Robert Varga [Thu, 8 Nov 2018 15:27:49 +0000 (16:27 +0100)]
Generate nonnull default wrappers for list getters

This adds the knowledge about default methods to BindingMapping,
templates and CodeHelpers, so that whenever we emit a List accessor
(getFoo) we also emit a corresponding nonnull accessor (nonnullFoo).

The nonnull accessor is a default method, which takes invokes
getFoo() and runs it through CodeHelper.nonnull(), which turns
nulls into empty lists.

JIRA: MDSAL-18
Change-Id: Ic4fc80aa071b7d5b93bf49d1de44855f4bd820f2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoMove getter method naming to BindingMapping 16/77616/12
Robert Varga [Thu, 8 Nov 2018 11:18:17 +0000 (12:18 +0100)]
Move getter method naming to BindingMapping

Both BaseTemplate.isAccessor() and a chunk of
AbstractTypeGenerator.getterMethodName() should actually be held
in BindingMapping, so we retain consistent naming of things.

This patch introduces the constants necessary for this to work
and migrates the code there. This cascades to various other places,
like mdsal-binding-dom-codec, where we extract copy&pasted code
to a common utility class.

JIRA: MDSAL-18
Change-Id: I5fb285f00658ce81f60890d03844b51e19bd4a40
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoRevert "Add DataObjectUtils" 17/77617/11
Robert Varga [Thu, 8 Nov 2018 09:49:32 +0000 (10:49 +0100)]
Revert "Add DataObjectUtils"

This reverts commit 0ef76ead8ed2d4af93e0d8cac92b67d087354057 in
preparation for a more proper solution.

JIRA: MDSAL-18
Change-Id: I96b89867e5a324327eb77cdde018700456fc4bbc
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoWADL/Documentations generators should use BuildContextAware 79/77679/3
Robert Varga [Mon, 12 Nov 2018 08:45:00 +0000 (09:45 +0100)]
WADL/Documentations generators should use BuildContextAware

We should not be hard-wiring to DefaultBuildContext, but rather
pick it up from yang-maven-plugin.

Change-Id: I56a6f23698e450f31087bff76e911bef0f5819cd
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoProvide iana-if-type based on RFC8343 96/77496/6
Jie Han [Mon, 5 Nov 2018 09:33:42 +0000 (17:33 +0800)]
Provide iana-if-type based on RFC8343

- Current iana-if-type artifact is tied to RFC7223,
  meaning the code generated within it is not usable with RFC8343.
  Provide an alternative artifact, which is bound to RFC8343.

  JIRA: MDSAL-381
Change-Id: Ia2089010fca472dfa499b97cc0ac3c6c420b0431
Signed-off-by: Jie Han <han.jie@zte.com.cn>
5 years agoPrevent NPE from being propagated from LazyDataObject 24/77624/4
Robert Varga [Thu, 8 Nov 2018 14:09:49 +0000 (15:09 +0100)]
Prevent NPE from being propagated from LazyDataObject

Rather than incurring a NPE when we fail to find proper
NodeContextSupplier, add an explicit verifyNotNull() check to
throw a more explanatory VerifyException.

Change-Id: Ieed6d050bccfe482f69152b33a9a84bbe20037c2
JIRA: MDSAL-18
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoRefactor DataObjectCodecContext.getBindingChildValue() 23/77623/3
Robert Varga [Thu, 8 Nov 2018 14:01:07 +0000 (15:01 +0100)]
Refactor DataObjectCodecContext.getBindingChildValue()

Using instanceof checks is an OOP anti-pattern, which we do not
want here anyways. Generalize NodeCodecContext.defaultObject()
to return null by default and refactor decoding to rely on it,
with LeafNodeCodecContext returning whatever it has as a default
value.

Change-Id: I2b58bc7f1a16496cf6bc93fd7a33aec38f864597
JIRA: MDSAL-18
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoSeparate out DOMDataTree{Read,Write}Transactions 90/77590/8
Robert Varga [Wed, 7 Nov 2018 23:31:14 +0000 (00:31 +0100)]
Separate out DOMDataTree{Read,Write}Transactions

DOMDataTreeReadWriteTransaction.close() does not make sense
in presence of DOMDataTreeReadWriteTransaction.cancel().

Split out both operation sets, so ReadWriteTransaction can eventually
become a WriteTransaction which also has ReadOperations.

Make DOMDataTreeReadWriteTransaction.close() a default method, which
defers processing to cancel() and remove its other implementations
-- some of which were completely broken.

Change-Id: Ib45e3e0d17ae2be591915fa618d5b468ec0c89e7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoRemove redundant public modifier 11/77611/2
Jakub Morvay [Thu, 8 Nov 2018 09:59:08 +0000 (10:59 +0100)]
Remove redundant public modifier

public modifier is redundant for inner interfaces. Remove it from
DOMMountPointService DOMMountPointBuilder inner interface definition.

Change-Id: I2a370750636d9307b45adbef44ec5c5eb37c28b6
Signed-off-by: Jakub Morvay <jmorvay@frinx.io>
5 years agoDeprecate leak methods in DOMMountPointServiceImpl 09/77609/5
Jakub Morvay [Thu, 8 Nov 2018 09:41:30 +0000 (10:41 +0100)]
Deprecate leak methods in DOMMountPointServiceImpl

This deprecates DOMMountPointServiceImpl registerMountPoint() and
unregisterMountPoint() methods as they are leaks and should never have
been exposed publicly.

Change-Id: Iba5a270d15ca882eb08372f1f6911af55d298f8d
Signed-off-by: Jakub Morvay <jmorvay@frinx.io>
5 years agoCleanup ShardedDOMWriteTransactionAdapter 95/77595/2
Robert Varga [Thu, 8 Nov 2018 00:04:48 +0000 (01:04 +0100)]
Cleanup ShardedDOMWriteTransactionAdapter

Move field initialization and add annotations.

Change-Id: If9548e02144e9c1ae9488bdb1854b2946af4da30
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoUpdate FastThreadPoolExecutor instantiation 94/77594/2
Robert Varga [Thu, 8 Nov 2018 00:00:06 +0000 (01:00 +0100)]
Update FastThreadPoolExecutor instantiation

This forwards logger identity to the executor, so its entries
are properly accounted for.

Change-Id: I996d9d51742c8c870e1ef5a48ad9cf8627f289be
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoCleanup ScanningSchemaContext 93/77593/2
Robert Varga [Wed, 7 Nov 2018 23:54:50 +0000 (00:54 +0100)]
Cleanup ScanningSchemaContext

This adds a few aesthetic improvements, killing some superfluous
operations.

Change-Id: Ibd4c45c9e5df91852fc7aa392ba34d3fd0c3fb52
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoCleanup PingPongDataBroker 92/77592/2
Robert Varga [Wed, 7 Nov 2018 23:43:15 +0000 (00:43 +0100)]
Cleanup PingPongDataBroker

This cleans up annotations and various aesthetics in pingpong, not
changing anything, really.

Change-Id: Ib86bff9df8cae3e5d48edc4f0c42770a207d8812
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoCleanup ShardedDOMTransactionChainAdapter 91/77591/2
Robert Varga [Wed, 7 Nov 2018 23:42:02 +0000 (00:42 +0100)]
Cleanup ShardedDOMTransactionChainAdapter

Inner classes have incorrect structure and can be final, fix that
and also eliminate the need to verifyNotNull().

Change-Id: I68a68f69e6e7e7f442783858dfd719e7ca374bfb
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoBump yangtools to 2.1.3 88/77588/4
Robert Varga [Wed, 7 Nov 2018 20:48:17 +0000 (21:48 +0100)]
Bump yangtools to 2.1.3

This adopts yangtools-2.1.3.

Change-Id: I6c67a060fa24d06553c6b6076acfa85f6f35718e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoRework lookup to eliminate the need for checkArgument() 89/77589/2
Robert Varga [Wed, 7 Nov 2018 22:03:40 +0000 (23:03 +0100)]
Rework lookup to eliminate the need for checkArgument()

SpotBugs is twitchy around this, let's rework it to make
the precondition unnecessary.

Change-Id: I2083877c1c6b263b6c9d8368cd8f3fb746bbc6d0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoFix AbstractTypeMember toString() 50/77550/1
Stephen Kitt [Tue, 6 Nov 2018 16:08:35 +0000 (17:08 +0100)]
Fix AbstractTypeMember toString()

It shouldn't reference MethodSignatureImpl.

Change-Id: I20c44fe66b76daa5fb8ccd51485e57c1da0e932c
Signed-off-by: Stephen Kitt <skitt@redhat.com>
5 years agoCache reflection operations in AbstractSchemaAwareTest 08/77508/1
Robert Varga [Mon, 5 Nov 2018 15:27:45 +0000 (16:27 +0100)]
Cache reflection operations in AbstractSchemaAwareTest

The design of AbstractSchemaAwareTest requires reflection-based
loading of SchemaContext for each test case, which is slow.

Instantiate weak caches to speed up tests which are co-located
on the same class loader.

Change-Id: I1a79d7e99f6efcccab37445f3de25a74cb6f02b6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoDo not issue empty list merges 79/77479/3
Robert Varga [Sun, 4 Nov 2018 18:31:16 +0000 (19:31 +0100)]
Do not issue empty list merges

List nodes undergo atomatic lifecycle, i.e. they are created
as needed. This means we do issue an empty merge when a list
entry is written from binding -- reducing the number of operations
issued in typical operation.

Also mark BindingToNormalizedNodeCodec.getDefaultNodeFor() as
deprecated, because it should never have been public in the first
place.

JIRA: MDSAL-383
Change-Id: Ie41dbd9d238990f3e136043b87d002bf55557501
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoFix a few eclipse warnings 83/77483/1
Robert Varga [Sun, 4 Nov 2018 21:23:15 +0000 (22:23 +0100)]
Fix a few eclipse warnings

This fixes:
- unneeded else statements
- unnecessary use of a raw type
- generic argument shadowing

Change-Id: Ifd3a83a57a9300a4b3b01ddf93facc892c01bb52
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoRefactor write tracking implementation 78/77478/2
Robert Varga [Sun, 4 Nov 2018 17:29:48 +0000 (18:29 +0100)]
Refactor write tracking implementation

Rather than duplicating code which wraps a package-internal class,
provide a subclass hook in TypedWriteTransactionImpl, so that it
write-tracking defaults to no-op and is optionally wrapped.

This removes a lot of duplicated code, making the result equally
performant and more maintainable. It also removes the need to leak
TypedWriteTransactionImpl.delegate to the package and tracking
them in two fields.

Change-Id: I636818f0048090c145e6fabba198238dad1e6922
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoHide TypedTransaction.datastoreType 76/77476/3
Robert Varga [Sun, 4 Nov 2018 15:22:42 +0000 (16:22 +0100)]
Hide TypedTransaction.datastoreType

This field has a proper accessor, hence we do not need to make
it package-private. Also shorten local variable name used in cast
so we lower verbosity.

Change-Id: Ifd0e83217996f0d14fb84ba42c53b879c68f3b1c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoFix warnings in TransactionAdapter 75/77475/3
Robert Varga [Sun, 4 Nov 2018 15:16:02 +0000 (16:16 +0100)]
Fix warnings in TransactionAdapter

Using a private constructor forces a synthetic accessor being
created, hence make nested class constructors package-private,
eliminating the need to suppress warnings.

Also rename generic arguments so as not to clash with method
generics used in the interface being implemented.

Finally add proper generic arguments, so we eliminate raw type
warnings.

Change-Id: I9ec2bf6b377eed26fd11896e84c99fa8922f4abf
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoAdd DataObjectUtils 02/77102/6
Robert Varga [Fri, 19 Oct 2018 12:42:06 +0000 (14:42 +0200)]
Add DataObjectUtils

Add DataObjectUtils.nullToEmpty(List), which is useful when dealing
with nullable lists being returned from binding DTOs. This also moves
mdsal.binding.spec.util to yang-binding, so the utilities are
available to all model users.

Change-Id: I681c49141b4e880448747a53d749065208f9aca1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoAdd @NonNull annotation to LazyDataTreeModification 74/77374/3
Robert Varga [Wed, 31 Oct 2018 08:49:16 +0000 (09:49 +0100)]
Add @NonNull annotation to LazyDataTreeModification

This fixes a couple of eclipse warnings and makes the code a bit
more dense.

Change-Id: Iab34963d54a6ee0f38a05e327c00c202ea9bf3b9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoReduce use of javax.annotation annotations 32/76732/21
Robert Varga [Mon, 8 Oct 2018 09:12:50 +0000 (11:12 +0200)]
Reduce use of javax.annotation annotations

The annotations in use have runtime retention, which triggers
generation of import-package for javax.annotation, which is no longer
satisfied with newer JDKs.

Use JDT @Nullable annotation instead. Since @Nullable is TYPE_USE
annotation, this also requires a bit of juggling in JavaFileTemplate
to make it work correctly with types which end up being referenced
via their FQCN.

This still retains javax.annotation.CheckReturnValue, but marks it
for replacement once we decide where to go annotation-wise.

JIRA: MDSAL-372
Change-Id: I792094d3c07162a5f8e6ca82ceea3a75b48c7b6e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoReport non-present initial data in (DOM)DataTreeChangeListener 70/77070/7
han [Thu, 18 Oct 2018 03:08:34 +0000 (11:08 +0800)]
Report non-present initial data in (DOM)DataTreeChangeListener

Add a default method 'onInitialData' with no-op in
DOMDataTreeChangeListener', which would be invoked only once during
registration of the listener if there was no data in the conceptual
data tree for the supplied path, which was used to register this
listener, and after this 'onDataTreeChanged' would always be
invoked for data changes.

Users not caring about this event could leave it as default with no-op.

JIRA: MDSAL-217
Change-Id: I3a2c02c76b8c37ac7624dd1646692bd783a3468d
Signed-off-by: Jie Han <han.jie@zte.com.cn>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoAdd missing @Beta annotations for managed txes 25/77325/2
Stephen Kitt [Mon, 29 Oct 2018 15:35:55 +0000 (16:35 +0100)]
Add missing @Beta annotations for managed txes

ManagedTransactionRunner is marked @Beta, but the related interfaces
ManagedTransactionFactory and ManagedTransactionChain aren’t. This
patch fixes that; hopefully it’s acceptable for a patch release...

Change-Id: I1d67551ae8bba12b515b31e0611bb5b713d20644
Signed-off-by: Stephen Kitt <skitt@redhat.com>
5 years agoUse equals() in AssertDataObjects 34/61334/8
Stephen Kitt [Tue, 8 Aug 2017 12:55:11 +0000 (14:55 +0200)]
Use equals() in AssertDataObjects

Currently, AssertDataObjects.assertEqualBeans() relies entirely on
XtendBeans’ conversions; but what we really want to test is the
equals() implementations — XtendBeans is helpful to produce errors
which are easier to understand and act upon.

This patch tests the beans using equals() first, and only uses
XtendBeans to produce an error message. It also catches cases where
equals() fails but the XtendBeans-generated representations are
equal.

Change-Id: I8412609c54795b3d7c27001f01d3df281203bb78
Signed-off-by: Stephen Kitt <skitt@redhat.com>
5 years agoTry harder to acquire class mapping 91/76991/4
Robert Varga [Mon, 15 Oct 2018 12:44:48 +0000 (14:44 +0200)]
Try harder to acquire class mapping

We can perform a third try when we failed to load an augmentation
using TCCL by installing the candidate class classloader as the TCCL.

This can help in situations where we are invoked from a context where
the TCCL is not set up to actually see binding classes properly.

JIRA: MDSAL-379
Change-Id: I56d65494cbce32aee0592e3f0799a2bf283e6d17
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoRelax LazyDataObject.augmentations() implementation 69/76969/7
Robert Varga [Sat, 13 Oct 2018 09:35:56 +0000 (11:35 +0200)]
Relax LazyDataObject.augmentations() implementation

We use double-checked locking to guard against concurrent
initialization of cachedAugmentations. While this ensures we do
not do the same work twice, it is a bit costly for the typical
case when the augmentations field is accessed once.

During the first call, we perform:
- a volatile read
- a lock acquire
- a volatile read
- compute the value (exclusive)
- a volatile write
- a lock release

Rather than doing that, allow the value to be computed concurrently
and use compare-and-swap to initialize it. Hence for the first call
we perform:
- a volatile read
- compute the value (concurrent)
- a compare-and-set

In case of concurrent initialization, all threads will compute
the value, but all except the first one will issue another volatile
read and throw their work away.

JIRA: MDSAL-377
Change-Id: I1dbf9c4e60cf9800720eea31bd9de936b1dae5aa
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoSpeed up DataObjectCodecContext instantiation 88/76988/3
Robert Varga [Mon, 15 Oct 2018 10:22:09 +0000 (12:22 +0200)]
Speed up DataObjectCodecContext instantiation

Do not bounce multiple times to bindingClass(), but rather store
it in a local variable. Since we are here, also update other callers
of bindingClass().

Change-Id: Ia093d5dbdff16f6ec17f96c71895cb292eb12862
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoDo not instantiate entrySet when not needed 85/76985/1
Robert Varga [Mon, 15 Oct 2018 09:00:12 +0000 (11:00 +0200)]
Do not instantiate entrySet when not needed

reloadAllAugmentations() does not need the key, hence we do not
need to instantiate entrySet(), values() is sufficient.

Change-Id: Ib58b5fac547370709ab916ca5f700bc4b841efb8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoShorten java.util.Optional reference 74/76974/1
Robert Varga [Sun, 14 Oct 2018 00:07:07 +0000 (02:07 +0200)]
Shorten java.util.Optional reference

All of our codebase is using JDK Optionals, hence we need not use
a FQCN.

Change-Id: Ib6b4fba3e8021fce4d238f8db84db32ac5bf746c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoBump versions for 3.0.2-SNAPSHOT 72/76972/1
Robert Varga [Sat, 13 Oct 2018 12:55:53 +0000 (14:55 +0200)]
Bump versions for 3.0.2-SNAPSHOT

This starts the next version development.

Change-Id: Ia3e479b1d364d6f92e7ff8405ada398c342227a6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoBump yangtools to 2.1.2 71/76971/1
Robert Varga [Sat, 13 Oct 2018 12:52:30 +0000 (14:52 +0200)]
Bump yangtools to 2.1.2

This propagates the released version.

Change-Id: I404e82dcb0aa6102ef00fb1ee65cbbf7aa8f821a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoOptimize AbstractBuilderTemplate key property sort 60/76960/1
Robert Varga [Sat, 13 Oct 2018 08:54:39 +0000 (10:54 +0200)]
Optimize AbstractBuilderTemplate key property sort

Rather than using a lambda for each comparison, create a constant
Comparator and reuse it.

Change-Id: I0b5af97b485f65924adb2de369a69e03027af887
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoOptimize AbstractBuilderTemplate.generateAugmentField() 58/76958/3
Robert Varga [Sat, 13 Oct 2018 08:08:42 +0000 (10:08 +0200)]
Optimize AbstractBuilderTemplate.generateAugmentField()

This moves the "private" field to its sole caller, eliminating
the need for a redundant IF. Also cache the importedName result
so we do not make multiple round-trips to cache.

Change-Id: I31bd9ffe51e6820d6b4b22f489ed0fbaf9dd1192
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoUse ArrayList.sort() instead of Collections.sort() 59/76959/2
Robert Varga [Sat, 13 Oct 2018 08:38:32 +0000 (10:38 +0200)]
Use ArrayList.sort() instead of Collections.sort()

We do not need Collections, as we have Java 8 and hence can
directly use List.sort(). This has the side-effect of
short-circuiting to ArrayList's implementation.

Change-Id: If978265242275014c586fcf92d96d5ba09bb7bca
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoBuilder should acquire augmentations only once 57/76957/2
Robert Varga [Sat, 13 Oct 2018 08:28:34 +0000 (10:28 +0200)]
Builder should acquire augmentations only once

While generated DataObjects have this method simple, LazyDataObject
constructs the map lazily and caches it -- hence additional access
is forcing an additional volatile read.

Therefore instead of invoking augmentations() twice, store its
result in a local variable and reuse that.

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