yangtools.git
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 agoMerge "Bug 2038: Ensure only one concurrent 3-phase commit in Shard"
Moiz Raja [Fri, 17 Oct 2014 14:56:16 +0000 (14:56 +0000)]
Merge "Bug 2038: Ensure only one concurrent 3-phase commit in Shard"

9 years agoBug 865: Fixed use of removed deprecated YANGInstanceIdentifier methods.
Tony Tkacik [Fri, 17 Oct 2014 12:05:06 +0000 (14:05 +0200)]
Bug 865: Fixed use of removed deprecated YANGInstanceIdentifier methods.

Some components in controller still used methods which was deprecated
before Helium and was removed after Helium was released to accomodate
API changes for 0.7.0 Yangtools. This patch migrates code to replacement
methods.

Change-Id: I146a08caefeb0d666223cf66600a4342a5b49165
Signed-off-by: Tony Tkacik <ttkacik@cisco.com>
9 years agoBug 2038: Ensure only one concurrent 3-phase commit in Shard
tpantelis [Sun, 5 Oct 2014 03:05:16 +0000 (23:05 -0400)]
Bug 2038: Ensure only one concurrent 3-phase commit in Shard

Added a ShardCommitCoordinator class that ensures there's only one
concurrent 3-phase commit.

The following outlines the new commit workflow:

- On ready, the ShardTransaction creates the dom store cohort and
forwards a new ForwardedReadyTransaction message to the shard.

- The shard calls its ShardCommitCoordinator to add the cohort and
modificaton to a cached keyed by transaction ID.

- On CanCommitTransaction message, the ShardCommitCoordinator looks up and removes
the cohort entry from the cache corresponding to the transaction ID
passed via the CanCommit message. The ShardCommitCoordinator also caches
the cohort entry for the current transaction in progress. If there's no
transaction in progress, the committing transaction becomes the current
transaction and canCommit is called on the cohort. Otherwise, the cohort
entry is queued to be processed after the current tranaction completes.

- On CommitTransaction message, if the transaction ID passed via the
Commit message matches the currently cached cohort entry, the preCommit
and commit phases are performed. When complete, the ShardCommitCoordinator
dequeues the next waiting transaction cohort entry, if any, and process
it.

If a Tx is aborted and it is the current transaction, the
ShardCommitCoordinator handles it as a completed Tx.

Implemented a timeout mechanism using the akka scheduler such that if
the commit message isn't received after a period of time (default 30 s)
after the canCommit message, the transaction is aborted so that the next
transaction can proceed. This is to handle remote node or network
failures during a 3-phrase commit.

The ThreePhaseCommitCohort actor was removed along with the
ForwardedCommitTransaction.

Change-Id: Iaa5692ca45cd7635d1a06a609f4bf98bec50df14
Signed-off-by: tpantelis <tpanteli@brocade.com>
9 years agoMerge "Bug 1577: Gates access to Shard actor until its initialized"
Moiz Raja [Wed, 15 Oct 2014 19:36:01 +0000 (19:36 +0000)]
Merge "Bug 1577: Gates access to Shard actor until its initialized"

9 years agoBug 1577: Gates access to Shard actor until its initialized
Abhishek Kumar [Sat, 20 Sep 2014 08:19:11 +0000 (01:19 -0700)]
Bug 1577: Gates access to Shard actor until its initialized

1. Shard manager creates Shard and mark them un-initialized.
   Shard completes recovery and onRecoveryComplete, sends a
   message to Shard manager to mark it initialized.
   If a request for Shard comes to Shard manager and the
   shard is not initialized, it sends ActorNotInitialized
   message.

2. Normalizes and refactors ActorContext.

3. Adds AbstractUntypedPersistentActorWithMetering to meter
   ShardManager.

Change-Id: Ibf15a2ef56422bda53067039d2271a719b6b2ce3
Signed-off-by: Abhishek Kumar <abhishk2@cisco.com>
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 agoBug 1831 Batch messages on journal recovery
tpantelis [Sun, 31 Aug 2014 15:15:18 +0000 (11:15 -0400)]
Bug 1831 Batch messages on journal recovery

