yangtools.git
4 years agoMigrate from YangInstanceIdentifier.EMPTY
Robert Varga [Fri, 30 Aug 2019 09:10:53 +0000 (11:10 +0200)]
Migrate from YangInstanceIdentifier.EMPTY

This migrates to the replacement empty() method.

Change-Id: I32ca026a33835edb16f8e1e6142e9192c880076b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoAdd a 100K-entry test
Robert Varga [Thu, 19 Sep 2019 21:59:24 +0000 (23:59 +0200)]
Add a 100K-entry test

This adds a test for serialization of a Map of 100K entries,
each of which has the key leaf and a simple constant non-key leaf.
Unlike other tests, this quantifies how well the encoding works
when faced with large maps.

JIRA: CONTROLLER-1919
Change-Id: I306e5175ba595a0967432393766f8317e7205492
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoAdd encoding size asserts
Robert Varga [Thu, 19 Sep 2019 19:20:16 +0000 (21:20 +0200)]
Add encoding size asserts

There is a number of places where we check serialize/deserialize
operations through ByteArrayOutputStream. In order to check stability
(and evolution) of our serialization formats, it is useful to check
the sizes of the intermediate bytes.

JIRA: CONTROLLER-1919
Change-Id: I171894ba3791245a53fe39c2d3238d2341d8ffc4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoAbstractNormalizedNodeDataOutput fails to write out header
Robert Varga [Wed, 11 Sep 2019 14:06:59 +0000 (16:06 +0200)]
AbstractNormalizedNodeDataOutput fails to write out header

In case AbstractNormalizedNodeDataOutput is used in a way, where
NormalizedNodeDataOutput.writePathArgument() is the first method
invoked, the stream header would not be output, leading to it
being unreadable.

Change-Id: I4ababb360129b2ef673d0546333599dd10fbdd9e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRemove NormalizedNodeOutputStreamWriter
Robert Varga [Sat, 7 Sep 2019 09:22:39 +0000 (11:22 +0200)]
Remove NormalizedNodeOutputStreamWriter

This class is tied to NeonSR2 serialization format through subclassing,
where it really is a package-private detail. This leads to two concrete
classes being in existence for a particular format, which simply does
not make sense.

Eliminating this subclass allows us to make Neon SR2 final, thus arriving
and monomorphic or bimorphic invocation of all methods based on whether
we have seen Lithium (well, Oxygen) format at runtime.

Change-Id: I9e0463ec4879900e82cf757006dccfdbeb0d7297
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoDisconnect {Lithium,NeonSR2} implementations
Robert Varga [Sat, 7 Sep 2019 07:54:32 +0000 (09:54 +0200)]
Disconnect {Lithium,NeonSR2} implementations

We will need to define two new serialization formats: one
sharing object value serialization (for NeonSR3) and one
disconnected from it (for Magnesium).

In order to maintain scalability with so many formats, we want
to avoid JIT considering implementations which were not referenced
at runtime. This should make CHA and method dispatch more
efficient.

Since we are isolating things, we also pull ValueTypes lookups
and keep it in the same class for easier understanding.

Change-Id: I3db4e9633db4a75016e17ac31bb38452bcb9f42a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoAdd QNameModule coding
Robert Varga [Thu, 6 Jun 2019 17:36:06 +0000 (19:36 +0200)]
Add QNameModule coding

Coding on QNames is effective when there are a lot of same QNames,
but there are cases where QNames themeselves are not reused --
for example YangInstanceIdentifiers and small read subtrees.

These typically end up using different QNames from a small set
of modules, hence coding modules actually helps them quite a bit.

This patch adds a namespace/revision cache, so that encoding such
QNames is also efficient.

JIRA: CONTROLLER-1898
Change-Id: I6cd0885ef605e4a1bf7b768ffe215e9eb3e2fbc5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoRemove use of thread-local input
Robert Varga [Mon, 3 Jun 2019 19:37:43 +0000 (21:37 +0200)]
Remove use of thread-local input

All callers are only called from top-level constructs, thus
not having a relationship with the context in which they are
deserialized.

JIRA: CONTROLLER-1888
Change-Id: I856f9109480fb83475a20ce4430d02a1dd055522
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoDo not use NodeIdentifierWithPredicates constructors
Robert Varga [Tue, 4 Jun 2019 17:05:55 +0000 (19:05 +0200)]
Do not use NodeIdentifierWithPredicates constructors

This class will transition into a value-based object for memory
efficiency reasons. Switch to using its static factory methods.

