controller.git
8 years agoAdd decorating "type" attr extension for service refs 82/36482/21
Tom Pantelis [Sun, 20 Mar 2016 04:06:08 +0000 (00:06 -0400)]
Add decorating "type" attr extension for service refs

Added an attribute extension to the <service> element that adds an
OSGi service property of the form "type=<value>". This allows providers
of a service to advertise the type of the service to distinguish it from
other services provided for the same interface.

Conversely, the extension can also be used in <reference> elements to allow
consumers of the service to specify which service implementation they
want.

As a convention, the "default" type should be used for the default
implementation of the service with other types being specialized
implementations. This allows consumers to obtain whichever
implementation the provider deems as the default without having to
explicitly know it and allows the provider to switch to a new
implementation without requiring all consumers to change their
referenced type.

If a consumer doesn't specify the "type" attribute, it may be ambiguous
as to which service is obtained. Rather than requiring that the "type"
attribute be specfied for every <reference> element, I added an attribute
extension attribute, "use-default-for-reference-types", to the <blueprint>
element that automatically adds a filter to all <reference> elements where
the "type" property is either not set or set to "default" if the "type"
attribute isn't explicitly specified. This ensures the default implementation
is imported if there are other implementations advertised with other types.

Change-Id: Ie61bb45da1c7539732cd31ab0f8130233c9696fc
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
8 years agoAdd restart-dependents-on-update blueprint extension 76/36476/20
Tom Pantelis [Sat, 19 Mar 2016 20:51:29 +0000 (16:51 -0400)]
Add restart-dependents-on-update blueprint extension

Added an attribute extension to the <blueprint> element that adds a bean
processor that scans for any "property-placeholder" elements and reacts to
changes to the corresponding cfg file by restarting this blueprint
container and any dependent containers that consume OSGi services provided by
this container in an atomic and orderly manner. This mimics the module
restart functionality provided by the CSS.

A new OSGi service, BlueprintContainerRestartService, was added that
performs the orderly restart. This service is created and registered by
the BlueprintBundleTracker.

Change-Id: I5f463303c3a8aba35b3ed914268bdc67ac795a5a
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
8 years agoAdd Blueprint bundle tracker 48/35848/15
Tom Pantelis [Tue, 5 Apr 2016 04:30:37 +0000 (00:30 -0400)]
Add Blueprint bundle tracker

Added an initial blueprint bundle and BlueprintBundleTracker which
scans ACTIVE bundles for blueprint XML files located under the well-known
org/opendaylight/blueprint/ path and deploys the XML files via the
Aries BlueprintExtenderService. This path differs from the standard
OSGI-INF/blueprint path to allow for controlled deployment of
blueprint containers in an orderly manner.

Change-Id: I21fd5aeb1d9ccd609caa8ea89bd66648fee5ad97
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
8 years agoImprove config system shutdown 77/36777/8
Tom Pantelis [Thu, 24 Mar 2016 15:53:39 +0000 (11:53 -0400)]
Improve config system shutdown

On shutdown, the ModuleFactoryBundleTracker is invoked for every removed
bundle which executes the "blank" transaction which in turn calls
ConfigRegistryImpl#beginConfig. This method is synchronized and may block
if a config commit is in progress (which might be waiting on capabilities or
a ModuleFactory). The ModuleFactoryBundleTracker is invoked
synchronously so this can block karaf shut down. It can affect single feature
tests in particular which start and stop karaf quickly.

I'm not exactly sure what the blank tx is for - I think its purpose is to
indirectly cause the deactivated bundle's module(s) to be destroyed. On
shutdown, the ConfigManagerActivator stop method calls ConfigRegistryImpl#close
which destroys all the modules so we really don't need the blank tx to
run on every bundle on shutdown.

On shutdown, karaf first sends a STOPPING event for the system bundle
(id 0). So I added the ConfigManagerActivator as a bundle listener and when
the system bundle 0 transitions to STOPPING, it calls ConfigRegistryImpl#close.
I also added a closed flag in ConfigRegistryImpl which is checked by
beginConfig and commitConfig. In order to make this work right, I had to change
the synchronization in ConfigRegistryImpl, which really was over-synchronized on
"this". I removed synchronized from the beginConfig and close methods to
break the locking between the two and I made ConfigHolder and TransactionsHolder
classes thread-safe by using ConcurrentHashMap which allows close to access them
safely w/o synchronization.  If the closed flag is set, beginConfig
returns a no-op ObjectName, otherwise it calls the synchronized beginConfigSafe
method. In commitConfig, if closed is set or the ON is the no-op ObjectName,
it returns an an empty CommitStatus.

I also changed from synchronizing "this" to using a Lock to take advantage
of the tryLock functionality. As an added measure of safety against
prolonged blocking, if beginConfig is called with the blank tx flag set,
it tries to acquire the lock for 5 sec. If it fails it returns the no-op
ObjectName.

After the modules are destroyed by ConfigRegistryImpl#close. the container
will proceed to stop the rest of the bundles and the ModuleFactoryBundleTracker
will initiate blank transactions but they'll be no-ops and won't block.

The ModuleFactoryBundleTracker was also changed to only initiate a blank
transaction for bundles that contain a ModuleFactory (via Boolean state
stored with the BundleTracker).

With these changes, karaf shuts down noticeably faster.

The BlankTransactionServiceTracker also initiates a blank transaction
when services are added and removed. Since these are synchronous calls
we really shouldn't block the OSGi container. So I added a
single-threaded executor to process the blank transactions for the
service changes. The blank transaction on bundle removed has to be done
synchronously as it may still need access to the BundleContext which
becomes invalid after the bundle removed event.

Change-Id: I5482caa4182dcc64df9b6bafefac9b8f2d505d3e
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
8 years agoFix ApplyState elapsed time check 84/37084/3
Tom Pantelis [Mon, 4 Apr 2016 05:40:06 +0000 (01:40 -0400)]
Fix ApplyState elapsed time check

On ApplyState, there's a check if the elapsed time exceeds a 50ms
threshold and it logs a warning. However the start time is captured when
the message is created prior to queueing. So if there's many ApplyState
or other messages already queued, the elapsed time also includes the time spent
in the queue, ie as a side effect includes the cumulative processing time
of each prior message in the queue. When a follower starts up, there can
be hundreds to thousands of catchup ApplyState messages and, eventually,
the cumulative processing times can add up to more than 50 ms, in which
case every subsequent ApplyState message trips the threshold with
increasing elapsed times, even though none of them actually took 50 ms
to process. Seeing hundreds to thousands of warnings with misleading
elapsed times looks ominous and leads users to think something is wrong.

Therefore I changed it to capture the start time just prior to calling
applyState so it captures just the processing time for that message. I
also removed the startTime field from ApplyState. This class is
Serializable but it is only ever sent locally to self and is never
serialized so there's no backwards compatibility concerns.