Added journal log recovery batching support in RaftActor along with
additonal abstract methods for granular recovery control.

It turns out that batching helps a little but the real performance hog
was deserialization. There was a couple inefficient PreConditions in the
NormalizedNodeSerializer (unwanted String concats in the fast path) that
accounted for significant performance degradation. I also made a few
other minor performance enhancements.

Although deserialization is much better with the fixes, I also
implemented some parallelization during shard recovery. I added a
ShardRecoveryCoordinator class that parallelizes deserialization
of journal log enry batches and snapshots for faster recovery time.
The resulting transactions are still committed to the data store in the
order the corresponding snapshot or log batch are received to preserve
data store integrity.

The journal recovery log batch size is configurable vai the config XML.
I also made the shard heartbeat interval and shard snapshot batch count
configurable.
`
Change-Id: I52ef1690bfb6cc486c329ee60f77c52720c24469
Signed-off-by: tpantelis <tpanteli@brocade.com>
9 years agoBUG 1815 - Do not allow Shards to be created till an appropriate schema context is...
Moiz Raja [Thu, 18 Sep 2014 17:54:47 +0000 (10:54 -0700)]
BUG 1815 - Do not allow Shards to be created till an appropriate schema context is available

The fix works like so,
- ShardManager maintains a list of all the modules that it ever knew about
- ShardManager persists the known modules to disk using persistence
- When ShardManager recovers it reads back the knownModules from persistence
- As ShardManager gets new SchemaContext's it checks whether the modules in
  the new SchemaContext are a superset of the knownModules. If they are then
  ShardManager persists it and let's the Shards know about the new SchemaContext
  otherwise the new SchemaContext is rejected and a message is logged

Also reduced the log level of some log messages in RaftActor from info to debug
it was too verbose

Change-Id: If388f690114c58e6a8df30f34ddac32a99f255e5
Signed-off-by: Moiz Raja <moraja@cisco.com>
9 years agoBUG 1883 - Ensure that all debug logging is done conditionally
Harman Singh [Tue, 16 Sep 2014 00:14:17 +0000 (17:14 -0700)]
BUG 1883 - Ensure that all debug logging is done conditionally

This commit is mostly about conditional logging.

It also sneaks in a couple of other things,
1. Cleanup of ClientRequestTracker
2. Removal of some dead code

Change-Id: I0862f1273e94856e19107d3a4beec4d66452787d
Signed-off-by: Moiz Raja <moraja@cisco.com>
Signed-off-by: Harman Singh <harmasin@cisco.com>
9 years agoBug-1830:Move install snapshot messages from akka-raft to sal-commons
Kamal Rameshan [Mon, 15 Sep 2014 07:08:57 +0000 (00:08 -0700)]
Bug-1830:Move install snapshot messages from akka-raft to sal-commons

Change-Id: I0bc5e68879ce0b7026c8bfda94ad7e2038aedff8
Signed-off-by: Kamal Rameshan <kramesha@cisco.com>
9 years agoBUG 1758 - Clustering : CompositeModificationPayload ClassNotFoundException
Moiz Raja [Tue, 9 Sep 2014 16:47:36 +0000 (09:47 -0700)]
BUG 1758 - Clustering : CompositeModificationPayload ClassNotFoundException

This patch also fixes BUG 1753 by enabling the SLF4J Adapter so that logging
goes to the karaf log.

For the most part the fix for CompositeModificationPayload not being found
is because of a DynamicImport missing in sal-akka-raft. I've also moved
Payload and CompositeModificationPayload to sal-clustering-commons

Change-Id: I82f6f598b8c912f8109526ebe7340c70f52fdcde
Signed-off-by: Moiz Raja <moraja@cisco.com>
9 years agoBUG 1712 - Distributed DataStore does not work properly with Transaction Chains
Moiz Raja [Fri, 5 Sep 2014 04:53:46 +0000 (21:53 -0700)]
BUG 1712  - Distributed DataStore does not work properly with Transaction Chains

The fix is as follows,

1. When Creating a trasaction chain create a unique identifier for the transaction chain
   using the member name and the current timestamp

2. When a transaction is created using the transaction chain pass the transaction chain id
   along to the remote shard

3. If the remote shard receives a transaction with a valid transaction chain (one which is
   not empty) then it creates a new transaction chain if one does not exist. If one does exist
   then the Shard just creates a new transaction on the existing transaction chain.
   This way if a single transaction chai was used to create transactions on multiple
   different shards the a transaction chain would  be created on each one of those shards.

4. When a transaction chain is closed a Close Transaction Chain message is broadcast to all
   the Shards in the system. If those shards had a transaction chain with the specified id
   then the transaction chain would be closed. The sender does not care about receiving a
   response

5. When a state change occurs on a Shard we check if the Shard is not a leader. If that is
   the case we automatically close all existing transaction chains on that shard and clear
   the map which tracks the transaction chains for that shard

Change-Id: I6bcfb9de3d0ec666e4152afb69c702dda4f38171
Signed-off-by: Moiz Raja <moraja@cisco.com>
9 years agoMetrics and Configuration
Abhishek Kumar [Wed, 27 Aug 2014 20:07:30 +0000 (13:07 -0700)]
Metrics and Configuration

1. Adds a new abstract class AbstractMeteredUntypedActored that
   extends AbstractUntypedActor. This adds metrics capture
   capability which can be turned on using Config Subsystem.
   By default its turned off.

2. Updates Shard actor; adds metrics capture capability which can be
   turned on via Config Subsystem.

3. In remote-rpc-connector module, we can now pass configuration
   obtained from config subsystem to actor system so that its
   available to all actors. This obviates the need to manually pass
   the configuration via constructors or other *Constant or *Util
   classes. It brings all configuration items in the module at one
   place and makes it easier to move them to config subsystem, if
   its required.

4. In spirit of DRY, moves common code to clustering-commons

5. Minor code inspection fixes.

6. Makes mailbox-capacity configurable via config subsystem.

Patch 9:
Adds a new behaviour (MeteringBehavior.java).
AbstractUntypedActorWithMetering and Shard actor exhibit this
behavior current.
This patch also refactors unified configuration (config subsystem
+ typesafe config) pieces.

Note that in subsequent commits distributed-datastore will have
its configuration added to actor system configuration. Also few
more configuration items in remote-rpc-connector will go to
config subsystem. I wanted to limit the amount of changes going
into this already large commit.

Change-Id: I383ec813c16ed09ed0e68ee59179f454c0d174cf
Signed-off-by: Abhishek Kumar <abhishk2@cisco.com>
9 years agoMerge "BUG 1595 - Clustering : NPE on startup"
Ed Warnicke [Thu, 4 Sep 2014 22:53:39 +0000 (22:53 +0000)]
Merge "BUG 1595 - Clustering : NPE on startup"

9 years agoBug 1637: Change Rpc actor calls to async
tpantelis [Mon, 25 Aug 2014 00:29:58 +0000 (20:29 -0400)]
Bug 1637: Change Rpc actor calls to async

Changed RemoteRpcImplementation and RpcBroker to use async calls and
modified/created unit tests.

Added an RpcErrorsException to transfer RpcError info on failure. This
is now used in lieu of ErrorResponse to communicate failures.

Change-Id: Ib0bbda1867caff9b6c584b9b8a9b336f8acf53d7
Signed-off-by: tpantelis <tpanteli@brocade.com>
9 years agoBUG 1595 - Clustering : NPE on startup
Moiz Raja [Fri, 29 Aug 2014 22:58:44 +0000 (15:58 -0700)]
BUG 1595 - Clustering : NPE on startup

This seemed to be happening because of recovery where the topology manager
was trying to add something into the datastore which was already present in
the journal.

The fix was to add a timestamp to each modification so that they do not
appear to be the same even if their content was exactly the same.

Change-Id: I2d5c98bd87ded7c8b64b8cebf757bfa073327061
Signed-off-by: Moiz Raja <moraja@cisco.com>
9 years agoChanged key actors to use bounded mailbox
Abhishek Kumar [Fri, 22 Aug 2014 21:18:19 +0000 (14:18 -0700)]
Changed key actors to use bounded mailbox

1. Changed key actors in clustering components to use
bounded mailbox.

2. Implementation of Bounded mailbox queue changed to
 use deque as its required by Shard Actors.

3. Cleanup of hard coded values.

Change-Id: I9fb87e1857f2aa9fee0819c4dff63ca3c967ec60
Signed-off-by: Abhishek Kumar <abhishk2@cisco.com>
9 years agoMerge "Optimized version of NormalizedNode Serialization"
Tom Pantelis [Fri, 29 Aug 2014 18:14:59 +0000 (18:14 +0000)]
Merge "Optimized version of NormalizedNode Serialization"

9 years agoMoving protobuff files to sal-clustering-commons
Basheeruddin Ahmed [Wed, 27 Aug 2014 23:36:00 +0000 (16:36 -0700)]
Moving protobuff files to sal-clustering-commons

Change-Id: I299886a22aa250f4a35c8c35385c89b5c58e297d
Signed-off-by: Basheeruddin Ahmed <syedbahm@cisco.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 agoMerge "Custom mailbox that is bounded and instrumented."
Moiz Raja [Tue, 19 Aug 2014 16:54:17 +0000 (16:54 +0000)]
Merge "Custom mailbox that is bounded and instrumented."

9 years agoCustom mailbox that is bounded and instrumented.
Abhishek Kumar [Fri, 15 Aug 2014 06:15:28 +0000 (23:15 -0700)]
Custom mailbox that is bounded and instrumented.

This is for use with Akka actors. It enables monitoring
of actor's mailbox size via JMX.

Change-Id: Ic1e478e4411f53ff0239d316a1ca02eaa80360ed
Signed-off-by: Abhishek Kumar <abhishk2@cisco.com>
9 years agoMoving common code out of remote rpc to clustering common bundle
Harman Singh [Sat, 16 Aug 2014 00:50:58 +0000 (17:50 -0700)]
Moving common code out of remote rpc to clustering common bundle

Change-Id: Iad469f809ac55b2d873ff4d48e912ad66184c68d
Signed-off-by: Harman Singh <harmasin@cisco.com>
9 years agoMove the CompositeModificatoinPayload message to proper
Basheeruddin Ahmed [Wed, 13 Aug 2014 23:35:27 +0000 (16:35 -0700)]
Move the CompositeModificatoinPayload message to proper
package
The package of protobuff generated code is
excluded from sonar testing

Change-Id: I4eeae429febe32a8a347c319f6dec60cd0df5946
Signed-off-by: Basheeruddin Ahmed <syedbahm@cisco.com>
9 years agoAdd exists method on DOMStoreReadTransaction and DOMDataReadTransaction
Moiz Raja [Sun, 10 Aug 2014 23:18:33 +0000 (16:18 -0700)]
Add exists method on DOMStoreReadTransaction and DOMDataReadTransaction

Introducing this API does not impact clients as it is mostly internal.

One reason for adding this API is because of ensureParentsByMerge used in a couple of places
which keeps checking if a parent node exists by reading a node to figure out if it exists. This is
fine for the InMemoryDataStore but it can be terrible in a distributed data store where the shard
which contains the data is remote. All sorts of overhead is associated with a remote read including
serialization which can actually be pretty expensive.

Change-Id: Ib5be5f6dc60be683d7a04c81dad08c56cd5681f4
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 agoUtilize transaction type to create read-only or
Basheeruddin Ahmed [Wed, 6 Aug 2014 22:38:35 +0000 (15:38 -0700)]
Utilize transaction type to create read-only or
write-only or read-write transaction instead of always
creating read-write transaction

patch 2: updated based on review comments

Change-Id: I36390ab348c5774cf4bf180ea1608fe04f75d073
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>