Change-Id: I7e21a6ccf1ad999d2d0427769b26dffeac166274
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoRemove use of thread-local output
Robert Varga [Mon, 3 Jun 2019 19:12:44 +0000 (21:12 +0200)]
Remove use of thread-local output

All callers can be safely migrated to using a non-shared writer,
as they all are expected to be apex implementations.

JIRA: CONTROLLER-1888
Change-Id: I87cfa1d3ec415b79c40c29a91ccbd8da2869b27a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoMove byte-based serialization method
Robert Varga [Mon, 3 Jun 2019 18:52:36 +0000 (20:52 +0200)]
Move byte-based serialization method

This is only used in testing, move the method out to testing class.

JIRA: CONTROLLER-1888
Change-Id: Ib18be55467561a2471a74285b062b40d4e9e08c8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoDo not format QNames to string on input
Robert Varga [Tue, 28 May 2019 11:14:34 +0000 (13:14 +0200)]
Do not format QNames to string on input

Profiling has revelead the creation of String for QNameFactory
lookup is taking around 19% of overall cost of
NormalizedNodeInputStreamReader.readQName().

Rather than using concatenation, use a dedicated Key object, which
holds the separated-out localname/namespace/revision strings,
thus allocating a small object instead of a full-blown String.

This improves snapshot deserialization perfomance on a 350MiB
snapshot by about 16%, also resulting in lower memory pressure.

JIRA: CONTROLLER-1897
Change-Id: If3e9e4b332b0a5acbe33aa10fca189bbc7da8c81
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoBump yangtools to 3.0.0
Robert Varga [Fri, 22 Mar 2019 18:32:29 +0000 (19:32 +0100)]
Bump yangtools to 3.0.0

This is bumps yangtools to 3.0.0, adjusting for changed APIs. The
changes specifically include:

- use ListenerRegistry.getRegistrations() instead of it implementing
  Iterable
- adjust for NormalizedNodeStreamWriter interface change
- remove use of *AttrBuilder, as NormalizedNodes no longer hold
  attributes
- DataTreeCandidateNodes.empty() instead of home-grown implementation
- adjust for DataTreeCandidateNode.getModifiedChild() returning Optional
- use QueuedNotificationManager.BatchedInvoker

Change-Id: Ia30d73ccf6380e3759414b3026b822df0950a481
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoRemove unused exceptions
Stephen Kitt [Mon, 23 Jul 2018 14:45:38 +0000 (16:45 +0200)]
Remove unused exceptions

This drops exception declarations which are never used.

Change-Id: Icc8938b9c3b437a0d5961ec1b481fd06c52d47f2
Signed-off-by: Stephen Kitt <skitt@redhat.com>
6 years agoHandle empty type in NormalizedNode streaming
Tom Pantelis [Sat, 20 Jan 2018 00:19:03 +0000 (19:19 -0500)]
Handle empty type in NormalizedNode streaming

The yang "empty" type is now represented as
org.opendaylight.yangtools.yang.common.Empty so handle it.

NormalizedNode no longer allows a null value but we still need
to handle NULL_TYPE on input for backwards compatibility. NULL_TYPE
is translated to Empty.

Change-Id: I99b87138d7358d37170cf603d993cd1a4f6a2087
Signed-off-by: Tom Pantelis <tompantelis@gmail.com>
6 years agoAdjust to yangtools-2.0.0 changes
Robert Varga [Wed, 11 Oct 2017 19:31:07 +0000 (21:31 +0200)]
Adjust to yangtools-2.0.0 changes

Change-Id: Ib86747e5ed19c0c00bb46b8d7e4936f4d90c4364
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Signed-off-by: Stephen Kitt <skitt@redhat.com>
6 years agoFix checkstyle reported by odlparent-3.0.0
Robert Varga [Thu, 16 Nov 2017 02:34:13 +0000 (03:34 +0100)]
Fix checkstyle reported by odlparent-3.0.0

Change-Id: I08c548fbbbef8527ad7b037b0def33d3c1c09bf6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoString performance and maintenability
Stephen Kitt [Thu, 18 May 2017 13:28:46 +0000 (15:28 +0200)]
String performance and maintenability

Use StringBuilder for strings built in loops. Use plain concatenation
for string construction not involving loops.

Change-Id: I8299eb54a347d132f0d19dfb39c8fb52366049f2
Signed-off-by: Stephen Kitt <skitt@redhat.com>
7 years agoRemove deprecated NormalizedNodeInputStreamReader ctor
Tom Pantelis [Tue, 30 May 2017 13:16:28 +0000 (09:16 -0400)]
Remove deprecated NormalizedNodeInputStreamReader ctor