Change-Id: I9493734b5307d6dd5d723e5fe416ba97915dfc63
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
8 years agoBUG 5656 : Entity ownership candidates not removed consistently on leadership change 16/37116/3
Moiz Raja [Tue, 5 Apr 2016 01:27:17 +0000 (18:27 -0700)]
BUG 5656 : Entity ownership candidates not removed consistently on leadership change

This patch removes candidates for all downed members when entity ownership shard
leadership changes. This fixes a corner case where a leader/follower are both killed
simulaneously in a cluster which has greater than 3 nodes. In this case the old leader
does not have a chance to remove the killed follower. The new leader does know that
the follower is down so it can remove the candidates for all downed followers on
shard leadership change.

Change-Id: If28f5656e0daee40fb96a937dbd0a868b7d3645a
Signed-off-by: Moiz Raja <moraja@cisco.com>
8 years agoDefault shard-journal-recovery-log-batch-size to 1 21/37121/2
Tom Pantelis [Mon, 4 Apr 2016 14:58:08 +0000 (10:58 -0400)]
Default shard-journal-recovery-log-batch-size to 1

In Helium there was an issue with batching journal log entries in a
single transaction on recovery which could cause validation exceptions
and/or missing data. Setting the batch size to 1 alleviated the issue and
thus it was defaulted to 1.

It was thought this issue wasn't present in Lithium but it is as I have
a Helium journal which exhibits the problem. I have tried this journal
with the current code base and didn't see an issue (it looked like all
data was recovered from what I could tell) but I'm not confident an issue
isn't still lurking with the right combination of modifications across
many journal transactions. It is safest to recover the transactions in the
same manner as they were originally committed, ie one by one.

Therefore I have defaulted the batch size to 1. In my testing, the prior
setting of 1000 doesn't add any value anyway as the recovery time is
virtually the same with batch size 1000 and 1. Setting it to 1
eliminates the potential risk of data loss.

Change-Id: Icd7fd3c60bdd6cf1b677ccae38be810e779d2bd3
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
8 years agoBUG-5626: Move leaderId/leaderPayloadVersion fields 24/37024/5
Robert Varga [Fri, 1 Apr 2016 21:36:33 +0000 (23:36 +0200)]
BUG-5626: Move leaderId/leaderPayloadVersion fields

Handling of getLeaderId() depends on behavior:
- for (Isolated)Leader, it is always its local ID
- for Candidate it is always null
- for Follower it can vary
The same is true of leader payload version.

This patch moves these two fields to Follower, makes Candidate return constants and
makes Leader return the values stored in the local context.

Change-Id: I0fca58ab985f14460eef9647a89ede02242e6e7c
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoDo not depend on the config generator 87/37087/1
Robert Varga [Mon, 4 Apr 2016 17:03:40 +0000 (19:03 +0200)]
Do not depend on the config generator

This is a bogus dependency, which should not simply exist, as it
causes us to pull in a jar which is not needed at runtime.

Change-Id: I456e420f498cd7e72d94cd65426ec8470149f107
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoDeprecate DCL in favor of DTCL 70/36970/2
Ryan Goulding [Thu, 31 Mar 2016 15:02:31 +0000 (11:02 -0400)]
Deprecate DCL in favor of DTCL

The DataTreeChangeListener abstraction offers many performance and semantic
advantages over DataChangeListener.  Although there is no concrete date for DCL
removal, @Deprecated annotations are added to DCL API and impl classes to
dissuade their use.  An example of how to transition from DCL to DTCL is
included in this patch:

https://git.opendaylight.org/gerrit/#/c/35209/

Change-Id: Ie6d287224f572f157d41bf56c04b02e60ea8bf2a
Signed-off-by: Ryan Goulding <ryandgoulding@gmail.com>
8 years agoBUG-5626: refactor BehaviorStateHolder 20/37020/2
Robert Varga [Fri, 1 Apr 2016 20:08:10 +0000 (22:08 +0200)]
BUG-5626: refactor BehaviorStateHolder

This patch splits this class into two parts: BehaviorStateTracker, which is kept
around for as long as RaftActor lives, and BehaviorState, which is used transiently
when we are about to perform a state change.

This makes it more clear as to what state is required to perform a behavior change
and also prevents us from keeping potentially stale objects around. While it forces
object allocation in message dispatch, BehaviorState objects are extremely short-lived
and do not leak to the help -- hence JVMs should be able to deal with them quickly
during GC or even eliminate allocations based on escape analysis.

Change-Id: Ida23a0dcb75ab6ccd11afcc64742884214760549
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoBUG-5626: eliminate SwitchBehaviorSupplier 19/37019/3
Robert Varga [Fri, 1 Apr 2016 18:31:59 +0000 (20:31 +0200)]
BUG-5626: eliminate SwitchBehaviorSupplier

This class acts as an indirection which makes following logic hard, eliminate
it in favor of explicit code.

Change-Id: I8715f6cdaed6e653d39af6741242072b39232022
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoReduce test class visibility 13/37013/4
Robert Varga [Fri, 1 Apr 2016 14:37:49 +0000 (16:37 +0200)]
Reduce test class visibility

These classes are not used anywhere else, make that explicit by making them
private.

Change-Id: Ic6549f1b5f6c6df20cc54e4162569363382fe305
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoRemove unused TestEntityOwnershipShard 12/37012/4
Robert Varga [Fri, 1 Apr 2016 14:34:22 +0000 (16:34 +0200)]
Remove unused TestEntityOwnershipShard

This class is not used anywhere, remove it.

Change-Id: I3d2aeb4219315681229eda35e749f732bb1f2b73
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoDo not use Strings for internal messages 10/37010/5
Robert Varga [Fri, 1 Apr 2016 14:14:25 +0000 (16:14 +0200)]
Do not use Strings for internal messages

Using a String for the message identity has the effect of the equality
running on Strings, which has the effect that message is not really
isolated, but can be sent by anyone who knows the message content.

Instantiate simple Objects instead, which force a proper identity
equality check. Retain debuggability by having these instances override
toString().

Change-Id: Ia581e0a1e023ace10b5dbb81a44092ca04a4ff8f
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoMake MessageTracker.Context implement AutoCloseable 08/37008/3
Robert Varga [Fri, 1 Apr 2016 13:16:47 +0000 (15:16 +0200)]
Make MessageTracker.Context implement AutoCloseable

The API contract is indicative of the fact that a Context is really
a resource which needs to be closed. Express this in code and take
advantage of availability of try-with.

Change-Id: I17ebc9e458ad43888fed868a89256cbb0fca7b87
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoMake config-it-base capable of accepting additional options from derived classes. 23/36923/6
Kevin Wang [Wed, 30 Mar 2016 23:24:00 +0000 (16:24 -0700)]
Make config-it-base capable of accepting additional options from derived classes.

