Robert Varga [Sun, 11 Mar 2018 21:06:02 +0000 (22:06 +0100)]
Add QName.withModule(QNameModule) method
In situations when a companion QName with specified QNameModule needs
to be created, we can side-step localName checking and just directly
reuse it. QName.withModule() does precisely that.
Change-Id: Ib1ca72210c0114610dafba0dfbbce15a2b8ddc03
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit
010c1f2204d4f0408a10b81a51c14933522825ad)
Robert Varga [Mon, 9 Apr 2018 13:38:33 +0000 (15:38 +0200)]
Improve ClassLoaderUtils.loadClassWithTCCL()
There are scenarios when we do not have a Thread Context Class Loader,
such as when executing from Netty's GlobalEventExecutor. When we attempt
to load a class in that scenario, the method will throw a NPE, which
exposes users which can deal with the class not being able to load
to a RuntimeException -- preventing recovery.
Detect the case when TCCL is null and report a failure to load the class,
noting the reason for the failure.
Change-Id: Ia6837ba451d290a2070bc24e9e7088c60275cae0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit
4a3cc19a42b3740ec518569ca274153b66f2bc82)
Robert Varga [Thu, 29 Mar 2018 21:59:34 +0000 (23:59 +0200)]
Fix leafref require-instance implementation
Both identityref and leafref types default to require-instace=true,
hence we should be starting with that and also properly inherit
the property from the parent type.
Add RequireInstanceRestrictedTypeDefinition to capture the common
method and adjust RequireInstanceRestrictedTypeBuilder to check
for it and initialize the require-instance value appropriately.
JIRA: YANGTOOLS-872
Change-Id: I125d5687950af21694c4510ce64adb00f92ae4e6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit
38ca7ba1b5222af644f0e782f2876db9e9a58f05)
Luis Gomez [Sun, 25 Mar 2018 16:52:28 +0000 (16:52 +0000)]
Revert "Realign ImmutableMapNodeBuilder and XML JSON builder"
This reverts commit
86d0422023815ba00acbd6bc73d0f6244ae7641e, which
breaks data formatting.
JIRA: YANGTOOLS-870
Change-Id: I1cd7ae954c1bebf1e55bf3ab5e78605160f52734
Signed-off-by: Luis Gomez <ecelgp@gmail.com>
Atul Gosain [Fri, 16 Feb 2018 20:41:32 +0000 (12:41 -0800)]
Realign ImmutableMapNodeBuilder and XML JSON builder
This patch removes the AugmentationNode wrapper for mapEntryNodes
as the ImutableMapNodeBuilder expects a different heirarchy.
This made the JSON parsing to normalized node in parity with XML codec.
JIRA: NETCONF-486
Change-Id: I25d32acfe7797e0744b42ef7a5f46ab01971c2a8
Signed-off-by: Atul Gosain <agosain@luminanetworks.com>
(cherry picked from commit
69af38512473463b4e8be9f8b30c80f727b31d84)
Robert Varga [Thu, 8 Mar 2018 01:12:43 +0000 (02:12 +0100)]
Optimize augment conflict checking
When we are validating whether a node can be introduced, we end up
needlessly iterating when the source is not a DataDefinitionStatement
and also end up running comparison when a substatement is not a
DataDefinitionStatement,
Refactor the code to take these invariants into account.
Change-Id: Ie55c7dfebacfad1189de1929c23809fd284958b4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit
6e4ed947d08856771dbbdf428ba84c44aed45126)
(cherry picked from commit
3ca3fc462aec22eb2dec19066edafbb039cb2a84)
Robert Varga [Tue, 6 Mar 2018 09:51:00 +0000 (10:51 +0100)]
Fix format string
checkArgument uses String.format() strings, not logger.
Change-Id: I723924bee6cafddda2cbc88362c3f5898e17da6a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit
923eebd3356ac4c02951d398ba3161d4337272e3)
Robert Varga [Mon, 5 Mar 2018 14:11:45 +0000 (15:11 +0100)]
Validate parsed QName to identity
We need to validate if parsed QName refers to an existing identity,
this fixes up unused AbstractModuleStringIdentityrefCodec to check
Module references.
Change-Id: Iebbb43681e9b384c43bd81607d169294373bdd72
JIRA: YANGTOOLS-846
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit
86ed935221b79680e8aca7a5e561fed6d89ed084)
Robert Varga [Thu, 22 Feb 2018 14:01:52 +0000 (15:01 +0100)]
Validate parsed QName to identity
We need to validate if parsed QName refers to an existing identity
before allowing it in Identityref codecs. Introduce IdentityCodecUtil
along with a test suite and migrate users over.
JIRA: YANGTOOLS-846
Change-Id: I673ae6df4406110202b86329121a3ca9673fb0ed
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit
e7e0e48e6a79b08bb2c976ee3fd69582d84a7e4c)
Robert Varga [Tue, 20 Feb 2018 18:12:19 +0000 (19:12 +0100)]
Encapsulate regexes in a non-capturing group
Regular expressions are pesky, nwo we are being bitten by branches.
Let's just encapsulate the internal pattern into a non-capturing
group and be done with it.
JIRA: YANGTOOLS-798
Change-Id: If3b3b2fb35ecd336bc23fd7acaf29efa48eb9b74
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit
42b62f098cbabbc286c3a506494c5e280f6c365b)
Robert Varga [Wed, 21 Feb 2018 09:43:03 +0000 (10:43 +0100)]
Move Bug4079/Bug5410 tests from yang-parser to yang-model-util
This co-locates the unit test with the class tested.
Change-Id: Ib7d044208946be3347e1b1aedbd87a0cfe1e5a23
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit
cc0855ee7a788a4ef96592f055e8a22698f024b3)
Robert Varga [Sun, 4 Feb 2018 20:04:57 +0000 (21:04 +0100)]
Correct double-quoted string whitespace trimming
We need to trim leading and trailing whitespace when it comes from
YANG text, so that the resulting string matches expectations.
This patch adds the required trimming.
JIRA: YANGTOOLS-845
Change-Id: I21777583c5d18819e68c089cd9f2cf51179b0530
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit
664c9179f9b7dc85a1cf7ef004fbd2da849dceae)
(cherry picked from commit
06aa2008e3f29f53fe2af802b49f9c9a8c912c6b)
jenkins-releng [Fri, 23 Feb 2018 14:26:53 +0000 (14:26 +0000)]
Bump versions by x.y.(z+1)
Change-Id: I5e97d33512eb5bf862fe258976f2b96384d0c06e
Signed-off-by: jenkins-releng <jenkins-releng@opendaylight.org>
Atul Gosain [Wed, 29 Nov 2017 02:07:08 +0000 (18:07 -0800)]
Handling empty text nodes
This is a fix for an issue seen in the patch 63984 on yangtools.
It handles text nodes which are empty.
Change-Id: I6cf1096c511758154df6121d26bf36184385403f
Signed-off-by: Atul Gosain <agosain@luminanetworks.com>
(cherry picked from commit
cedf67270d96f385d0c2154582c6ada267b0c005)
Tomas Cere [Tue, 3 Oct 2017 10:36:26 +0000 (12:36 +0200)]
BUG 8927: Netconf response payload fails to render in JSON
JSONNormalizedNodeStreamWriter does not write a content of anyXml nodes
correctly mainly due to Text nodes containing whitespaces before, between
or after Element nodes. Therefore the first Text node only was serialized
to JSON and the rest of anyXML content was missing.
This patch provides fix of anyXml content serialization to JSON.
Added a fix for a null pointer for empty text node.
Fixed the unit test to pass the anyxml test.
Change-Id: I74f34aecec1a85b2ede4be63e5b6dd74522981e4
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Signed-off-by: Atul Gosain <agosain@luminanetworks.com>
Signed-off-by: Balaji Varadaraju <bvaradar@brocade.com>
Robert Varga [Tue, 7 Nov 2017 18:28:53 +0000 (19:28 +0100)]
YANGTOOLS-827: fix revision compare
When revision statements do not follow guidance from RFC6020/RFC7950
section 7.1.9 and are not order in the order of descending date and
the delta between previous and next version strings is not exactly 1,
we end up picking the wrong version.
This is caused by wrong compareTo() check, which should compare '< 0',
not '== -1'.
Change-Id: Ib7f9a77a9950b6da93ffa30e4c13cc940887ad19
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit
3c855240dd70f79e7acd9fa98adb8c6a3580f60b)
Robert Varga [Sat, 28 Oct 2017 11:09:42 +0000 (13:09 +0200)]
YANGTOOLS-823: take modifier into account when enforcing patterns
Modifiers are an RFC7950 addition to the metamodel and need to be
accounted for to comply with the specification.
Change-Id: Ide9625812a2df26e931a2b5d472af80bba07d730
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Igor Foltin [Tue, 17 Oct 2017 14:08:18 +0000 (16:08 +0200)]
Bug 9242: Reuse deviating statement contexts
In the process of deviate add/replace resolution we make
copies of deviated statement contexts which are then added
to the deviation target context.
However, making copies of these statement contexts is not
necessary except the ones which represent unknown statements.
Therefore, reuse them during the resolution of deviate add/replace.
By doing this, we also solve the failing deviate replace with
user-defined types as statement contexts that represent deviating
user-defined types are now resolved within their original context.
Change-Id: Ie61a38e270ef648fe61ea283805d149533c10f62
Signed-off-by: Igor Foltin <igor.foltin@pantheon.tech>
Igor Foltin [Tue, 17 Oct 2017 09:07:51 +0000 (11:07 +0200)]
Bug 9244: Fix deviate replace of implicit substatements
In case when a deviate replace of a config/mandatory/max/min-elements
substatement targets a node which does not contain an explicitly declared
config/mandatory/max/min-elements, YANG statement parser throws an exception
because it did not find the substatement in the target node.
However, according to RFC6020/7950, these properties are always implicitly
present. Therefore, perform a deviate add instead of throwing an exception
in this particular case.
Change-Id: I79e5c427040c81db7f2f68ebcfa71b274d48816d
Signed-off-by: Igor Foltin <igor.foltin@pantheon.tech>
Igor Foltin [Fri, 13 Oct 2017 10:02:58 +0000 (12:02 +0200)]
Bug 9241: Action definition should implicitly define input/output
Empty input and output statements are now automatically added to
every action statement that does not declare them explicitly.
Change-Id: I41c037657e83b8e53d314d9b9c6c691ef99e993f
Signed-off-by: Igor Foltin <igor.foltin@pantheon.tech>
jenkins-releng [Tue, 17 Oct 2017 01:39:44 +0000 (01:39 +0000)]
Bump versions by x.y.(z+1)
Change-Id: I66aac3d7400f75b059252ca13f3c3615484ee3bb
Signed-off-by: jenkins-releng <jenkins-releng@opendaylight.org>
Robert Varga [Fri, 18 Aug 2017 12:56:51 +0000 (14:56 +0200)]
Fix AnyXml node handling
Fixup the mixup of calling instanceof on an Optional.
Change-Id: I184e2ad7535129cf19c41dfd5c235285e82e9f28
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit
7746599ddc0043b518e263faf8a41aa0e3653f92)
Peter Kajsa [Mon, 14 Aug 2017 17:35:33 +0000 (19:35 +0200)]
Bug 7246 - Fix of SchemaTracker initialization and lookup of schema nodes
SchemaUtils methods perform lookup in both the namespace of groupings and
the namespace of all leafs, leaf-lists, lists, containers, choices, rpcs,
actions, notifications, anydatas, and anyxmls. In consequence, performed
lookups are ambiguous due to possible name conflicts between these namespaces.
Change-Id: Icd3e141b21d0adaf0126b539454e640c0ea0b5a6
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
(cherry picked from commit
d77eb113748d9571c5bd9588e8f6c745182b8b05)
Peter Kajsa [Thu, 7 Sep 2017 11:18:22 +0000 (13:18 +0200)]
Bug 8713 - BGP models not compatible with leafref context
Lookup of parent module should be performed based on the first path
argument from root not the last one.
Change-Id: Ic8e0dc901056caf93e4fc5266334434bd067d9ab
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
(cherry picked from commit
f1193617e74d40724cc53df1f5a4f007dc135f2b)
Robert Varga [Sat, 26 Aug 2017 16:50:55 +0000 (18:50 +0200)]
Throw SourceException instead of IllegalArgumentException
TypeUtils already considers StatementSourceReference, so instead
of home-grown format use SourceException.throwIf().
Change-Id: Ifc81db735d72bb7c98b94c66ac013f8dcc47413c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit
4a6f8307db1a3e9f31608a73924f48ed2ea7dc6e)
(cherry picked from commit
9be7f96ec29f2ba9782085d5029420889a6d9812)
Peter Kajsa [Fri, 18 Aug 2017 10:24:32 +0000 (12:24 +0200)]
Bug 9005 - scope of model import prefix should be module/submodule
Yang parser includes all substatements of a submodule into a parent
module including all import statements of the submodule, what causes
mismatch of parent module imports.
Change-Id: I5c0b45348ca5e9f3ae54351c93e940135fe2b99d
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
Peter Kajsa [Tue, 8 Aug 2017 16:11:16 +0000 (18:11 +0200)]
Bug 8922 - Evaluation of if-features is done regardless of ancestors
Evaluation of if-features for a statement is done regardless of its
ancestors. This is not correct and if an ancestor of a statement is
not supported by features, then current statement should be
unsupported too. In other words, if a statement is not supported by
features, then all its children should be unsupported too.
Change-Id: Ieb8a3c32849808a4492f518f4481aaef45c11cae
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
(cherry picked from commit
668b0262993e44cb007754a0fdf08c0edb7649d2)
Peter Kajsa [Thu, 6 Jul 2017 08:05:01 +0000 (10:05 +0200)]
Bug 7051 - Refactoring of StmtContextUtils
Refactoring of StmtContextUtils in order to remove undesired dependencies
on stmt.rfc6020 package.
Change-Id: Ia0e494ba792e9eb8a92aadebb806748af5fe8cee
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit
b9bda31186b0587d699373321b5ce19717dbc873)
Peter Kajsa [Tue, 4 Jul 2017 10:56:39 +0000 (12:56 +0200)]
Bug 7051 - moving of SubstatementValidator into spi.meta package
Moving of SubstatementValidator into spi.meta package in order
to remove undesired dependencies between parser packages.
Change-Id: If0b3bb969c25c37fb4658fa9c4659d53e13c04bb
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
(cherry picked from commit
0c39d30a237a61b7a7eb0fecb066004ff561e1a9)
Peter Kajsa [Fri, 4 Aug 2017 13:28:29 +0000 (15:28 +0200)]
Bug 8831 - Yang 1.1 default values are not checked correctly
When a leaf has a union type, and a default that does not correspond
to the first member of that union type, the default is not processed
correctly and IllegalStateException is thrown during the check of if-feature
statements. The same bug occurs also in case, when the default is a
number, which is in the range of the first member of the union etc..
Change-Id: Ic3b165eb5c4416dee2216f47c240ce596e3f7dd2
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
(cherry picked from commit
6f90351f01d34979e9d22f5e6235b785d8091b14)
Robert Varga [Thu, 3 Aug 2017 09:29:44 +0000 (11:29 +0200)]
Cleanup SchemaTracker logic
Do not perform duplicate null checks.
Change-Id: If1fa8631e9e6d93fa2063bea0c395d3fdcba87ea
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit
8ac02d36bb5189e29514d837600f45e8eb546d36)
Robert Varga [Wed, 19 Jul 2017 12:10:17 +0000 (14:10 +0200)]
BUG-7464: do not depend on odlparent's triemap
We have our internal fork, not need to pull in odlparent packaging
of it.
Change-Id: I8910df0e484e81bb7a5c7c554833889c8ce336f0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit
e681992fd29a336c0dc932d28bc7a7e0ca0eaf9a)
Robert Varga [Tue, 14 Feb 2017 09:13:49 +0000 (10:13 +0100)]
BUG-7464: Switch to use forked TrieMap
Switch from dead upstream to our forked version of TrieMap.
Change-Id: Ide40b87b96d16500e2a8566d3d627ca1aac8d762
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit
cffa4941b89f7a054867a27410ab3053ef1a79be)
Igor Foltin [Wed, 26 Jul 2017 11:14:06 +0000 (13:14 +0200)]
Bug 8803: check for null return NamespaceContext.getNamespaceURI()
The javadoc indicates that for unbound prefixes this method should be
returning NULL_NS_URI (which is defined as an empty string), and there
is no mention of the possibility of returning null anywhere.
Nevertheless JDK8-default XMLOutputWriter returns null for unbound
prefixes, which leads to an infinite loop in RandomPrefix.
Fix this by adding an explicit check for null, too.
Change-Id: Ib8af7d03eb59b004f2fcb4d1806c0f4f256a974a
Signed-off-by: Igor Foltin <igor.foltin@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit
9946267ef128228dad7d6cc9dd5319bfad081756)
Signed-off-by: Igor Foltin <igor.foltin@pantheon.tech>
Robert Varga [Tue, 25 Jul 2017 11:27:54 +0000 (13:27 +0200)]
BUG-8733: add YangInstanceIdentifierBuilder.append()
In scope of BUG-8733 we need the ability to efficiently append
a set of PathArguments. Introduce a Builder method to do exactly
that.
Change-Id: I06e655490dd5c7e92588eeb5a5e5237479e7ff7e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Fri, 21 Jul 2017 09:07:09 +0000 (11:07 +0200)]
BUG-8733: add EmptyDataTreeCandidateNode
This class is used by multiple downstreams, hence it is useful to
expose it from DataTreeCandidateNodes.
Change-Id: I88e247c3a9a2cb7fffab4d73f6f8b7ef211a3ea0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Fri, 7 Jul 2017 08:41:13 +0000 (10:41 +0200)]
BUG-6972: eliminate StmtContext.getOrder()
This is not really used, so try to eliminate it, saving a couple
of bytes in StatementContextBase.
Change-Id: If9a5126c9110f50324bb94b7fecdb3845874b763
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit
ff2e82f6d14803a316c81f0ebf980435eb330976)
Robert Varga [Fri, 7 Jul 2017 00:22:06 +0000 (02:22 +0200)]
BUG-6972: Add OptionaBoolean utility
This utility allows us to store an optional boolean in a byte field,
reducing the cost from 2 bytes (two boolean fields) or 4/8 bytes
(reference) to a single byte.
Also converts eligible classes. Trims down StatementContextBase
and DeviateEffectiveStatementImpl.
Change-Id: I5444bd4bb7aa0ea52202b08fcfcf9207ea045fa9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
jenkins-releng [Fri, 14 Jul 2017 12:49:22 +0000 (12:49 +0000)]
Bump versions by x.y.(z+1)
Change-Id: I49a87bc1be2779bfdd8c79f91365b6ba843c608a
Signed-off-by: jenkins-releng <jenkins-releng@opendaylight.org>
Igor Foltin [Tue, 20 Jun 2017 14:01:17 +0000 (16:01 +0200)]
Fix uninitialized ExtensionDefinition for openconfig-version
The StatementDefinition for openconfig-version extension is
not bound to any revision. When populating the ExtensionNamespace
with openconfig-version, we have to store it with a revisionless
QName key. This way we can properly extract the corresponding
ExtensionDefinition later down the road in the
UnknownEffectiveStatementBase.
This issue causes NPE in MDSAL's binding generator v2.
Change-Id: Ie24c09b56986c87b5118d715ec6c8e755cf07ebe
Signed-off-by: Igor Foltin <igor.foltin@pantheon.tech>
Robert Varga [Mon, 12 Jun 2017 15:21:42 +0000 (17:21 +0200)]
Bypass array-based sort
This makes unneeded copies, move over to Iterable-based sort.
Change-Id: I58d4b6b31e4e7927c1139bc6e2920a4e783597f8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit
9c88733c10ba6098c7a694891e75209aeb58b78a)
xygeng [Mon, 12 Jun 2017 07:57:50 +0000 (15:57 +0800)]
Bug 6897: [YANG 1.1] Allow notifications to be tied to data nodes
Change-Id: I6143907b8d2ee1b9e78cb9d76c0db3d252419f00
Signed-off-by: Geng Xingyuan <geng.xingyuan@zte.com.cn>
(cherry picked from commit
be42023bdd6d1ef6f310c73c33a5ea5cbbc96cb9)
Robert Varga [Fri, 9 Jun 2017 00:11:29 +0000 (02:11 +0200)]
Make getOriginalCtx() give out an Optional
This simplifies its users and make things more streamlined, by
eliminating a source of nulls. While we are at it, migrate some
optionals.
Change-Id: I9f5c051db33b1898ca5decd523055adbd1309855
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit
cc5aa8ec1c4c108d1f397ff5f8c516f29813c85b)
Robert Varga [Thu, 8 Jun 2017 23:38:56 +0000 (01:38 +0200)]
BUG-6972: inline copy operation modifications
Copy operations is really internal to StatementContextBase hence
all the work of setting state can be done in the constructor.
This allows us to make some of the state final. While it does not
help the footprint issue, it is a stepping-stone to defining a
proper set of copy operations.
Change-Id: I0586ecb0757a3126b9e4ed3dbd0ea6c5a2547544
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit
e807a055a1f878b4e0fd74d5763caaa7ab16a8c7)
Robert Varga [Thu, 8 Jun 2017 17:02:49 +0000 (19:02 +0200)]
BUG-6972: Do not allow root StmtContext to be copied
It cannot be targeted, hence it does not make sense to copy it.
Removes a chunk of duplicate code and takes this class out of the
picture where copy operations are concerned.
Change-Id: I7a8d46ba59658a534534cd8204c43d894d017247
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit
36a5673da061c01ed2c3c58e4e3b418b01e9876a)
Robert Varga [Thu, 8 Jun 2017 16:43:21 +0000 (18:43 +0200)]
Eliminate StmtContext.isRootContext()
This condition is already available by checking getParent(), so there
is no need for method proliferation.
Change-Id: I7eaeca1655dbdffe1a6738f439b12afa165e30b5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit
9bb8886df13969f7b58c68e5aa54e0392d2641bc)
Robert Varga [Thu, 8 Jun 2017 15:47:53 +0000 (17:47 +0200)]
Remove appendCopyHistory from public view
This is an internal detail of the copy process, hence it should not
be visible in StmtContext.Mutable.
Change-Id: I890af7f9f8273fc3960c4acd5340fa97f5c3c6c2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit
e28214eff8cd0865813eccfcd51fcff08e633cdc)
Robert Varga [Thu, 8 Jun 2017 00:09:44 +0000 (02:09 +0200)]
BUG-7052: Move qnameFromArgument to StmtContextUtils
This has no dependencies on RFC6020, move it to common statement
utilities. Also takes all utility methods used by it.
This removes {BuildGlobal,Substatement}Context->rfc6020.Utils and
rfc6020.Utils -> reactor.RootStatementContext dependencies, which
by defition is Good.
Change-Id: I9ff90a0be8c4eaee2c085c9333a71c12619d2d7c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit
742be43770eb77e1898466d3d887422cc9127e40)
Robert Varga [Mon, 5 Jun 2017 16:50:10 +0000 (18:50 +0200)]
Do not tolerate invalid status arguments
Status must be one of current, deprecated, obsolete. Make sure we
do not leak nulls when the model supplies an illegal string, but
rather flag the offender.
Change-Id: I3301eaf2f753fe74a24dfa30d8e74cbf3a571493
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit
d25e1c05a0af0930ad1fa469d2edbd30b24a43dc)
Robert Varga [Wed, 7 Jun 2017 22:51:21 +0000 (00:51 +0200)]
BUG-7052: reduce StatementContextBase proliferation even more
This splits up the mutable and immutable views of declared/effective
statements so we do not access mutable state when all we need is
immutable view.
The mutable view now has only StmtContext.Mutable, hence users get
more isolation from the reactor implementation.
Change-Id: I3e77b3837beea533590cad681c1895e047c9a2a6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit
12880a5876c644243ba46ce8c674f29a7d0c773a)
Robert Varga [Thu, 8 Jun 2017 06:58:07 +0000 (08:58 +0200)]
BUG-7052: Move RecursiveObjectLeader to util
This is a general utility. Expand warnings and move it to util,
reducing more reactor->rfc6020 dependencies.
Change-Id: If21a560633f31bb25edaed8ac8e87b882f27dc83
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit
b704d772ac1fb2bb55a5f817d2173274a7f83fab)
Robert Varga [Wed, 7 Jun 2017 21:31:40 +0000 (23:31 +0200)]
BUG-7052: reduce StatementContextBase proliferation
In some places we require StatementContextBase where only a simple
StmtContext or Mutable is enough. Fix those places up and move mutator
methods into Mutable.
This frees up parser.spi from reactor imports and lowers rfc6020's
reliance on reactor internals.
A nice side-effect is that we do not leak the mutable aspect of
StatementContextBase from StmtContext references.
One violation of this contract is caching of 'supportedByFeatures',
which is now costing an instanceof check. Since that is an optimization
this is a fair thing.
Change-Id: I6b4991264ef8c3322260f0962d41eeaa79b1b427
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit
bd36a9a4be114b70b4a8a82a1a5d4b1373513063)
Robert Varga [Tue, 6 Jun 2017 23:43:46 +0000 (01:43 +0200)]
Enforce namespace listener compatibility
If we happened to register a listener to a namespace which does not
support listening, we would silently ignore the listener. Instead
of doing that, complain loudly when such a thing occurs.
Change-Id: If77bbec91571178fe7a1ada169a824d5d8a6807c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit
064d4eae6564dc3892d85caecf87ccdaf4e2ea20)
Robert Varga [Tue, 6 Jun 2017 21:50:24 +0000 (23:50 +0200)]
Refactor InferenceAction
An inference action's prerequisite may only be accessed once the
action fires. Hence require a key context to give out the value
of a particular Prerequisite.
Also audit methods interfacing to StatementContextBase and lower
their expectations where possible.
Change-Id: I71cec8647d7e013598dcdf2faf9d0a46c5105938
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit
7e0c23776039758abe103858c3f9afe490e3035c)
Robert Varga [Mon, 5 Jun 2017 17:19:06 +0000 (19:19 +0200)]
Move DeviateKind parsing
This parser is only used in DeviateStatementImpl, so move it there
and do not clutter Utils.
Change-Id: Ie878f22e5fdd28fc2e3747a1af61a25b92a44d05
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit
4523f8f18be0dfbe81e7a9bfc648d319bb366e7e)
Robert Varga [Tue, 6 Jun 2017 20:55:00 +0000 (22:55 +0200)]
ModifierImpl has no use for phase
Since the field is unused, reduce confusion by not propagating it.
Change-Id: Id541143dffc536b4487628c301950d5f4d98385e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit
7429be41b925370957e59eec2825a6adff713875)
Robert Varga [Tue, 6 Jun 2017 00:41:29 +0000 (02:41 +0200)]
Cleanup effectiveStatements() access
No need to cache the field, as we are typically only iterating over
it.
Change-Id: Ia5d189deca1dbc560c77c17423814db1f7700c0d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit
aa3a77e73cc51fe1286902caab094295b3a4ee91)
Robert Varga [Fri, 9 Jun 2017 09:34:38 +0000 (11:34 +0200)]
Do not duplicate findModuleByNamespaceAndRevision()
This method is already defined as a default method in SchemaContext,
hence there is no need to re-define it.
Change-Id: I419d502bffea6e5f25c60aefb31bf3f14dd3f58e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Fri, 9 Jun 2017 10:00:58 +0000 (12:00 +0200)]
Optimize ModuleDependencySort
This class can use some love to improve its performance:
- eliminate unneeded String.format() calls
- perform revision formatting only when needed
- streamline getModuleByNameAndRevision() to eliminate duplicate
lookups and checks
Change-Id: Iac88e223bb108110a9081ce0e6edcdd748d5b52a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit
add54f1ae94f38ec842ab6810d5da2369d05422d)
Robert Varga [Fri, 9 Jun 2017 09:17:47 +0000 (11:17 +0200)]
Do not create temporary array for module sorting
ModuleDependencySort uses an internal iterable anyway, so expose
that method and pass our temporary set, skipping an unnecessary
copy operation.
Change-Id: I2253ed4edc3837ebb9182bcb1b0069d94e2f83e7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit
c0f132ca8118358f1e41feb196da4f068f130430)
Robert Varga [Mon, 5 Jun 2017 16:46:02 +0000 (18:46 +0200)]
Intern low-cardinality statement arguments
config, mandatory, ordered-by, require-instance, status and
yin-element statements have a fixed number of strings they take as
an argument, hence we can lower the memory overhead by sharing
strings instances.
Change-Id: I9b3f470466db8d3463956e4fb010c77671ac3900
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Tue, 6 Jun 2017 08:13:19 +0000 (10:13 +0200)]
Do not throw IllegalArgumentException
We have enough information to throw a SourceException, so do that
to propagate relevant diagnostics.
Change-Id: I5d7b5db1cba00fc3bea6f63025091086c6d2ed34
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit
5b20a9f51f915e53180f1ff5612be8c999cd554c)
Igor Foltin [Fri, 2 Jun 2017 12:41:49 +0000 (14:41 +0200)]
Bug 8523: Add support for parsing restconf:yang-data extension
Add support for yang-data extension to the YANG statement parser.
This extension is defined in RFC8040:
https://tools.ietf.org/html/rfc8040#section-8
Config and if-feature statements are ignored
when placed within a yang-data extension body.
Change-Id: Iccc1ffc76cf1ba1032552e68a4591d44f586c889
Signed-off-by: Igor Foltin <igor.foltin@pantheon.tech>
(cherry picked from commit
d2d8522c64bede5324547689345e4c0188b5bb87)
Peter Kajsa [Mon, 5 Jun 2017 14:37:42 +0000 (16:37 +0200)]
Bug 8597 - Empty description and reference of ModuleImport in some cases
If a module import is specified without 'revision-date' or with
'revision-date' equal to '1970-01-01', ModuleImport does not have
filled description and reference, even though they are declared
in yang source.
Change-Id: I217d09f5f3718aee6557bec309f53c278895ebe7
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
(cherry picked from commit
f1df7385a93b7cc83278a992f0bbed74e04b96f2)
Igor Foltin [Mon, 5 Jun 2017 13:18:31 +0000 (15:18 +0200)]
Bug 4640: Change semantic-version to openconfig-version
The concept of semantic version already exists in the
openconfig-extensions YANG module in the form of
openconfig-version extension.
Rename the internal representation of semantic-version
statement to openconfig-version in the yang-parser-impl module.
Also adjust existing unit tests accordingly.
Change-Id: Ie647bfce5c1a462e6d269103e55a13e08f163dc6
Signed-off-by: Igor Foltin <igor.foltin@pantheon.tech>
(cherry picked from commit
9ba2970f55594e4c2704b0c590bd92112e0441fb)
Peter Kajsa [Thu, 20 Apr 2017 09:49:14 +0000 (11:49 +0200)]
Bug 7037 - Improve mapping of YANG extensions
Each extension definition is able to create an unknown statement
form of a regular yang statement. Created definitions of regular yang
statements are created only once per each yang statement and extension
definition. So we do not create a new ModelDefinedStatementDefinition
and a corresponding UnknownStatementImpl.Definition for each instance
of a regular yang statement when it is placed in an unknown statement's
body.
Change-Id: I5613eb36273e6b512637fb14456c64b023df3f1f
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
(cherry picked from commit
4fe39dd37465c2bb87f920317849ca5eb044fc3d)
Tomas Cere [Wed, 31 May 2017 11:28:17 +0000 (13:28 +0200)]
BUG 8566 Introduce a fallback for ChoiceSchemaNode lookup
With the way parsing callbacks are handled between netconf and yangtools
theres no hook for case nodes, which we are missing in the path when doing
SchemaNode lookup. This introduces a callback that checks Choice children
for a possible match once the normal lookup fails.
Change-Id: Ieefc6771ec3c6892e00103cbab77f6340f197d62
Signed-off-by: Tomas Cere <tcere@cisco.com>
Robert Varga [Wed, 31 May 2017 16:42:25 +0000 (18:42 +0200)]
Add hook for interning raw argument
Type statement typically has a low cardinality of arguments, hence
we can reuse the same object for things like 'type uint32'.
Change-Id: I34c11e1d1f18f8ecaf260d55eb20ffd09d8ae4b0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Igor Foltin [Tue, 16 May 2017 12:04:38 +0000 (14:04 +0200)]
Bug 8307: Add the option for activating deviation statements
YANG statement parser currently resolves all deviation statements.
Add the option to specify which of the processed YANG modules
can be deviated by the specified YANG modules. This information is
passed down to the statement parser in the form of
Map<QNameModule, Set<QNameModule>>. If no deviations should be
activated, use an empty Map. In default mode, that is when
the Map is not provided at all, all deviations are activated.
This patch handles only the statement reactor part.
SchemaContextFactory should be fixed in a separate patch.
Moreover, change the rules for allowed deviation target path.
A deviation statement cannot target nodes in the same module
as the one it is defined in. Adjust existing unit tests accordingly.
Change-Id: Ica0f8c09218e50fd4c3efeb4dc08acb4fa418798
Signed-off-by: Igor Foltin <ifoltin@cisco.com>
Signed-off-by: Igor Foltin <igor.foltin@pantheon.tech>
(cherry picked from commit
5079ec96bfeeb7a6ff66e71a114033c7d6c5c7a3)
Robert Varga [Fri, 12 May 2017 13:49:47 +0000 (15:49 +0200)]
Do not use FileInputStream
https://www.cloudbees.com/blog/fileinputstream-fileoutputstream-considered-harmful
Change-Id: Ic3c9fab4ba21ac9da05d96e9a83597426f67331a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit
5190fa2a29692f8200eb971b6819c38cdeae5d38)
Peter Kajsa [Fri, 12 May 2017 12:10:50 +0000 (14:10 +0200)]
Bug 7844 - Unable to create LeafRefContext for leafref
In order to get correct namespace for a prefix used in a leafref
path we need to find the module which contains definition
of leafref path and then a prefix need to be resolved based on
imports of this module.
Change-Id: Icfb599783e90e44935d5e18eea23b0ac0d86cbf0
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
jenkins-releng [Thu, 25 May 2017 18:18:08 +0000 (18:18 +0000)]
Bump versions by x.y.(z+1)
Change-Id: I8dfd91ad4af6664fa75b32f73cc33daced2e9cd1
Signed-off-by: jenkins-releng <jenkins-releng@opendaylight.org>
Vratko Polak [Wed, 26 Apr 2017 14:13:31 +0000 (16:13 +0200)]
Make repo depend on single features only
Change-Id: I33b67267ebcbab193acbfe72611f02a0d0e32b4b
Signed-off-by: Vratko Polak <vrpolak@cisco.com>
Robert Varga [Wed, 26 Apr 2017 16:13:26 +0000 (18:13 +0200)]
Silence all info messages about all features being used
This message:
2017-04-26 17:55:00,136 | INFO | l for user karaf | CrossSourceStatementReactor | 85 - org.opendaylight.yangtools.yang-parser-impl - 1.1.0.SNAPSHOT | Set of supported features has not been provided, so all features are supported by default.
is featured prominently during startup operations. As it turns out,
we do not have a proper API to express 'use everything', hence the
callers, which really mean that, are passing down nulls.
Expose proper Optional-based methods which are as expressive, thus
allowing us to side-step this pesky flood.
Change-Id: I11c95c58be01deac8bbb587883d152fc6e647a6c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Peter Kajsa [Wed, 26 Apr 2017 09:08:56 +0000 (11:08 +0200)]
Bug 8291 - Unit test
Added unit test for Bug 8291.
Change-Id: Iaf41b01924f3d644b94620d2b72968725b2b2177
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
(cherry picked from commit
e95ee66d2753375516ad07fc11ab24844da0a471)
Robert Varga [Tue, 25 Apr 2017 20:32:06 +0000 (22:32 +0200)]
BUG-8291: expose additional DataTreeFactory methods
There are use cases when we want to instantiate a DataTree rooted
at a list itself, which is something we cannot discover from
YangInstanceIdentifier because lists and containers share the same
identifier.
Therefore we need to expose a factory method which takes an initial
SchemaContext, from which we can derive the appropriate root node.
While we are at it, we also expose another factory method, which
takes additionally the initial tree state. Since the state is not
empty, we can run full validation on it before we give out the
DataTree -- allowing us to perform full enforcement of mandatory
nodes.
Change-Id: Id362234b9ef42d93ae01577809fb004864d05d1c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit
cbb18c74acab8a9b77ddf1dc19d988e3d0fe37fc)
Robert Varga [Tue, 25 Apr 2017 17:17:33 +0000 (19:17 +0200)]
BUG-8123: fix URL naming mixup
As it turns out URL.getFile() does the wrong thing, leading to us
taking the whole path as the module name, resulting in wrong comparison.
Change the code to analyze URL.getPath(), stripping it down to the
last component.
Change-Id: Ica3e387caf2924712151f4da5939487872f8e98c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit
c2ca0aa4ddb933bbb4b1f8701c92c4f0d22c08a7)
Igor Foltin [Fri, 21 Apr 2017 15:06:37 +0000 (17:06 +0200)]
YANG XPath functions - unit tests and bugfix
Add more unit tests for YANG XPath functions
in yang-data-jaxen.
Fix deref function for leafrefs that reference
a leaf-list node.
Change-Id: I7bfe90a3a1a101b95a3b8ea3b1dd42963e5ea264
Signed-off-by: Igor Foltin <ifoltin@cisco.com>
(cherry picked from commit
8539503c13746b5b765c9aa9d249a85462f69d7f)
Robert Varga [Thu, 13 Apr 2017 14:18:06 +0000 (16:18 +0200)]
BUG-8123: simplify file name support
As it turns out, we already have the utility classes needed
to parse the file name. Reuse them rather than duplicating their
functionality.
Change-Id: I1ecfeb6ac40ae9ae928b6457807a3fd4c421dc41
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Peter Kajsa [Wed, 12 Apr 2017 08:27:57 +0000 (10:27 +0200)]
Bug 7050 - Document parser-impl package structure
Added initial javadoc to yang statement parser packages.
Change-Id: I2f18eb4ad01fee297f52953f2ef2aae24a69d253
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
Peter Kajsa [Thu, 23 Mar 2017 16:12:33 +0000 (17:12 +0100)]
Bug 7038 - Rework 'type decimal64' lookup
Fix of hack in SourceSpecificContext, which attempts to lookup specific
complex types by considering only a QName's localName and routes
it via BUILTIN_TYPE_SUPPORTS to specific statement support.
This solution introduces argument specific statement sub-definitions.
If a StatementSupport has some argument specific sub-supports, processing
of a statement is routed to appropriate sub-support based on given
statement argument.
Change-Id: I602c0a919107a633f594a4393299f3f6623bd1c5
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
Igor Foltin [Thu, 13 Apr 2017 07:59:35 +0000 (09:59 +0200)]
Update the developer docs
Update the docs related to the usage of
if-feature resolution mode of the YANG statement parser.
Change-Id: Id2201d7082b2b744f98c09801530bc8ad2205d65
Signed-off-by: Igor Foltin <ifoltin@cisco.com>
Robert Varga [Wed, 12 Apr 2017 13:54:23 +0000 (15:54 +0200)]
BUG-8123: be better at guessing identifiers
Given an URI we need to attempt to interpret it to improve our
guess of the module name and revision.
Change-Id: I4d74b06fb9f949c538911d215b6d90a383560f1f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Jakub Toth [Tue, 11 Apr 2017 21:49:18 +0000 (23:49 +0200)]
Implement DocumentedNode interface to RevisionEffectiveStatementImpl
for overriding getDescription() and getReference() methods for
exposing it to others.
Change-Id: Ida77679f952f795d06a044c0fdc8f5c40d9455a7
Signed-off-by: Jakub Toth <jatoth@cisco.com>
Anil Belur [Tue, 11 Apr 2017 01:26:31 +0000 (11:26 +1000)]
Update .gitreview to stable/carbon
Change-Id: Ie757e1c01c9268e97b7503c4787427ae9a976a13
Signed-off-by: Anil Belur <abelur@linuxfoundation.org>
Igor Foltin [Fri, 7 Apr 2017 15:17:23 +0000 (17:17 +0200)]
Bug 7847: Implement YANG 1.1 XPath functions in YangFunctionContext
Introduce implementation of functions re-match, deref, derived-from,
derived-from-or-self, enum-value and bit-is-set in the yang-data-jaxen's
YangFunctionContext.
The functionality introduced in this patch is beta-quality and will
need more thorough testing in the future
Change-Id: Ia89f8b50dd7537cfafc2297ada8720648050bdbd
Signed-off-by: Igor Foltin <ifoltin@cisco.com>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Peter Kajsa [Wed, 5 Apr 2017 13:55:08 +0000 (15:55 +0200)]
Bug 8126 - Some augments are not being processed
If a node is marked as mandatory (e.g. "leaf" with "mandatory true;"),
yang statement parser does not perform augmentation of such node into
a target node in different module even though one of ancestors of the
target node is a non-mandatory choice or a non-mandatory list from the
same namespace as the mandatory node and so in fact it should not
be considered as augmenatation of mandatory node into different module
anymore and augmentation should be performed.
We also increase severity of the augment error log from debug to error.
Change-Id: Icb8554ba61ce0aa0fa25541dd5675f3aa8ba3d1b
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
Robert Varga [Sun, 26 Mar 2017 19:38:00 +0000 (21:38 +0200)]
BUG-7833: Fix identityref codecs
Introduce QNameCodecUtil to help JSON and XML codecs correctly implement
their identityref codecs. As it turns out, both only need to provide
proper mapping functions without having to deal with multiple codec
hierarchies.
The patch is also more strict about parsing the string, as it rejects
malformed identityrefs, i.e. those which contain invalid characters.
This fixes BUG-7833, which is triggered by invalid PUT, where we parse
an empty string as a null identityref.
Change-Id: I1f3086a0f9e930f7782dff8d6c39329d4b28ed14
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Sun, 26 Mar 2017 18:06:21 +0000 (20:06 +0200)]
BUG-7983: unify JSONCodec and XmlCodec methods
This patch introduces TypeAwareCodec to define the common interface
which both these codecs implement. We adjust methods to conform
to this interface.
Change-Id: I25ccaf56c2e6013dee01016efe5fd7c960790f70
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Sun, 26 Mar 2017 15:49:03 +0000 (17:49 +0200)]
BUG-7983: make XmlCodecFactory a subclass of AbstractCodecFactory
AbstractCodecFactory contains everything we need for efficient caching,
the only problem we need to solve is binding to NamespaceContext. This
patch does exactly that, decoupling XmlCodec from the generic Codec
interface, so that serialization and deserialization paths are explicit.
This flushes out the fact that the codecs are not used in the egress
path at all and rely on TypeDefinitionAwareCodec instead. That deficiency
will be fixed in a subsequent patch.
Change-Id: I0bdf8af673893f2dc4fcc8842b64f9bed1bc5236
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Sun, 26 Mar 2017 20:30:13 +0000 (22:30 +0200)]
Speed up XpathStringParsingPathArgumentBuilder
Use an internal ArrayList to lower the amount of pointer-chasing
we do. Also make sure we format the error string only when it is
necessary.
Change-Id: Ic2ce96b45dd44b1d1da24ceb9452a2548f883446
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Sun, 26 Mar 2017 14:57:37 +0000 (16:57 +0200)]
BUG-7983: factor out AbstractCodecFactory
Since the type decomposition logic can be shared between XML and
JSON codecs, factor it out into yang.data.util.codec, where it
can be efficiently shared.
JSONCodecFactory becomes a pure type binding provider, with all
of the logic abstracted out. We also reduce CodecCache method
visibility, as they are a package-private implementation detail.
Change-Id: I58e50dd966915e4e1a691add517c9a6d0b647c80
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Sun, 26 Mar 2017 14:09:40 +0000 (16:09 +0200)]
BUG-7983: extract codec caching from JSONCodecFactory
Caching aspect of CodecFactory is independent of the actual codec,
factor it out for reuse with XML codecs.
Change-Id: Ib6678a038482a2f50a8a55a0065158e3bc840cd8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Fri, 24 Mar 2017 16:37:42 +0000 (17:37 +0100)]
BUG-7996: expose different implementations of JSONCodecFactory
We have four different implementations of JSONCodecFactory, each useful
in different circumstances. Rather than having a singleton create()
method, expose multiple methods so users can pick and choose the
implementation which is best suited to their use case.
Change-Id: I1c2e48ed2bc2734447e08e043d8505b741f1e401
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Tue, 21 Mar 2017 16:29:33 +0000 (17:29 +0100)]
BUG-7996: reshuffle caching logic
This patch reworks JSONCodecFactory internals to split the codecs
by their type, allowing simple codecs to be reused across multiple
leaves.
Efficient implementation of this split requires exposing individual
StringCodec classes -- as we need to avoid the broken union codec.
This also has the added benefit of not performing instanceof checks
multiple types.
JSONCodec interface is updated to not be directly bound to the Codec
interface, but rather provide the GSON-specific methods and to expose
the expected data type class. This change allows us to optimize
the serialization side of union codecs, as they can check the input
data without incurring a ClassCastException.
Union codec is decoupled from AbstractStringUnionCodec and contains
pre-computed codecs. This is needed to eliminate the dependency
on the JSONCodecFactory itself and allow for efficient caching
of the codec without incurring further overhead of having to deal
with mutable codec.
Change-Id: I05f18fbaa4b3160d2a7017ec2428d1577f54af7d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Peter Kajsa [Fri, 10 Mar 2017 13:10:56 +0000 (14:10 +0100)]
Bug 6183 - Shorthand case should create case node in schema tree
According to Rfc7950, if a case statement is omitted and implicit case
node is created, schema node identifiers MUST always explicitly include
the implicit case node identifiers.
This patch deals with both Yang 1.1 and Yang 1 in the same way.
Change-Id: I64fef2aee85855cb6300318f7c97e694b3105a0a
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
Robert Varga [Wed, 22 Mar 2017 07:29:37 +0000 (08:29 +0100)]
Trim down TypeDefinitionAwareCodec
Storing an Optional runs contrary to its usual role and wastes
memory. We can simply calculate the optional and have a nullable
internal field, saving ~16 bytes per codec instance.
Change-Id: I184fbd8f390bf5703b3342a6dd09de599c236554
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Fri, 17 Mar 2017 09:49:43 +0000 (10:49 +0100)]
Cleanup codecs a bit
- prevent unnecessary boxing
- add type arguments
- static methods
- do not use deprecated methods
Change-Id: Ic129d327804d3b28066c84d6101cbe262e2101b1
Signed-off-by: Robert Varga <rovarga@cisco.com>
Robert Varga [Thu, 16 Mar 2017 08:34:42 +0000 (09:34 +0100)]
BUG-7996: Use weak keys in SharedJSONCodecFactory
This speeds up hashing, as weak keys are forcing identity-based
hashCode/equals().
Change-Id: If6b0323ac8e80fc8833a13ff5b4406e908e7f558
Signed-off-by: Robert Varga <rovarga@cisco.com>
Robert Varga [Wed, 15 Mar 2017 18:10:18 +0000 (19:10 +0100)]
BUG-7996: Split JSONCodec into multiple implementations
Make JSONCodecFactory an abstract base class with four different
trade-offs in cpu/memory usage. The only implementation available
to clients is SharedJSONCodecFactory, which behaves exactly like
the previous implementation used to.
One user-visible change is that thread-safe implementations,
including SharedJSONCodedFactory, now keep a shared weak cache
for reuse when the same kind of factory is requested multiple times
for the same context.
Change-Id: I15342e6b4ed68ccbac9c099f63654d7456913934
Signed-off-by: Robert Varga <rovarga@cisco.com>