The intent is for NormalizedNodeInputStreamReader to be package-scoped
and to create instances via NormalizedNodeInputOutput#newDataInput.
Thus the deprecated public constructor was removed and the remaining
users were converted to use NormalizedNodeInputOutput#newDataInput.
However newDataInput has the side-effect of validating the input stream
first which failed for a couple users who need to lazily do the
validation so I added a newDataInputWithoutValidation method.

Change-Id: Ieb97ab77d05d7a4401dd0526cd4df3a5eafc9eda
Signed-off-by: Tom Pantelis <tompantelis@gmail.com>
7 years agoAdd SerializationUtils unit test
Andrej Mak [Wed, 22 Mar 2017 06:23:26 +0000 (07:23 +0100)]
Add SerializationUtils unit test

Change-Id: I7e8533c8c54c6d2cab234e9ad7db6037a97bdbdc
Signed-off-by: Andrej Mak <andrej.mak@pantheon.tech>
7 years agoCheckstyle: fix ParenPad violations
Lorand Jakab [Fri, 3 Feb 2017 13:44:55 +0000 (15:44 +0200)]
Checkstyle: fix ParenPad violations

Enforcing no space(s) after a left parenthesis and before a right
parenthesis is a proposed change [0] which can only be merged when all
violations are fixed in projects enforcing checkstyle. This patch fixes
those violations.

[0] https://git.opendaylight.org/gerrit/#/c/51316/

Change-Id: Id3e4853bf1cee789d584d4fb528f5415084e26ab
Signed-off-by: Lorand Jakab <lojakab@cisco.com>
7 years agoBUG-7594: Expand NormalizedNodeData{Input,Output} to handle SchemaPath
Robert Varga [Thu, 19 Jan 2017 10:26:11 +0000 (11:26 +0100)]
BUG-7594: Expand NormalizedNodeData{Input,Output} to handle SchemaPath

These utility classes are already dealing with QNames, so it makes
sense to expand their capabilities to include SchemaPath serialization.

Change-Id: Ibcb931f78959eb57f834cd2892511c4963638caa
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoBUG-7159: eliminate use of CrossStatementSourceReactor
Robert Varga [Thu, 22 Dec 2016 15:27:26 +0000 (16:27 +0100)]
BUG-7159: eliminate use of CrossStatementSourceReactor

yang-test-util provides a convenient way to parse YANG files
into a SchemaContext, without relying on the internal layout
of the yang parser. Convert tests to use these utilities,
which simplifies test setup and allows the yang parser layout
to evolve without breaking the world.

Change-Id: Icbd0556b990ea9d5ff93c34330049a9683e04970
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoRemove legacy NormalizedNode serialization classes
Tom Pantelis [Wed, 26 Oct 2016 18:55:01 +0000 (14:55 -0400)]
Remove legacy NormalizedNode serialization classes

Removed the pre-Lithium protobuff-based NormalizedNode classes and
related classes as they are no longer used.

Change-Id: I6ae34c9f3778f31bfa26cb4b6d30f3f3eb1f6fc8
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
7 years agoRemove pre-Lithium serialization support in sal-distributed-datastore
Tom Pantelis [Wed, 26 Oct 2016 18:06:11 +0000 (14:06 -0400)]
Remove pre-Lithium serialization support in sal-distributed-datastore

We've had 3 releases since Helium so it should be safe to remove the
backwards compatible serialization support for the old format utilized by
NormalizedNodeToNodeCodec. It's not likely any user would have persisted
data in the old format in production (mainly b/c clustering was essentially
beta at best) but, in Boron, persisted journals will get snapshotted anyway
in the post-Helium format due to message migration.

Change-Id: I3fba07748b798962b7816878a791cf50a97e5a50
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
7 years agoFix CS warnings in sal-clustering-commons and enable enforcement
Tom Pantelis [Wed, 12 Oct 2016 20:28:13 +0000 (16:28 -0400)]
Fix CS warnings in sal-clustering-commons and enable enforcement

Fixed checkstyle warnings and enabled enforcement. Most of the
warnings/changes were for:
 - white space before if/for/while/catch
 - white space before beginning brace
 - line too long
 - illegal catching of Exception (suppressed)
 - variable name too short
 - indentation
 - local vars/params hiding a field
 - putting overloaded methods close to one another
 - remove unused vars
 - convert functional interfaces to lambdas (eclipse save action)
 - empty catch block - added comment or Throwables.propagate as appropriate
 - missing period after first sentence in javadoc
 - missing first sentence in javadoc
 - adding final for locals declared too far from first usage