Change-Id: I654224bf9c927e0b393f92036f759b487a8075ad
Signed-off-by: Kevin Wang <kevixw@gmail.com>
8 years agoAdd javanet stax-utils bundle to the odl-mdsal-common feature 76/36976/3
Tom Pantelis [Thu, 31 Mar 2016 18:25:05 +0000 (14:25 -0400)]
Add javanet stax-utils bundle to the odl-mdsal-common feature

Currently the stax-utils artifact is embedded internally by
sal-rest-connector so it isn't generally available. Therefore I added it
to the odl-mdsal-common feature. It is just a regular jar so I used the
wrap scheme to make it into a bundle.

Change-Id: I61909e3e55c0ccc0e3886c73a96db27c6e3664da
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
8 years agoModify AbstractConfigTestBase to use opendaylight-karaf-empty 76/36776/9
Tom Pantelis [Tue, 29 Mar 2016 13:34:52 +0000 (09:34 -0400)]
Modify AbstractConfigTestBase to use opendaylight-karaf-empty

The vanilla karaf distro that AbstractConfigTestBase installs only has the
base features. We need the standard features which includes eventadmin
which is needed for the upcomng blueprint work. So I changed
AbstractConfigTestBase to install opendaylight-karaf-empty which now
includes the standard features as well as the updated Aries proxy-impl
1.0.5 artifact.

Change-Id: I46100cc8edb9743e0885b156a1adc37e3a18ca9e
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
8 years agoBUG-5626: do not use needless cast 09/36909/2
Robert Varga [Wed, 30 Mar 2016 17:54:45 +0000 (19:54 +0200)]
BUG-5626: do not use needless cast

Casting to Follower is not needed, as we can access the leader ID from
the RaftActorBehavior interface.

Change-Id: Id1b0e20571eb12b14791e7e42abe846ebe3a6b9f
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoInvert equals() invocation for expired TX_COMMIT_TIMEOUT_CHECK_MESSAGE 00/36900/3
Robert Varga [Wed, 30 Mar 2016 15:09:16 +0000 (17:09 +0200)]
Invert equals() invocation for expired TX_COMMIT_TIMEOUT_CHECK_MESSAGE

TX_COMMIT_TIMEOUT_CHECK_MESSAGE is a constant, hence calling equals on it
with the message parameter should be faster than the over way around.

Change-Id: I4d8b8bfa644e7802d90059369266e2227e5c1ca3
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoDo not allow RaftActorBehavior.close() to throw Exception 90/36890/3
Robert Varga [Wed, 30 Mar 2016 14:50:55 +0000 (16:50 +0200)]
Do not allow RaftActorBehavior.close() to throw Exception

No implementation uses the ability to throw here, disallow it in API contract.

Change-Id: I8560e60a7cab06f221ff7382f9c205d967efcfe5
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoDo not use Stopwatch.toString() in logging 89/36889/3
Robert Varga [Wed, 30 Mar 2016 14:05:29 +0000 (16:05 +0200)]
Do not use Stopwatch.toString() in logging

This prevents a conversion if the log level is not active.

Change-Id: Ia176a61c50929d500a5e041dd59d39c12a445f62
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoBug 5625: Fix OutOfMemoryError in YangStoreSnapshot 86/36886/2
Tom Pantelis [Tue, 29 Mar 2016 17:37:43 +0000 (13:37 -0400)]
Bug 5625: Fix OutOfMemoryError in YangStoreSnapshot

Close the InputStream returned via yangTextSchemaSource.openStream().

Change-Id: I3ecd2e1a3f52f91203a3a00c2f982b061cc62c42
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
8 years agoUse java.util.Optional in ShardLeaderStateChanged and PrimaryShardInfo 95/36695/4
Robert Varga [Wed, 23 Mar 2016 20:42:04 +0000 (21:42 +0100)]
Use java.util.Optional in ShardLeaderStateChanged and PrimaryShardInfo

This migrates to using Java 8 Optional instead of Guava. It also changes the
constructor conventions as Optional is recommended to be used in short-lived
scenarios (e.g. return type, not argument).

Change-Id: I85db0e02b6c247efd8a84262ee7d05159cf926f8
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoUse java.util.Objects instead of Guava 82/36682/5
Robert Varga [Wed, 23 Mar 2016 19:41:25 +0000 (20:41 +0100)]
Use java.util.Objects instead of Guava

Java 8 gives us a Objects.equals(), so stop using Guava.

Change-Id: I319d01c3d1d8abeaa2da4a38286e024f3055996b
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoUse java.util.function.Supplier instead of Guava 81/36681/5
Robert Varga [Wed, 23 Mar 2016 19:40:41 +0000 (20:40 +0100)]
Use java.util.function.Supplier instead of Guava

Java 8 gives us a Supplier, so stop using Guava.

Change-Id: I0a7e845727df9ee32d5d77ef51e06b92b4d91bb7
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoSplit out ShardInformation 80/36680/5
Robert Varga [Wed, 23 Mar 2016 19:28:24 +0000 (20:28 +0100)]
Split out ShardInformation

ShardInformation is a large inner class, split it out for easier navigation.

Change-Id: I1748f23ff0902c512251bf4aeeb65451f696ba78
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoMake ShardManagerInfo a proper view of ShardManager 55/36655/6
Robert Varga [Wed, 23 Mar 2016 15:54:03 +0000 (16:54 +0100)]
Make ShardManagerInfo a proper view of ShardManager

This reduces method visibility, removing unnecessary methods. It also fixes
thread safety issues around local shard lists by repurposing SwitchShardBehavior
and introducing a query message.

Change-Id: I35b05c067448c0be94411e5599e6faee182d2ced
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoDo not expose the shutdown initiator in OnComplete 74/36874/3
Robert Varga [Wed, 30 Mar 2016 10:09:02 +0000 (12:09 +0200)]
Do not expose the shutdown initiator in OnComplete

The sender (replyTo) is not used from callbacks or anywhere else, it should
really be just internal to the RaftActor's onShutdown path. Also clarify Shutdown
message.

Change-Id: Ibc64e345e54c101f22ff360afc1d71d9d6a281f7
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoUpgrade Aries Proxy 1.0.4 -> 1.0.5 01/36801/3
Stephen Kitt [Tue, 29 Mar 2016 08:14:30 +0000 (10:14 +0200)]
Upgrade Aries Proxy 1.0.4 -> 1.0.5

Karaf 3.0.3 ships with Aries Proxy 1.0.4, but we need the fixes in
version 1.0.5. This patch adds Aries Proxy 1.0.5 to our Karaf
distributions and overrides the version in startup.properties.

Change-Id: Ibe77bc14404e30ea571e46589c983d2e2c47dde5
Signed-off-by: Stephen Kitt <skitt@redhat.com>
8 years agoSimplify onShutdown checks 73/36873/1
Robert Varga [Wed, 30 Mar 2016 09:33:48 +0000 (11:33 +0200)]
Simplify onShutdown checks

We check for RaftState.Leader twice in an if/else chain. Check for non-Leader
first and bail early, leaving a simple if/else to handle the leader case.

Change-Id: I26e2821b0e3ab86f1fd50625ddd1a0ad6ae3b3be
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoMake RaftActor.initiateLeadershipTransfer() private 70/36870/3
Robert Varga [Wed, 30 Mar 2016 09:04:51 +0000 (11:04 +0200)]
Make RaftActor.initiateLeadershipTransfer() private

the only external caller is RaftActorServerConfigurationSupport,
which invokes the method when the actor should become non-voting.

Expose an explicit method for this case and make the leadership
transfer an implementation detail -- making it easier to refactor.

Change-Id: I06c9d1c0c07a92490ddf111d5723c8361001437f
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoUse inline initialization of Stopwatch 69/36869/3
Robert Varga [Wed, 30 Mar 2016 08:55:53 +0000 (10:55 +0200)]
Use inline initialization of Stopwatch

No need to have it the constructor, just inline the initialization.

Change-Id: Ife07c58baee22a503b1b4b4bbcd4c8fa8bb317dd
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoSimplify isolated leader check 67/36867/3
Robert Varga [Wed, 30 Mar 2016 08:53:08 +0000 (10:53 +0200)]
Simplify isolated leader check

Sonar warns about nested ifs, merge them.

Change-Id: I77fcee90b467bc141b79aa5f8fcccb7f8b4f2fe3
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoDo not declare thrown Exception AbstractLeader 66/36866/2
Robert Varga [Wed, 30 Mar 2016 08:50:34 +0000 (10:50 +0200)]
Do not declare thrown Exception AbstractLeader

These methods throw only runtime exceptions, hence tighten the contract
and eliminate a sonar warning.

Change-Id: Ibb8b1f0053f38c5a68cf7e3caaf112c3b7beed09
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoUse a static YangInstanceIdentifier in AbstractEntityOwnerChangeListener 13/36813/3
Robert Varga [Tue, 29 Mar 2016 12:35:47 +0000 (14:35 +0200)]
Use a static YangInstanceIdentifier in AbstractEntityOwnerChangeListener

This will force reuse of the same YangInstanceIdentifier across instances.

Change-Id: Iec33a79267e059ee7fad694a50f74dc2de87035b
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoFix ShardManagerInfo JMX registration error 94/36794/3
Tom Pantelis [Tue, 29 Mar 2016 12:56:43 +0000 (08:56 -0400)]
Fix ShardManagerInfo JMX registration error

The ShardManagerInfo mbean is failing to register with error:
"ShardManagerInfo does not implement DynamicMBean, and neither
follows the Standard MBean conventions". To be a standard MBean, the
implementation class must be in the same package as the MBean
interface. However recent refactoring moved the ShardManagerInfo
class to a new package so I moved both the ShardManagerMBean class to
the org.opendaylight.controller.cluster.datastore.shardmanager package.

Change-Id: I77870e7cf8274f3e99e116d6f18949ac3cf26e41
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
8 years agoSplit out AbstractBuilder and rename it 13/36613/6
Robert Varga [Wed, 23 Mar 2016 15:06:13 +0000 (16:06 +0100)]
Split out AbstractBuilder and rename it

This is a DTO-like class, not really a Builder with .build() method. Split it out
of its enclosing class and rename it to AbstractShardManagerCreator.

Change-Id: I891fc685c2d9776384294a708336b32eb34011b5
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoRefactor MessageTracker 11/36511/5
Robert Varga [Mon, 21 Mar 2016 19:34:12 +0000 (20:34 +0100)]
Refactor MessageTracker

This patch updates MessageTracker implementation with the following:
- lower overhead when dealing with StopWatch under normal conditions
- prevent Context from being instantiated from the outside
- use a Ticker instance for reliable testing
- use Stopwatch.isRunning() instead of explicit done/enable boolean
- properly reset interval timer when expected message is received
- add explicit @NotThreadSafe and @Beta annotations
- move currentMessage to CurrentMessageContext

Change-Id: Idd553a39a8fb885a5c05e391cb4ae45384a59f07
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoMove MessageTracker to sal-clustering-commons 10/36510/5
Robert Varga [Mon, 21 Mar 2016 16:58:54 +0000 (17:58 +0100)]
Move MessageTracker to sal-clustering-commons

Message tracker is useful outside of the data store, move it to commons. This will allow
us to use it in RaftActor's recovery code.

Change-Id: Ia1d8074d6dad7ea051d3650cd417cc773292506c
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoDrop -XX:MaxPermSize 81/35981/2
Stephen Kitt [Wed, 9 Mar 2016 11:21:48 +0000 (12:21 +0100)]
Drop -XX:MaxPermSize

This is no longer supported in Java 8.

Change-Id: Ic421500c6d6d1432a0fa893799b1155d76eb6502
Signed-off-by: Stephen Kitt <skitt@redhat.com>
8 years agoMove SwitchShardBehaviorMessage to shardmanager package 53/36653/4
Robert Varga [Wed, 23 Mar 2016 16:17:59 +0000 (17:17 +0100)]
Move SwitchShardBehaviorMessage to shardmanager package

This message is only used internally by the ShardManager, move it to its
package and limit visibility.

Change-Id: I4c546f214cfcfa2e460cd6e78131e27a6d3bd4d7
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoMove ShardManagerSnapshot to new package 98/36598/4
Robert Varga [Wed, 23 Mar 2016 13:27:17 +0000 (14:27 +0100)]
Move ShardManagerSnapshot to new package

This creates a copy of the ShardManagerSnapshot in the new package and uses
readResolve() to perform migration.

Change-Id: I976adbaafd74de64a90d3970e17ce4ea52bdbe40
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoInitialized visitedAddresses to a smaller list 54/36654/4
Robert Varga [Wed, 23 Mar 2016 15:37:04 +0000 (16:37 +0100)]
Initialized visitedAddresses to a smaller list

Adds final keyword to force initialization and provide a hint that
the list will have a single entry.