Change-Id: I0a6690f97820e8fb670f209221d8e4e2f1cf5d8b
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
7 years agoBug 6910: Fix anyxml node streaming
Tom Pantelis [Mon, 10 Oct 2016 20:57:32 +0000 (16:57 -0400)]
Bug 6910: Fix anyxml node streaming

On output, changed AbstractNormalizedNodeDataOutput to transform the
DOMSource to a result String that is serialized to the stream. On input,
modified NormalizedNodeInputStreamReader to parse the XML string into
a org.w3c.dom.Node and create a DOMSource.

Change-Id: Ib10822c4444331351cf7f25e1f26d981f7d41dc7
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
8 years agoGet rid of old Yang Parser in Controller
Martin Ciglan [Tue, 31 May 2016 12:46:39 +0000 (14:46 +0200)]
Get rid of old Yang Parser in Controller

- Config part DONE
- MD-SAL part DONE
- bit of clean-up

Change-Id: I6bf4f8b81826d5ab61dd883fff3244f42d148375
Signed-off-by: Martin Ciglan <mciglan@cisco.com>
8 years agoUse YangInstanceIdentifier.EMPTY
Robert Varga [Tue, 17 May 2016 20:58:47 +0000 (22:58 +0200)]
Use YangInstanceIdentifier.EMPTY

While the empty build resolves to the same instance, inline the constant
directly saves a bit of the constant pool and makes it a bit more explicit.

Change-Id: I6c92183f473c551a882d2f2a23b5de13406b1982
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoFix static methods and convert to lambdas
Robert Varga [Tue, 3 May 2016 12:01:47 +0000 (14:01 +0200)]
Fix static methods and convert to lambdas

This fixes warnings about static methods and as an auto-save action, converts
functional interface implementations to lambdas.

Change-Id: Id4486516282685fb85f9cfc6e512096662475d53
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoBug 5485: Improve DataTreeModification pruning on recovery
Tom Pantelis [Wed, 9 Mar 2016 04:07:02 +0000 (23:07 -0500)]
Bug 5485: Improve DataTreeModification pruning on recovery

Modified the PruningDataTreeModification and NormalizedNodePruner to
validate path and node QNames via the SchemaContext instead of just
namespaces. This allows migration support for any element to be removed
from a yang hierarchy.

Also handled SchemaValidationFailedException on ready which can happen
with writes which don't immediately validate the sctructure as merge
does. The modification tree is re-applied with pruning.

Change-Id: I8c4f84fbaa93563ce6741d7a3e15855f7fc4940f
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
8 years agoRemove InputStream constructors
Robert Varga [Wed, 17 Feb 2016 16:30:42 +0000 (17:30 +0100)]
Remove InputStream constructors

These are not used anywhere, remove them and simplify callers.

Change-Id: I1b7f28c8fb73903da2c3ddfe59defba56c44e364
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoRemove NormalizedNodeStreamReader
Robert Varga [Wed, 17 Feb 2016 14:47:20 +0000 (15:47 +0100)]
Remove NormalizedNodeStreamReader

This class has been superseded by NormalizedNodeDataInput, remove it.

Change-Id: I11c915f4aff6ca217e096c42ba1115043a99a3ab
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoFix raw type warnings
Robert Varga [Fri, 12 Feb 2016 12:28:25 +0000 (13:28 +0100)]
Fix raw type warnings

Fixes NodeWithValue and similar raw type warnings. Also imports
YangInstanceIdentifier inner interfaces for more readable code.

Change-Id: Iaff9e250fff26b0da70dd9f24d7ccc72121630e4
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoBug 5109: Handle stand alone leaf nodes in CDS streaming
Tom Pantelis [Thu, 21 Jan 2016 15:59:50 +0000 (10:59 -0500)]
Bug 5109: Handle stand alone leaf nodes in CDS streaming

Modified AbstractNormalizedNodeDataOutput to output the leaf set QName
that is now passed to leafSetEntryNode if no parent LeafSetNode QName is
present. Modified NormalizedNodeInputStreamReader accordingly.

I also found that OrderedLeafSetNode was not handled correctly.
AbstractNormalizedNodeDataOutput#startOrderedLeafSet needs to set
lastLeafSetQName.

The NormalizedNodePruner assumed a leaf set entry node must have a
parent and threw an exception if not, similarly with leaf node and anyXML
node. But all 3 can be standalone so I modified NormalizedNodePruner to
handle it.

Change-Id: I02a71d9280dac0eb466ff401699a40d3d8826220
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
8 years agoRemove Helium Tx modify operation messages
Tom Pantelis [Tue, 19 Jan 2016 23:18:19 +0000 (18:18 -0500)]
Remove Helium Tx modify operation messages

Removed the following deprecated Helium Tx messages and related code:

  DeleteData[Reply]
  MergeData[Reply]
  WriteData[Reply]
  ReadyTransaction

Also removed the associated protobuf message classes.

Change-Id: I6f5db0096a60b50e51bf94b12f38941a4be9ca20
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
8 years agoDeprecate NormalizedNodeInputStreamReader(InputStream)
Robert Varga [Fri, 27 Nov 2015 16:48:23 +0000 (17:48 +0100)]
Deprecate NormalizedNodeInputStreamReader(InputStream)

Using ByteStreams.newDataInput() allows us to deprecated ineffcient
constructor, keeping the API cleaner.

Change-Id: Ia8fa4114ce82ccb440f859584069a8c6d6a397ea
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoBUG 4589 : Handle writing and reading large strings
Moiz Raja [Tue, 10 Nov 2015 01:56:32 +0000 (17:56 -0800)]
BUG 4589 : Handle writing and reading large strings

Change-Id: If81926757aef3c1275ba43a7cf8c7adf94d86e08
Signed-off-by: Moiz Raja <moraja@cisco.com>
(cherry picked from commit 28484d59aa626dd4b32cdeb2d10dbc2c47cc051a)

8 years agoRemove checks for NormalizedNodeBuilderWrapper
Robert Varga [Sat, 24 Oct 2015 11:29:44 +0000 (13:29 +0200)]
Remove checks for NormalizedNodeBuilderWrapper

Interface contract already guarantees returned objects are subclasses of
NormalizedNodeBuilderWrapper, the instanceof guards only non-nullness.

Switch to explicit assertNotNull() to reduce eclipse warnings.

Change-Id: Ibf0d73752c6e1ebeacbb10677e2f11f185098bd9
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoMake private methods static
Robert Varga [Fri, 23 Oct 2015 10:34:58 +0000 (12:34 +0200)]
Make private methods static

These methods do not reference object state and therefore can be made
static.

Change-Id: I416e415b90647b4f700b7893fe4f64f479271fab
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoFix Eclipse compilation warnings.
Gary Wu [Wed, 7 Oct 2015 18:11:01 +0000 (11:11 -0700)]
Fix Eclipse compilation warnings.

Change-Id: I16921743a8cc4ac8902c1b7fffa2edfd8cba8be6
Signed-off-by: Gary Wu <Gary.Wu1@huawei.com>
8 years agoFix license header violations in sal-clustering-commons
Thanh Ha [Sun, 9 Aug 2015 01:26:24 +0000 (21:26 -0400)]
Fix license header violations in sal-clustering-commons

Change-Id: I1b76464cd875fdaaedeebc22cf35cae11714990d
Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
9 years agoBUG 2970 : Create a utility class which can prune a normalized node based on the...
Moiz Raja [Fri, 22 May 2015 11:03:00 +0000 (04:03 -0700)]
BUG 2970 : Create a utility class which can prune a normalized node based on the schema context

This will be used when a data modification operation fails because of a missing schema
failure.

Change-Id: I6e07763051cc2181c0c786a0762cbf6a3c5c4eed
Signed-off-by: Moiz Raja <moraja@cisco.com>
(cherry picked from commit 9055581e2aabac7478102c6b05f9118b443a9d64)

9 years agoBug 3258 : Changed the order of condition for OrderedMap and MapNode,
Harman Singh [Mon, 18 May 2015 18:10:23 +0000 (11:10 -0700)]
Bug 3258 : Changed the order of condition for OrderedMap and MapNode,
same for OrderedLeafSet and LeafSet
Added a test to validate it works for OrderedMap

Change-Id: Ifb0375d47668fcc36d824fb33a8b4684e89dccc8
Signed-off-by: Harman Singh <harmasin@cisco.com>
9 years agoAdd signature marker and version to NormalizedNode streaming
tpantelis [Mon, 2 Feb 2015 08:42:37 +0000 (03:42 -0500)]
Add signature marker and version to NormalizedNode streaming

For backwards compatibility, in some message classes, when
de-serializing, we first try the new NormalizedNode streaming and if
that fails we try the pre-Lithium protobuff de-serialization. However,
we're relying on an IOException from the NormalizedNode streaming or it
returning null which may not be reliable. In addition if protobuff fails
as well we can't tell if it's a bad protobuff or streamed message and we
squash the streaming exception. We don't want to masking streaming failures
as that's what will be used going forward.

To alleviate this, NormalizedNodeOutputStreamReader now writes an initial byte
as a signature marker to identify it as a valid stream.
NormalizedNodeInputStreamReader reads it, and if invalid, throws an
exception. This is caught by SerializationUtils as an indication to try
the legacy protobuff de-serialization.