Change-Id: I8c562faa5ce6f6303ab11717e55b624a31720281
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoAdd **/yang-gen-config/** to checkstyle ignore path 20/36220/3
Thanh Ha [Mon, 14 Mar 2016 21:08:13 +0000 (17:08 -0400)]
Add **/yang-gen-config/** to checkstyle ignore path

Change-Id: I4080cd5a5c6d2ccd9374af9979ff2fca76e607ab
Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
8 years agoAdd yang-jmx-generator dependency 19/36219/3
Thanh Ha [Mon, 14 Mar 2016 20:45:35 +0000 (16:45 -0400)]
Add yang-jmx-generator dependency

When building in parallel sal-dom-xsql fails due to
yang-jmx-generator missing. This implies that yang-jmx-generator is
actually a dependency.

Change-Id: I624d4026d8182c12a147830ded0391eca25b0f62
Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
8 years agoUse range import for odl-akka-* 23/36823/1
Robert Varga [Tue, 29 Mar 2016 16:22:41 +0000 (18:22 +0200)]
Use range import for odl-akka-*

We do not need akka.version, but should use a version range import.

Change-Id: Ib7d2f4233945023fe3b12cdcce01e4a345a35dc8
Signed-off-by: Robert Varga <robert.varga@pantheon.sk>
8 years agoRemove DelegatingRaftActorBehavior 60/36160/11
Robert Varga [Tue, 15 Mar 2016 13:32:58 +0000 (14:32 +0100)]
Remove DelegatingRaftActorBehavior

The delegate is leaked through various methods, implementations of which already have access
to the current behavior if it were available from RaftActorContext. Simplify calling
conventions

Change-Id: I9e27f68e55f28a9afd446abff91fbb38dd26c011
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoEnlarge critical section to cover processNextTransaction() 49/36749/2
Robert Varga [Thu, 24 Mar 2016 18:59:49 +0000 (19:59 +0100)]
Enlarge critical section to cover processNextTransaction()

As it turns out the critical section is not sufficient to cover the case
when the user thread performs a submit/allocate/submit in the time window
between us releasing the in-flight transaction and taking the lock: we would
have to re-check inflightTx after taking the lock.

Since we are going to take the lock anyway, reverse the order of operations
by making processNextTransaction() synchronized, which means the user
thread will not be able to submit the transaction even when it observes
inflightTx as null outside the lock.

Change-Id: I688ceb5e8aae28f5e582b64e6bbaa64c9699c7f5
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoMove ShardManager into its own package 90/36590/7
Robert Varga [Wed, 23 Mar 2016 12:29:04 +0000 (13:29 +0100)]
Move ShardManager into its own package

ShardManager contains quite a few classes, which are not used by the rest
of the data store. Some of them are in their own files, some of them are
hosted in ShardManager.java.

This first step allows us to isolate related functionality without leaking
it to the rest of the package, separating internal an external interfaces.

Change-Id: I955296d739d962d912eadf0507c317b0a8e71deb
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoForward pending transactions on leadership change 99/35199/9
Tom Pantelis [Mon, 22 Feb 2016 01:41:16 +0000 (20:41 -0500)]
Forward pending transactions on leadership change

If the current leader is deposed for some reason and it has pending
tx's, on leader change, the tx's will now be converted to
BatchedModifications messages and forwarded to the new leader in the
ready state so the new leader can complete the commits. Previously
they were aborted and failed.

In addition, if there's a current transaction that had already been
canCommitted and possibly preCommitted, CanCommitTransaction and
CommitTransaction messages will also be sent to the new leader appropriately.

Change-Id: I9bbd68856586c15464f4ca0e844f040c6bb5f30a
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
8 years agoImplement change to voting with no leader 23/32723/12
Tom Pantelis [Wed, 13 Jan 2016 21:17:28 +0000 (16:17 -0500)]
Implement change to voting with no leader

Implemented a special case where on a voting state change from
non-voting to voting, if there's no leader, it will try to elect a
leader in order to apply the change and progress.

This is to handle a use case where one has 2 geographically-separated
3-node clusters, one a primary and the other a backup such that if the
primary cluster is lost, the backup can take over. In this scenario,
there's a logical 6-node cluster where the primary sub-cluster is
configured as voting and the backup sub-cluster as non-voting such
that the primary cluster can  make progress without consensus from
the backup cluster while still replicating to the backup. On fail-over
to the backup, a request would be sent to a member of the backup
cluster to flip the voting states, ie make the backup sub-cluster
voting and the lost primary non-voting. However since the primary
majority cluster is lost, there would be no leader to apply, persist and
replicate the server config change.

Therefore, if the server processing the request is currently non-voting
and is to be changed to voting and there is no current leader, it will
try to elect itself the leader by applying the new server config change in
the RaftActorContext and sending an ElectionTimeout. If it's elected
leader, it persists and replicates the new server config. If no leader
change occurs within the election timeout period, it reverts the server
config change and tries to forward the change request to another server
with the same voting state change. In this manner, the intent is to elect
the newly voting server that has the most up to date log.

Change-Id: I67b5b2d3a97745dbe9a8215f9a28f3a840f2a0db
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
8 years agoAdd a few toString() methods 05/36105/2
Stephen Kitt [Fri, 11 Mar 2016 10:14:44 +0000 (11:14 +0100)]
Add a few toString() methods

These help when converting to DataTree ;-).

Change-Id: I9b0fdb428ebe0265cb4321bd6ee31dedb4811950
Signed-off-by: Stephen Kitt <skitt@redhat.com>
8 years agoUse partial mocking for FollowerTest 68/36568/1
Robert Varga [Tue, 22 Mar 2016 17:57:58 +0000 (18:57 +0100)]
Use partial mocking for FollowerTest

This patch removes the need for a subclass and some explicit casts.

Change-Id: I19a30266f8690ffcc68f70e949d88101db6552ae
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoMake AbstractRaftActorBehavior.state() final 66/36566/1
Robert Varga [Tue, 22 Mar 2016 17:38:46 +0000 (18:38 +0100)]
Make AbstractRaftActorBehavior.state() final

This removes the potential inconsistency in IsolatedLeader, where the internal
field (state) would be seen as Leader whereas the reported value (state()) would be
IsolatedLeader.

Change-Id: I079f934e31bb52b306ccc21e16b6c23442e87ce4
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoDecouple RaftState and RaftActorBehaviors 65/36565/1
Robert Varga [Tue, 22 Mar 2016 17:04:56 +0000 (18:04 +0100)]
Decouple RaftState and RaftActorBehaviors

This patch makes RaftState (which is a RAFT concept) independent of
behaviors (which are an implementation detail). This will allow us to
freeze RaftState and make it more widely available.

Change-Id: I70b4e7f762e3cb20a6c7b865f1a0c1f46f9a3d33
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoMake SwitchShardBehavior transport RaftState 57/36557/1
Robert Varga [Tue, 22 Mar 2016 14:38:14 +0000 (15:38 +0100)]
Make SwitchShardBehavior transport RaftState

Instead of passing around generic strings (and potential failures from that),
make sure the message carries a proper raft state.

Change-Id: Id2c97773464d2a643f67a391247d58917c62d0c4
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoFixup ShardManagerInfo constants 56/36556/1
Robert Varga [Tue, 22 Mar 2016 14:34:51 +0000 (15:34 +0100)]
Fixup ShardManagerInfo constants

Use an ImmutableList for allowed states and make the JMX category a proper constant.

Change-Id: I72fe41b55a0534e72d8aa4a7128c0506339d0a19
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoFix wait for schema in BindingToNormalizedNodeCodec 81/35881/7
Tom Pantelis [Mon, 7 Mar 2016 11:20:13 +0000 (06:20 -0500)]
Fix wait for schema in BindingToNormalizedNodeCodec

The wait for schema mechanism does not work. A few issues were fixed:

 - FutureSchema did not add the FutureSchemaPredicate instances to the
   postponedOperations list so they always timed out.

 - The waitForSchema method in BindingToNormalizedNodeCodec checked for
   !futureSchema.waitForSchema so it only successfully returned on
   failure.

 - There was a timing issue in FutureSchema where a context update could
   occur just prior to adding a postponed operation to the list, in
   which case the operation may timeout if the new update contained the
   postponed criteria and another update didn't occur in time. To
   alleviate this, the sychronization was tighted up and runtime context
   is now stored in FutureSchema instead of BindingToNormalizedNodeCodec.

 - The runtimeContext field needs to be volatile.

I also added a wait if the runtimeContext was null b/c
onGlobalContextUpdated hadn't been initially notified yet.

Added unit tests to cover the wait for schema mechanism.

Change-Id: I7155dae021453d085f89d13dfd4b069178dd2fc8
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
8 years agoStop logging complete data tree on prepare/commit failure 57/36457/2
Moiz Raja [Fri, 18 Mar 2016 19:29:50 +0000 (12:29 -0700)]
Stop logging complete data tree on prepare/commit failure

Sometimes the data tree modification is so large that just trying to create
the buffer to hold the message can make the controller run out of memory. Plus
it's rarely useful to have a log filled with data which obfuscates other
important log messages. This patch still logs the data tree modification at
trace level.

Change-Id: I76bff9f7e836ee5eff347b0b77e2817f441ab953
Signed-off-by: Moiz Raja <moraja@cisco.com>
8 years agoUse instanceof instead of .class.isInstance() 98/36298/2
Robert Varga [Wed, 16 Mar 2016 15:16:35 +0000 (16:16 +0100)]
Use instanceof instead of .class.isInstance()

These two are equivalent and using instanceof is more consistent with the rest
of the code.

Change-Id: I0493a94a09f66e19afb503afd05682692fba1b40
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoHandle snapshot support messages first 97/36297/2
Robert Varga [Wed, 16 Mar 2016 13:50:56 +0000 (14:50 +0100)]
Handle snapshot support messages first

This checks with snapshot snapshot support first, making the code a bit
more readable.

Change-Id: I1a9ea097d71b2f28771e19b2b1979ebff0f15e7a
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoRemove duplicate 'return true' statements 96/36296/2
Robert Varga [Wed, 16 Mar 2016 13:48:12 +0000 (14:48 +0100)]
Remove duplicate 'return true' statements

Instead of having each case return true, make it the default return
from the method and use the last else branch to return false.

Change-Id: I545d2f2c19ef8a10b693a0e904766141bc5db34e
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoDo not allow overrides of onReceive{Command,Recover} 92/36292/3
Robert Varga [Wed, 16 Mar 2016 13:21:16 +0000 (14:21 +0100)]
Do not allow overrides of onReceive{Command,Recover}

We already have protected methods to handle these cases, do not allow
overrides, as they create confusion around which method does what.

Change-Id: I3d6e9b9c4dc72a53471bf60324e4c7f36845ed5b
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoBug 2562: Binding Data Codec: Incorrectly deserialized unkeyed list from NormalizedNode 35/36435/2
Filip Gregor [Fri, 18 Mar 2016 10:21:03 +0000 (11:21 +0100)]
Bug 2562: Binding Data Codec: Incorrectly deserialized unkeyed list from NormalizedNode

added test show that this is no longer an issue

Change-Id: I3f84b0ebc71d1fef85068e2ff7b06a78c397e4c8
Signed-off-by: Filip Gregor <fgregor@cisco.com>
8 years agoFix forwarding in Shard.handleBatchedModifications 21/35121/6
Tom Pantelis [Fri, 19 Feb 2016 21:40:52 +0000 (16:40 -0500)]
Fix forwarding in Shard.handleBatchedModifications

Addressed the TODO in Shard.handleBatchedModifications to handle the
case where the BatchedModifications is not the first batch when leadership
changes and the BatchedModifications needs to be forwarded to the new
leader. Added code in ShardCommitCoordinator to reconstruct all previous
BatchedModifications messages, if needed, from the transaction
DataTreeModification, honoring the max batched modification count.

Change-Id: I4fecb71be91aee24072086e1565437a69c20c8d9
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
8 years agoImplement ChangeServersVotingStatus message in RafActor 11/32511/8
Tom Pantelis [Tue, 12 Jan 2016 23:21:15 +0000 (18:21 -0500)]
Implement ChangeServersVotingStatus message in RafActor

Added a new ChangeServersVotingStatus message to change servers to/from
voting members. The leader updates its local peer info and persists and
replicates a new ServerConfigurationPayload with the appropriate voting
states. If the leader changes to non-voting it steps down as leader by
initiating a leadership transfer.

Change-Id: If073e4665cb1a270aae6e3dce36a6b3e900d0282
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
8 years agoFix intermittent unit test failures 40/36440/1
Tom Pantelis [Fri, 18 Mar 2016 04:22:27 +0000 (00:22 -0400)]
Fix intermittent unit test failures

Change-Id: I2ef68b48de8da4cc7d82a91263976295458d011a
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
8 years agoBug 5485: Improve DataTreeModification pruning on recovery 13/36013/5
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 agoBug 5460: Fix snaphots on follower 74/36274/2
Tom Pantelis [Tue, 15 Mar 2016 23:51:58 +0000 (19:51 -0400)]
Bug 5460: Fix snaphots on follower

Added a callback to the appendAndPersist call in Follower to call
captureSnapshotIfReady.

Added checks in ReplicationAndSnapshotsIntegrationTest to verify the
followers snapshot along with the leader.

Change-Id: Ie71f1b16152541d069f9d005ba669cb1e5771dd1
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
8 years agoConvert toaster-it to use mdsal-it 74/36074/9
Tom Pantelis [Thu, 10 Mar 2016 11:48:43 +0000 (06:48 -0500)]
Convert toaster-it to use mdsal-it

I recently added an mdsal dependency to another project and it caused
the toaster-it test to fail. There was no useful output to troubleshoot,
just that some bundles failed to resolve.

It turns out the mdsal dependency and all its dependencies would need to be
added to the hard-coded bundle configuration for the test. This will be ongoing
issue every time a new dependency is added that might affect the toaster test.

To alleviate this I converted the test from manually installing bundles to use
the mdsal-it functionality which installs features into the
opendaylight-karaf-empty distro.

I also changed AbstractConfigTestBase to override the pax logging to
append to stdout, otherwise most output goes to karaf.log. This is helpful to
troubleshoot failures.

Change-Id: I1dd9150c6e617e491458560fe4b360d37548f264
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
8 years agoFix intermittent RaftActorLeadershipTransferCohortTest failure 58/36158/2
Tom Pantelis [Fri, 11 Mar 2016 23:44:55 +0000 (18:44 -0500)]
Fix intermittent RaftActorLeadershipTransferCohortTest failure

Change-Id: I4c58f6545d7ef7667c7fcf42f5dda82345ab1167
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
8 years agoAdd Maven Site generation data 22/36022/4
Thanh Ha [Thu, 10 Mar 2016 02:04:09 +0000 (21:04 -0500)]
Add Maven Site generation data

Add the necessary configuration to allow new projects to automatically
have Maven Site generation enabled when they use the startup-archetype.

Change-Id: Icfd69505bb01f3e8f895a7fef4147d4d8779de9d
Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
8 years agoFix yangtools version in startup archetype 21/36021/3
Thanh Ha [Thu, 10 Mar 2016 01:46:39 +0000 (20:46 -0500)]
Fix yangtools version in startup archetype

Yangtools version for Boron should be 1.0.0-SNAPSHOT.

Change-Id: I2109eb26d8de717ecfa212d1448456a4048e9191
Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
8 years agoChange default version to 0.1.0-SNAPSHOT 20/36020/4
Thanh Ha [Thu, 10 Mar 2016 01:35:02 +0000 (20:35 -0500)]
Change default version to 0.1.0-SNAPSHOT

With semantic versioning a project's initial version should not start
with 1.0.0-SNAPSHOT. Changing it to 0.1.0-SNAPSHOT so that a project can
start off with the recommended value.

See: http://semver.org/

Change-Id: Id3b99a9a5ccb2d68be02cc6faa0d4253e5b80f80
Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
8 years agoBump default copyright year to 2016 19/36019/4
Thanh Ha [Thu, 10 Mar 2016 01:34:20 +0000 (20:34 -0500)]
Bump default copyright year to 2016

Change-Id: I1d520d0c0b18002921f1f45768f62cdf58214cfb
Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
8 years agoImprove formatting for visual satisfaction 18/36018/4
Thanh Ha [Thu, 10 Mar 2016 01:29:08 +0000 (20:29 -0500)]
Improve formatting for visual satisfaction

Formatting for the startup poms improved to be more visually appealing
and easier to read.

Change-Id: Ibdd3828f712eed1e6864bbbbcbb316bf4e5962ac
Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
8 years agoBug 4823: Offload generation of DCNs from Shard 96/34096/5
Tom Pantelis [Thu, 4 Feb 2016 06:39:20 +0000 (01:39 -0500)]
Bug 4823: Offload generation of DCNs from Shard

Generation of data change notifications can be expensive with large
lists which can block the Shard actor for many seconds. This processing
was offloaded to other actors to free up the Shard, one for DCLs and the
other for DTCLs. I separated the 2 types of listeners b/c DCN generation
is much more expensive than DTCs so at least DTCLs aren't held up by
DCLs.

Change-Id: I1bfb5d572c793f8eb703ebf0a7fd9bf628747168
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
8 years agoDo not guard simple logging with isXXXEnabled() 18/36118/1
Robert Varga [Fri, 11 Mar 2016 12:30:52 +0000 (13:30 +0100)]
Do not guard simple logging with isXXXEnabled()

There is not benefit in the guards, making them pure overhead.

Change-Id: I75e310a2f08e5650db436bb4a7f46d85cbde313d
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoRemove commented-out logging 16/36116/1
Robert Varga [Fri, 11 Mar 2016 12:07:26 +0000 (13:07 +0100)]
Remove commented-out logging

Remove commented-out logging lines and do not condition simple logging
on isDebugEnabled().

Change-Id: I648ee585a4cf2e4a4dfabecdcf0ce833906b4dac
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoFix issues with LeastLoadedCandidateSelectionStrategy 14/33714/3
Moiz Raja [Wed, 27 Jan 2016 22:43:39 +0000 (14:43 -0800)]
Fix issues with LeastLoadedCandidateSelectionStrategy

LLCSS degenerates into a round robin owner allocator when
ownership changes. This patch fixes that issue as follows,

- Consider the statistics that are collected using the DTL
  only as initialStatistics which are passed to the Strategy
  when it is created
- When Leadership changes clear all the strategies so that
  they get freshly created with the right initial statistic
- Modify the newOwner method on Strategy to
    - pass the currentOwner for the entity, for the current
      owner we decrease the ownership statistic
    - remove the statistics passed to it as it would no longer
      be required. Due to this removal we also get rid of all
      the CRUD which we had added to check if the passed in
      stats were actually greater than the local stats which
      anyway did not work.

Change-Id: I754f0459051687a95056857044777ca6eebbcd93
Signed-off-by: Moiz Raja <moraja@cisco.com>
8 years agoRemoved unnecessary file. 83/35083/3
Tony Tkacik [Fri, 19 Feb 2016 13:33:09 +0000 (14:33 +0100)]
Removed unnecessary file.

Change-Id: I1dfe4ec5a2ccca36f44d68c1639f28572425b831
Signed-off-by: Tony Tkacik <ttkacik@cisco.com>
8 years agoClean up DistributedEntityOwnershipService instantiation 01/35501/9
Robert Varga [Sat, 27 Feb 2016 01:30:06 +0000 (02:30 +0100)]
Clean up DistributedEntityOwnershipService instantiation

Most validation checks are done in customValidation(). Also add more
resilency to possible interactions with ConfigAdmin service.

The lambda conversion comes courtesy Eclipse on-save autoconvert.

A lot of this code needs to go away.

Change-Id: Ifaf4416015996be9a7716a2620f16a56b74d12b5
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoDo not duplicate candidate list 45/35545/3
Robert Varga [Mon, 29 Feb 2016 11:45:52 +0000 (12:45 +0100)]
Do not duplicate candidate list

Iterables.getLast() provides an efficient way of getting the last item
from a collection, without the need to duplicate it.

Change-Id: I49b0bc827bffc0adb616cf516438bad7526ad141
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoDo not use String.toString() 42/35542/3
Robert Varga [Mon, 29 Feb 2016 11:36:17 +0000 (12:36 +0100)]
Do not use String.toString()

Use Strings.isNullOrEmpty instead of open-coding the check, also add
preconditions for fields and eliminate a String.toString() call.

Change-Id: Ic25a60511514ea623d1d9bdde9675faec8d538f8
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoBUG-4964: Bump to akka-2.4.1 24/32524/19
Robert Varga [Wed, 13 Jan 2016 20:42:04 +0000 (21:42 +0100)]
BUG-4964: Bump to akka-2.4.1

This updates the imports and adapts to API changes. Requires Java 8 to
work. Also bumps netty to 3.10.5, as that is what remoting requires.

Change-Id: I3a3886ac75496d07ec03ae561a6df03ecaa5ad0c
Signed-off-by: Robert Varga <robert.varga@pantheon.sk>
8 years agoModify toaster example to use DataTreeChangeListener 09/35209/3
Tom Pantelis [Mon, 22 Feb 2016 04:22:43 +0000 (23:22 -0500)]
Modify toaster example to use DataTreeChangeListener

Change-Id: I88e16026247d4e4f979eb795f5c5ea33857ac66f
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
8 years agoFix ConcurrentModificationEx in RpcRegistry.onBucketsUpdated 14/35714/2
Tom Pantelis [Thu, 3 Mar 2016 17:52:47 +0000 (12:52 -0500)]
Fix ConcurrentModificationEx in RpcRegistry.onBucketsUpdated

This was introduced by a recent patch. onBucketsUpdated iterates the
routesUpdateCallbacks however one of the callbacks in receiveGetRouter
removes itself from the list causing the ConcurrentModificationEx.

I changed onBucketsUpdated to first copy the list to an array to prevent
this.

Change-Id: I44c9a89b4b433f711cf4f90bf28e6955d8784f5f
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
8 years agoRemove unused obsolete concepts code. 87/35087/4
Tony Tkacik [Fri, 19 Feb 2016 13:38:25 +0000 (14:38 +0100)]
Remove unused obsolete concepts code.

Change-Id: I7898e6ced3938ff245cbc9d4861bdce23e909d30
Signed-off-by: Tony Tkacik <ttkacik@cisco.com>
8 years agoRemoved non-building code. 84/35084/3
Tony Tkacik [Fri, 19 Feb 2016 13:36:06 +0000 (14:36 +0100)]
Removed non-building code.

Change-Id: Ic7ddbb76b3485704ffc48602c3081122cdd03d72
Signed-off-by: Tony Tkacik <ttkacik@cisco.com>
8 years agoMove JMX generator out of src/main 52/35052/3
Robert Varga [Fri, 19 Feb 2016 10:06:00 +0000 (11:06 +0100)]
Move JMX generator out of src/main

Move generated files to target/generated-sources/config-binding to make
sure we do not emit generated source files to src/main, where they run
risk of being added to SCM.

Change-Id: Idc8733dbfd5b125c96bfb49069a908174bfeefd0
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoUse {{VERSION}} for config files 20/35320/3
Robert Varga [Wed, 24 Feb 2016 10:16:01 +0000 (11:16 +0100)]
Use {{VERSION}} for config files

This detects failure to include a dependency, ensuring a failure.

Change-Id: I350a47ad7d844e0e61c818da796810c4ea1000dd
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoBUG-4329: remove references to JDT 58/35358/1
Robert Varga [Wed, 24 Feb 2016 20:43:18 +0000 (21:43 +0100)]
BUG-4329: remove references to JDT

Since we have migrated the lonely test using JDT, we can now remove
references to it.

Change-Id: Ic814ba20e11ce95e5d25260be4c7cebcd5a21565
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoFix broken downstream features 17/35317/1
Robert Varga [Wed, 24 Feb 2016 09:18:36 +0000 (10:18 +0100)]
Fix broken downstream features

factoryakkaconf needs to be spelled out in the dependency of
features-mdsal.

Change-Id: I71e7cff1076fc63c08f6debefc72107046f8337f
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoBug 4866: Add wait/retries for routed RPCs 75/34175/4
Tom Pantelis [Fri, 5 Feb 2016 07:42:54 +0000 (02:42 -0500)]
Bug 4866: Add wait/retries for routed RPCs

If a routed RPC is registered on one node it takes a little time for the
route to propagate via gossip to other nodes. If another node tries to
invoke the RPC prior to propagation it fails. To alleviate this timing
issue, I added wait/retries via a timer in the RpcRegistry for the
FindRouters message. As routes are updated via gossip, it retries the
FindRouters request. If the timer triggers, it sends back an empty list.
The timer period is 10 times the gossip tick interval (500ms * 10 = 5s).

Change-Id: Iaafcfb4c93cde44f62f6645c8b8684102ac0d0db
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
8 years agoFix sporadic failures in ClusterAdminRpcServiceTest 85/35285/2
Tom Pantelis [Tue, 23 Feb 2016 18:10:21 +0000 (13:10 -0500)]
Fix sporadic failures in ClusterAdminRpcServiceTest

The testAddShardReplica is failing sporadically indirectly due to
https://git.opendaylight.org/gerrit/#/c/35097/. The leader's payload
version was -1 so a transaction's BatchedModifications instance was
serialized to the legacy protobuf message type and thus wasn't delivered.

The underlying problem is that RaftActor.updateConfigParams
needs to pass the previous leader's payload version when re-constructing
the Follower instance on RaftPolicy change.

Change-Id: Id6b8da98c145f2e265dddbc1b27384d54e400370
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
8 years agoBug 5329: Add factory akka.conf 53/34553/5
Tom Pantelis [Fri, 12 Feb 2016 14:08:15 +0000 (09:08 -0500)]
Bug 5329: Add factory akka.conf

Added a factory akka.conf file that is shipped to
configuration/factory/akka.conf. This file contains all the necessary
akka settings. Modified the FileAkkaConfigurationReader to load the
existing configuration/initial/akka.conf file with the factory file as
the fallback. In this manner akka will overlay/merge the initial file
with the factory file. I pared down the initial file to only contain the
settings that users would normally set or configure to setup a cluster,
ie hostname, port, seed-nodes, roles.

In the features.xml, the factory file is configured to always overwrite
so changes are picked up on upgrade. We still preserve the initial file.

Change-Id: I8e80161e21d0ad0e26f1efa1023c670b3a5ef6bc
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
8 years agoRemove unused org.opendaylight.controller.xml.codec package/classes 14/35114/5
Tom Pantelis [Fri, 19 Feb 2016 16:12:17 +0000 (11:12 -0500)]
Remove unused org.opendaylight.controller.xml.codec package/classes

The org.opendaylight.controller.xml.codec utility classes in
sal-clustering-commons are no longer used so remove them. They were
originally used by the remote RPC code for conversion of the legacy
CompositeNode class which has since been removed. The code referencing
CompositeNode et al was removed from these classes but unused
remnants were left behind.

Change-Id: Ic8f880c8075f076549bb822f6dfbaaad81595ed1
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
8 years agoFix TerminationMonitor to reference correct Monitor class 13/35113/5
Tom Pantelis [Fri, 19 Feb 2016 15:46:37 +0000 (10:46 -0500)]
Fix TerminationMonitor to reference correct Monitor class

The TerminationMonitor actor listens for messages of type
org.opendaylight.controller.cluster.datastore.messages.Monitor
but the AbstractUntypedActor sends a message of type
org.opendaylight.controller.cluster.common.actor.Monitor.
TerminationMonitor was changed to reference the right class and
org.opendaylight.controller.cluster.datastore.messages.Monitor was
removed.

Change-Id: Ie0e8dd4face529c3b40e1227fec575a8bd4c9425
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>