Also, I added a version number to the output stream so we can handle
future changes for backwards compatibility.

Change-Id: I19779aa83c33eadc6bf83adfe6aae0b9a27cdfae
Signed-off-by: tpantelis <tpanteli@brocade.com>
9 years agoBUG 2667 : Handle null value type
Moiz Raja [Tue, 3 Feb 2015 21:13:59 +0000 (13:13 -0800)]
BUG 2667 : Handle null value type

Modified the code to handle null types in leaf and leafset entries since
they are allowed. This should help avoid atleast some of the issues seen
by GBP.

Change-Id: Id24e03738e9b5490c8221fbf31ec0734c58655bb
Signed-off-by: Moiz Raja <moraja@cisco.com>
9 years agoMore unit test code coverage for NormalizedNodeStreamReader/Writer
tpantelis [Sun, 18 Jan 2015 19:29:11 +0000 (14:29 -0500)]
More unit test code coverage for NormalizedNodeStreamReader/Writer

Change-Id: Id93186bb8de8dd7fadb4a53679f964697bd45e3c
Signed-off-by: tpantelis <tpanteli@brocade.com>
9 years agoBug 2327: Handle binary data in NormalizedNode streaming
tpantelis [Wed, 12 Nov 2014 22:09:15 +0000 (17:09 -0500)]
Bug 2327: Handle binary data in NormalizedNode streaming

Also made optimization improvements to reuse primitive (using valueOf) and coded String
values (using intern) when read from the stream.

Also added a reusable StringBuilder instance for building qnames. After
use, the StringBuilder is cleared via the delete method. This
effectively resets the char count to 0. Previously, the
code used string concatenation which the compiler will translate to use
an imlicit StringBuilder. These changes avoid the implicit creation of a
StringBuilder instance each time which should reduce object churn.

Change-Id: Ic9c745d97d1b5eed2dd24bc5d252d05ac1355cbb
Signed-off-by: tpantelis <tpanteli@brocade.com>
9 years agobug 2266 : added more types of schema nodes to increase code coverage
Harman Singh [Fri, 21 Nov 2014 03:49:07 +0000 (19:49 -0800)]
bug 2266 : added more types of schema nodes to increase code coverage

Change-Id: I7372157ffc2b2e69ff9ae34b44eaeecadbf6b75d
Signed-off-by: Harman Singh <harmasin@cisco.com>
(cherry picked from commit 3b743648ca93c5f65b8334fe699b4ceb5aaa054d)

9 years agoBug 2267: Reuse leaf and leaf set entry builders in NormalizedNodeInputStreamReader
tpantelis [Thu, 30 Oct 2014 12:16:05 +0000 (08:16 -0400)]
Bug 2267: Reuse leaf and leaf set entry builders in NormalizedNodeInputStreamReader

Builders.leafBuilder() and Builders.leafSetEntryBuilder() can be
re-used. Added class members to lazy-create a reusable an instance of each.

Also fixed a bug related to a null revision field in QName.

Change-Id: Ief41b6c23d9f41dc0d281786e5143127ef88ca4d
Signed-off-by: tpantelis <tpanteli@brocade.com>
9 years agoBUG 2353 : Handle binary, bits and instanceidentifier types in NodeIdentifiers
Moiz Raja [Wed, 12 Nov 2014 21:10:09 +0000 (13:10 -0800)]
BUG 2353 : Handle binary, bits and instanceidentifier types in NodeIdentifiers

This fix properly serializes and deserializes NodeIdentifier attributes of the types
  - binary (byte[])
  - yanginstanceidentifier
  - bits (set)

Change-Id: I612d40f9730c939be0594496c26370db96ea6449
Signed-off-by: Moiz Raja <moraja@cisco.com>
9 years agoMerge "Fix non-generic references to NormalizedNode"
Tony Tkacik [Mon, 10 Nov 2014 08:55:42 +0000 (08:55 +0000)]
Merge "Fix non-generic references to NormalizedNode"

9 years agoFix non-generic references to NormalizedNode
Robert Varga [Fri, 7 Nov 2014 17:38:43 +0000 (18:38 +0100)]
Fix non-generic references to NormalizedNode

Adds wildcard type arguments to get rid of eclipse warnings.

Change-Id: I16514de7e82b6cabdc9fc17cc76dcb0cbdbe76ce
Signed-off-by: Robert Varga <rovarga@cisco.com>
9 years agoFix non-generic references to Set
Robert Varga [Fri, 7 Nov 2014 17:07:21 +0000 (18:07 +0100)]
Fix non-generic references to Set

Adds arguments as appropriate.

Change-Id: Ib8faba91bd9fc8751014ea00f1859636e0fcda6d
Signed-off-by: Robert Varga <rovarga@cisco.com>
9 years agoFix non-generic references to HashSet
Robert Varga [Fri, 7 Nov 2014 17:00:58 +0000 (18:00 +0100)]
Fix non-generic references to HashSet

Adds arguments and changes to use ImmutableSet.of() where that
is more straighforward.

Change-Id: I9f8709cc320ee9804eb2d83e552ec69cc99ee05a
Signed-off-by: Robert Varga <rovarga@cisco.com>
9 years agoUpdate junit Assert imports
Robert Varga [Fri, 7 Nov 2014 12:42:30 +0000 (13:42 +0100)]
Update junit Assert imports

JUnit 4.11 has moved Assert to org.junit, and deprecated
junit.framework.Assert. This adjust the imports to fix the warnings.

Change-Id: Iecbf2a1b4ae097989e840ad6f6d5bf759c521639
Signed-off-by: Robert Varga <rovarga@cisco.com>
9 years agoBUG 2325 : Value type of byte[] not recognized by the NormalizedNodeSerializer
Moiz Raja [Wed, 5 Nov 2014 19:09:06 +0000 (11:09 -0800)]
BUG 2325 : Value type of byte[] not recognized by the NormalizedNodeSerializer

Change-Id: I16eab6cdbf7712624f2c1fafb5bf41107b6ae379
Signed-off-by: Moiz Raja <moraja@cisco.com>
(cherry picked from commit 819b04091a3d4d96612a1036228638a3b4e85d09)

9 years agoBug 2265: Modified NormalizedNodeOutputStreamWriter to implement yangtools interface
tpantelis [Mon, 27 Oct 2014 21:13:58 +0000 (17:13 -0400)]
Bug 2265: Modified NormalizedNodeOutputStreamWriter to implement yangtools interface

The NormalizedNodeOutputStreamWriter was originally written to implement
a NormalizedNodeStreamWriter interface class that was copied from
yangtools. This was done to get access to the NodeWithValue in the
leafSetEntryNode method which isn't specified in the yangtools
interface. However it turns out we don't actually need the NodeWithValue so
NormalizedNodeOutputStreamWriter was changed to implement the yangtols interface
and the copied NormalizedNodeStreamWriter interface was removed.

Change-Id: I72f0c96359e4fe96e8e183aa7afba9291c5d519d
Signed-off-by: tpantelis <tpanteli@brocade.com>
9 years agoBug 2086: Adding normalized node stream reader and writer.
Harman Singh [Tue, 21 Oct 2014 21:50:04 +0000 (14:50 -0700)]
Bug 2086: Adding normalized node  stream reader and writer.

Normalized node and its children are written in recursive manner. Besides the leafNode, leafSetEntryNode and anyxmlNode, all other nodes must call endNode method
while writing object to data stream. This helps to recreate the object.

Recursion  runs in opposite direction while reading the object.

Updated code with review comments

Change-Id: Ibb822e11fc76f52b5be78596ed979c3b97d51de8
Signed-off-by: Harman Singh <harmasin@cisco.com>
9 years agoBUG 1833 : Remove all unused code from sal-clustering-commons
Moiz Raja [Tue, 21 Oct 2014 21:12:19 +0000 (14:12 -0700)]
BUG 1833 : Remove all unused code from sal-clustering-commons

Change-Id: I7ce05b4ee77b6151f361091b18d1a7bbd8ed408a
Signed-off-by: Moiz Raja <moraja@cisco.com>
(cherry picked from commit 4861f2406206bf208a07a703ad8d6808072c6e45)

9 years agoBug 2003: CDS serialization improvements
tpantelis [Thu, 18 Sep 2014 21:35:53 +0000 (17:35 -0400)]
Bug 2003: CDS serialization improvements

In NormalizedNodeToNodeCodec#encode, significant time was spent
serializing the YangInstanceIdentifier path via PathUtils even though it
wasn't actually needed - the decode method didn't decode it.

This might have been used by WriteModification and MergeModification
originally however they currently serialized/deserialize their
YangInstanceIdentifier path separately from the NormalizedNode via
InstanceIdentifierUtils. It turns out this takes significant time as
well as it's implemented similarly as PathUtils.

So I ended up using NormalizedNodeToNodeCodec to encode/decode the
YangInstanceIdentifier along with the NormalizedNode but changed
InstanceIdentifierUtils to utilize the new PathArgumentSerializer
and the NormalizedNodeSerializer's special QName encoding.

With serializing a 5K batch of WriteModifications with flow data, the
time went down from ~350 ms to ~150 ms. Deserialization was also
improved.

Other smaller optimizations in NormalizedNodeSerializer,
NormalizedNodeType, PathArgumentSerializer and PathArgumentType chopped
another 20-30 ms off the time.

I also changed InstanceIdentifierUtils to serialize/deserialize via the
new PathArgumentSerializer and the NormalizedNodeSerializer's special QName
encoding by default, even when the ID isn't encoded as part of a
NormalizeNode. This seems reasonable to me as a standalone IID will
likely have repeated namespaces and revisions plus we get savings by not
serializing each path arg class name.

Removed the deprecated InstanceIdentifierUtils class in
sal-distributed-datastore bundle.

Change-Id: Iaa29daeaececf4b93065f4d46d0c2796c4d8188f
Signed-off-by: tpantelis <tpanteli@brocade.com>
9 years agoOptimized version of NormalizedNode Serialization
Moiz Raja [Tue, 26 Aug 2014 02:04:30 +0000 (19:04 -0700)]
Optimized version of NormalizedNode Serialization

This commit contains the following,
- Conversion of NormalizedNode to Protocol Buffer using simple tree traversal
- Encoding of QNames and other values to small sized codes to reduce the size of the protobuf message
- Also we now do not use SchemaContext for decoding a NormalizedNode

In addition to these changes I have snuck in an unrelated change to the pom files
to get the appropriate jacoco settings in it.

Change-Id: I6ab48c9f53cf76d6d0c865cf6e5522ff27a30e3f
Signed-off-by: Moiz Raja <moraja@cisco.com>
9 years agoMerge "BUG 1597 - Do not use toString as serialized version of YangInstanceIdentifier...
Ed Warnicke [Mon, 25 Aug 2014 09:07:28 +0000 (09:07 +0000)]
Merge "BUG 1597 - Do not use toString as serialized version of YangInstanceIdentifier/PathArgument"

9 years agoKeep a cache of QName
Moiz Raja [Mon, 11 Aug 2014 22:44:56 +0000 (15:44 -0700)]
Keep a cache of QName

QName creation is expensive so keep of cache of 10,000 QNames around so that
we can lookup QNames that were previously created

Change-Id: I04e19bbe733a9da46b999e517e2eefdbb88d1259
Signed-off-by: Moiz Raja <moraja@cisco.com>
9 years agoBUG 1597 - Do not use toString as serialized version of YangInstanceIdentifier/PathAr...
Moiz Raja [Sat, 23 Aug 2014 10:34:43 +0000 (03:34 -0700)]
BUG 1597 - Do not use toString as serialized version of YangInstanceIdentifier/PathArgument

The code has been modified to stop interpreting YangInstanceIdentifier.toString
and PathArgument.toString as a serialized versions of those objects. The toString
implementations of those objects has now been moved into PathUtils.

- NormalizedNodeGetter and NormalizedNodeToNodeCodecTest have been modified to use
PathUtils.toString instead of YangInstanceIdentifier.toString or PathArgument.toString

- Added tests to cover all the utilities in PathUtils

Change-Id: I1ed2c452e15a45229c36532d59db7fa1a77d283d
Signed-off-by: Moiz Raja <moraja@cisco.com>
9 years agoFix usage of StringBuilder when getting parent path
Basheeruddin Ahmed [Fri, 8 Aug 2014 21:39:25 +0000 (14:39 -0700)]
Fix usage of StringBuilder when getting parent path
in PathUtils
Making constants final
timing encode/decode in a test case

Change-Id: Ia552163dfe35dcd268bd8a0620c6b34c910f47b2
Signed-off-by: Basheeruddin Ahmed <syedbahm@cisco.com>
9 years agoCreated sal-clustering-commons and moved
Basheeruddin Ahmed [Tue, 5 Aug 2014 00:18:27 +0000 (17:18 -0700)]
Created sal-clustering-commons and moved
sal-protobuff-encoding files to sal-clustering-commons

updated sal-distributed-datastore pom with the above change

removed sal-clustering-commons as part of distribution as it is embedded currently as part of distributed-datastore

Note - after this is merged we need to move
 out the .proto from  akka-raft to sal-clustering-commons
and add dependency of sal-akka-raft on sal-clustering-commons
and embed the same
rebased
Change-Id: I7d4ac51628cef96ffb16acfcfd596dfd3129e0fa
Signed-off-by: Basheeruddin Ahmed <syedbahm@cisco.com>