7 years agoMake REUSABLE_*_TL final 69/28769/5
Robert Varga [Sat, 24 Oct 2015 09:44:30 +0000 (11:44 +0200)]
Make REUSABLE_*_TL final

Since these are public static fields, they should be final to prevent
possible shenanigans.

Change-Id: I4a360e060ddde57a73118bcf3d053ce397204136
Signed-off-by: Robert Varga <>
7 years agoReduce ShardDataTree#getDataTree() callsites 29/28729/7
Robert Varga [Fri, 23 Oct 2015 12:24:39 +0000 (14:24 +0200)]
Reduce ShardDataTree#getDataTree() callsites

A lot of these callsites perform a specific function, expose those
functions without leaking the DataTree. This is needed to handle
asynchronous persistence and optimistic transaction commit.

Change-Id: I330cb4172349e0d1d8daacc3aafce7dad64cd8b2
Signed-off-by: Robert Varga <>
7 years agoDo not declare unneeded Exception throw 27/28727/5
Robert Varga [Fri, 23 Oct 2015 10:42:05 +0000 (12:42 +0200)]
Do not declare unneeded Exception throw

Fixes sonar warnings

Change-Id: I31ab95c75cf30b33c9025d6f6e4662ccc5df7a47
Signed-off-by: Robert Varga <>
7 years agoMake private methods static 26/28726/5
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

Change-Id: I416e415b90647b4f700b7893fe4f64f479271fab
Signed-off-by: Robert Varga <>
7 years agoAdd getPeerIds to RaftActorContext 18/28718/6
Tom Pantelis [Fri, 23 Oct 2015 02:50:20 +0000 (22:50 -0400)]
Add getPeerIds to RaftActorContext

For upcoming to work to add voting status to the peer info in
RaftActorContext, I added a getPeerIds method to replace calls to
getPeerAddresses as virtually all callers really just want the IDs or want
to check the size. getPeerAddresses will (likely) be removed altogether -
this is a preliminary patch.

Change-Id: I2b6f2c36dfec14ccd4bbfef35e67ed86cf3e3e45
Signed-off-by: Tom Pantelis <>
7 years agoFix resource leaks in TransactionChainProxyTest 54/28754/2
Gary Wu [Fri, 23 Oct 2015 20:40:48 +0000 (13:40 -0700)]
Fix resource leaks in TransactionChainProxyTest

Close TransactionChainProxy objects (AutoCloseable)
that were not being closed in the test cases.

Change-Id: I85b1f951545b764007bdb2e808a2438c9bd4b2b2
Signed-off-by: Gary Wu <>
7 years agoupdate leveldbjni version to support Solaris 93/25693/2
rshoaib [Sat, 22 Aug 2015 06:24:57 +0000 (23:24 -0700)]
update leveldbjni version to support Solaris

Change-Id: I46de5b3cc9c220a70a408194fb3ff709cdff1937
Signed-off-by: rshoaib <>
7 years agoBug 2187: Code cleanup and refactoring 74/28674/5
Tom Pantelis [Wed, 21 Oct 2015 22:47:31 +0000 (18:47 -0400)]
Bug 2187: Code cleanup and refactoring

I addressed remaining comments from a prior patch.

I also refactored RaftActorServerConfigurationSupport to use an FSM
similar to the SnapshotManager with some generic classes. This will
make it easier to implement RemoveServer and reuse code.

Change-Id: Id3cdcede3f9c393c878abd3e9a9d3a5e12c5fb8a
Signed-off-by: Tom Pantelis <>
7 years agoRemove unused Jersey dependencies from the controller 40/28740/2
Ryan Goulding [Fri, 23 Oct 2015 15:19:11 +0000 (11:19 -0400)]
Remove unused Jersey dependencies from the controller

The code utilizing Jersey was moved to the netconf project.  This change
removes some of the deprecated dependencies.

Change-Id: I62b944497c976b1251412d8d047ef833e69dfb0a
Signed-off-by: Ryan Goulding <>
7 years agoRemove unnecessary @SuppressWarnings 43/28743/2
Gary Wu [Fri, 23 Oct 2015 16:44:06 +0000 (09:44 -0700)]
Remove unnecessary @SuppressWarnings

Change-Id: I2b59e7f29a15298c1135c12b6bd9699205706600
Signed-off-by: Gary Wu <>
7 years agoFix resource leaks in exception handling 09/28709/3
Gary Wu [Thu, 22 Oct 2015 20:01:13 +0000 (13:01 -0700)]
Fix resource leaks in exception handling

Fix resource leaks when exceptions are
encountered during ConfigManagerActivator.start().

Change-Id: Ic12c756aa5a768add0bc62e71eed94e5b2fa5fea
Signed-off-by: Gary Wu <>
7 years agoBug 4037: Allow auto-downed node to rejoin cluster 52/27852/8
Gary Wu [Fri, 2 Oct 2015 20:12:43 +0000 (13:12 -0700)]
Bug 4037: Allow auto-downed node to rejoin cluster

This patch will detect when a node has been
auto-downed/quarantined by another node. When this
happens, the ActorSystem of the datastore will be
restarted to allow the node to rejoin the cluster.

Change-Id: I0913bf455d426b6a0fccb17eac61b74f0911fa5d
Signed-off-by: Gary Wu <>
7 years agoBug 2187: AddServer unit test and bug fixes 63/28663/3
Tom Pantelis [Wed, 21 Oct 2015 09:02:17 +0000 (05:02 -0400)]
Bug 2187: AddServer unit test and bug fixes

Follow-up patch to

Got the unit tests working and added more unit tests to cover more code.

Also fixed several bugs in the code that were failing the tests. One bug
was caused by replicating data quickly after install snapshot was
complete. On the final install snapshot chunk the follower sends an
ApplySnaphot message to persist and apply the snapshot. On the reply,
the leader assumes the follower is up-to-date and sets its next index.
However, applying the snapshot, ie updating the log and commit index, is
actually done after the async callback from the snapshot persist. In between
that time, if the leader sends the server config AppendEntries, the follower's
log is still empty and it deems itself out-of-sync and reports back failure.
This will cause the leader to eventually send a new install snaphot
which isn't which is not desirable. Also it may delay consensus for the
server config entry.

To fix this, I delayed the final InstallSnapshotReply until after the
ApplySnapshot is complete. I did this by adding a Callback to the
ApplySnapshot message which the SnapshotManager invokes.

Also the new server config was constructed without the leader's ID - it
needs to contain all members.

Also the ServerConfigurationPayload wasn't being applied in the

Another issue was that, if the leader had no peers initially, the
heartbeat wasn't scheduled so, when the new server was added, heartbeats
weren't occurring. So I change addFollower to schedule the heartbeat.

I added a test for adding a non-voting server which caused an endless
loop in AbstractLeader#handleAppendEntriesReply where it updates the
commitIndex based on the replicated count. To fix this, I added a break
if the replicatedLogEntry is null.

Change-Id: I5dff351140c611d58357cd58900bed401606038c
Signed-off-by: Tom Pantelis <>
7 years agoBUG 2187 - JMX API for create/delete shard replica 42/27742/13
kalaiselvik [Thu, 22 Oct 2015 10:19:47 +0000 (15:49 +0530)]
BUG 2187 - JMX API for create/delete shard replica

Change-Id: I48a4dcb7983f5f231e9ddc04e851950abf7c2d8a
Signed-off-by: kalaiselvik <>
7 years agoBUG-2187: Add Server - Leader Implementation 18/28018/9
Rajesh_Sindagi [Tue, 20 Oct 2015 22:38:41 +0000 (15:38 -0700)]
BUG-2187: Add Server - Leader Implementation

Processes addServer request from the follower, forwards the request
to the shard leader, if not the leader.

The follower shard replica data is brought to sync with leader by installing the snapshot from the shard leader.
On sucessful application of snapshot data, this voting but not initialized member is transitioned to voting member.
New server configuration is persisted and replicated to majority of the followers and responds back with OK message to the shard follower.

In case where the leader is unable to sync data to the follower in a configured time period, TIMEOUT message is responded back to the shard follower without adding/persisting the new server configuration.

Change-Id: I9a3870d14bb6ad532ff64f315b2e2000d8b803e2
Signed-off-by: Rajesh_Sindagi <>
7 years agoAdd cluster config yang RPCs and provider wiring 66/28366/6
Tom Pantelis [Wed, 14 Oct 2015 01:53:48 +0000 (21:53 -0400)]
Add cluster config yang RPCs and provider wiring

Added experimental RPCs, including AddShardRelica, with initial empty
implementations that return unsupported.

Change-Id: Ie8587903920760fc4555bc009c81183e8d7740e4
Signed-off-by: Tom Pantelis <>
7 years agoFix DistributedDataStoreIntegrationTest failure 95/28395/3
Tom Pantelis [Wed, 14 Oct 2015 05:42:08 +0000 (01:42 -0400)]
Fix DistributedDataStoreIntegrationTest failure

Fixed a timing issue with a test just started causing failures pretty
regularly on jenkins builds for some reason.

Change-Id: I40273574376804034fd6f14f56384cb8cae26900
Signed-off-by: Tom Pantelis <>
7 years agoAdd missing dependencies 18/28318/2
Stephen Kitt [Tue, 13 Oct 2015 08:49:33 +0000 (10:49 +0200)]
Add missing dependencies

pax-url-aether provides javax.inject and commons-codec, but they need
to be declared separately for correctness and to allow upgrades to
newer versions of pax-url-aether. can be replaced by javax.inject.Inject.

Change-Id: I0a1da43faf0345bd71c2737caaa840c396bc60ab
Signed-off-by: Stephen Kitt <>
7 years agoFix ModuleFactory not found errors 11/28211/5
Tom Pantelis [Wed, 7 Oct 2015 18:24:40 +0000 (14:24 -0400)]
Fix ModuleFactory not found errors improvements to the
config system but had the side-effect of introducing timing issues where
a ModuleFactory wasn't found when trying to push a config. The reason is
that yang schemas load earlier and much quicker than ModuleFactory's,
which are scanned from ACTIVE bundles, so the capabilities may resolve
but a ModuleFactory may not be available yet. As a result, that patch
was partially reverted for the time being.

To fix the missing ModuleFactory issue, I added retries in the
ConfigPusherImpl when a ModuleFactory isn't found, similar to the
ConflictingVersionException retries. The backend now throws a new
checked exception, ModuleFactoryNotFoundException, which is caught to
trigger a retry after a delay. Prior, it threw an
InstanceNotFoundException which was wrapped in an
IllegalArgumentException. I didn't keep the InstanceNotFoundException
b/c it can be thrown for other reasons and I wanted to distinguish
missing ModuleFactoryNotFoundException.

I derived ModuleFactoryNotFoundException from RuntimeException to avoid
having to change signatures in the call chain and thus changing the API.
Prior it threw an unchecked IllegalArgumentException anyway so it's
consistent plus other areas of the code throw unchecked exceptions along
with checked exceptions.

Since the missing ModuleFactory issue is fixed, I re-enabled scanning of
RESOLVED bundles in the ModuleInfoBundleTracker.

Change-Id: I89ff346c0a89afdfa76ce402f2cf3211ac68b5c0
Signed-off-by: Tom Pantelis <>
7 years agoBUG 4151 : Create a shared actor system 62/27562/9
Moiz Raja [Tue, 29 Sep 2015 03:26:38 +0000 (20:26 -0700)]
BUG 4151 : Create a shared actor system

This patch adds an ActorSystemProvider interface in clustering commons
with a method to get a shard ActorSystem instance which uses the
clustered data store configuration as it contains more configuration
options than the rpc connector which pretty much uses stock configuration.
I added a config yang to define an actor-system-provider-service.

I added the ActorSystemProvider implementation and actor-system-provider-impl
config yang in the distributed datastore bundle. I tried it in
sal-clustering-commmons originally but ran into akka errors re: missing
config properties and it also couldn't find the
ReadyLocalTransactionSerializer class. So to avoid chasing down those
errors I put the implementation in sal-distributed-datastore. I think
this makes sense as it is the prime user of the actor system.

I added a dependency for the ActorSystemProvider service in both
datastores modules so the ActorSystem is now injected in and passed
to the DistributedDataStoreFactory. The dependency was also added to the
RPC mpdule.

Elements for the new actor system provider service and impl were added to
the 05-clustering.xml file along with the wiring changes for the data
stores and RPC modules.

Change-Id: I79c14f84c992a2d5ac9c1f1856efbaeba3cc2b77
Signed-off-by: Moiz Raja <>
7 years agoFix Eclipse compilation warnings. 30/28030/3
Gary Wu [Wed, 7 Oct 2015 20:54:41 +0000 (13:54 -0700)]
Fix Eclipse compilation warnings.

Fix compilation warnings in DistributedDataStoreTest
that DistributedDataStores were never closed.  Also fix
NPEs on closing DistributedDataStores when the
MXBeans are uninitialized.

Change-Id: I5dcaa389e1e69f934e9016933b00be3adaf4529f
Signed-off-by: Gary Wu <>
7 years agoRemove peer address cache in ShardInformation 60/27760/4
Tom Pantelis [Thu, 1 Oct 2015 13:27:40 +0000 (09:27 -0400)]
Remove peer address cache in ShardInformation

The ShardManager caches the peer addresses in the ShardInformation and
uses it mainly to suppress PeerUp, PeerDown and PeerAddressResolved
messages to the shard for peers that don't have replicas for the shard.

This is fine with static config but With the upcoming work to dynamically
add replicas, the shard will take ownership of persisting its peers so
the ShardManager will not know about dynamic peers.

I changed the semantics of the peer addresses to initial peer addresses.
They are now only used to pass to the Shard on creation. As a result,
PeerUp, PeerDown and PeerAddressResolved messages are now always sent to
the Shard for all peers. The Shard/RaftActor decide ll whether or not to
process the peer message. I changed RaftActorContextImpl#setPeerAddress
to ignore a peerId it doesn't know about instead of throwing an ex.

The other usages of the peerAddresses were to lookup the leader address.
This is now done dynamically via the ShardPeerAddressResolver.

Change-Id: Ida9738916a4a85d23198e7c095d5c73f17e2aa6c
Signed-off-by: Tom Pantelis <>
7 years agoPrepare for Karaf 3.0.4 upgrade 59/28059/2
Stephen Kitt [Thu, 8 Oct 2015 14:12:56 +0000 (16:12 +0200)]
Prepare for Karaf 3.0.4 upgrade

Pull in karaf.version from odlparent.
Drop import of org.apache.felix.service.command (apparently unused).

Change-Id: I6487ce1a52e6f51bbcdd4e332de18d4684782301
Signed-off-by: Stephen Kitt <>
7 years agoRefactor to fix unchecked cast warnings. 66/28166/3
Gary Wu [Thu, 8 Oct 2015 19:30:58 +0000 (12:30 -0700)]
Refactor to fix unchecked cast warnings.

Change-Id: I0fb6ce59707000f225ffa8d654685fbc89f8f2eb
Signed-off-by: Gary Wu <>
7 years agoFix Eclipse compilation warnings. 25/28025/2
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 <>
7 years agoFix Eclipse compilation warnings. 21/28021/2
Gary Wu [Wed, 7 Oct 2015 17:32:54 +0000 (10:32 -0700)]
Fix Eclipse compilation warnings.

Change-Id: I2caddfded34638002b2e31bf4e99d1770dd03a00
Signed-off-by: Gary Wu <>
7 years agoReproduce bug 4359 78/27678/4
Moiz Raja [Wed, 30 Sep 2015 16:49:22 +0000 (09:49 -0700)]
Reproduce bug 4359

Added a couple of unit tests which demonstrates the problem
described in bug 4359 where upon recovery a node which
is previously deleted reappears on reapplying the

For some reason the problem is reproducible only when the
car is added and deleted twice and not once. I haven't
investigated why yet.

Change-Id: I5f5a656ef6fdc017a3342c8b409576a8b121b7f1
Signed-off-by: Moiz Raja <>
7 years agoPartial revert of 67/28067/2
Tom Pantelis [Wed, 7 Oct 2015 01:32:08 +0000 (21:32 -0400)]
Partial revert of

Patch made improvements
that significantly sped up config system boot and helped the SFC project
but a couple other projects are seeing a timing issue where a
ModuleFactory isn't found and the config pusher fails. This is due to
the speed up and that YangModuleInfo's are now scraped from RESOLVED bundles
and thus are available quicker but ModuleFactory's are scaped from
ACTIVE bundles.

While the ModuleFactory issue is addressed, I'll partially revert the
prior changes to go back to scanning ACTIVE bundles for YangModuleInfo.

Change-Id: Icd3a51a049a940ad60a4bd0071e3c969167275d3
Signed-off-by: Tom Pantelis <>
7 years agoAdd ShardPeerAddressResolver 06/27606/4
Tom Pantelis [Mon, 28 Sep 2015 00:14:45 +0000 (20:14 -0400)]
Add ShardPeerAddressResolver

Added a ShardPeerAddressResolver implementation that is passed to
Shard RaftActors to resolve addresses for shard peer ids. I refactored
ShardManager a bit to move the memberNameToAddress map and related code
to the ShardPeerAddressResolver.

Change-Id: I5cbef5816d9bf13a339e43008144f44fd55fc606
Signed-off-by: Tom Pantelis <>
7 years agoModify ModuleInfoBundleTracker to track RESOLVED bundles (round 2) 74/27874/4
Tom Pantelis [Fri, 2 Oct 2015 21:14:46 +0000 (17:14 -0400)]
Modify ModuleInfoBundleTracker to track RESOLVED bundles (round 2)

My first patch didn't
do well with the feature tests due the BundleContext bust wait so it
was reverted.

I went back to my original solution to confgure the ModuleInfoBundleTracker
to track RESOLVED and ModuleFactoryBundleTracker to track ACTIVE.
Originally when I tried that I had some failure due to the ModuleFactory
not loaded yet but I don't remember exactly what. This patch seems to work
fine - I've restarted karaf several times and also ran the tsdr features tests
several times successfully. Originally I did the first patch in stable/lithium
so maybe something else has changed in master or the way I did it wasn't right.

Since the initial yang module info's are now processed synchronously when the
BundleTracker is opened, I modified the ModuleInfoBundleTracker to
ensure it doesn't propagate runtime ex's. This would disrupt the
BundleTracker and the ConfigManagerActivator - if one module had an
issue the config manager wouldn't start.

For every YangModuleInfo scraped, it registers it with the
ModuleInfoRegistry. The backing impl is RefreshingSCPModuleInfoRegistry
which causes a new SchemaContext to be created from the current yang
models (via updateService). This isn't efficient - on startup, we'll get all
YangModuleInfo's in quick succession so, optimially, it should build the
SchemaContext once after open is complete. This is what the
GlobalBundleScanningSchemaServiceImpl does.

To accomplish this, I removed the call to updateService from
RefreshingSCPModuleInfoRegistry#registerModuleInfo - it is now
specifically called by ModuleInfoBundleTracker. This means the
ModuleInfoBundleTracker now references RefreshingSCPModuleInfoRegistry
instead of the ModuleInfoRegistry interface which makes it less clean.
Any other way would require changes to the ModuleInfoRegistry interface,
which I didn't want to do, or extending the interface which I didn't think that
was worth the effort. The RefreshingSCPModuleInfoRegistry is only used by

Change-Id: I20213ce8bd1dfc5109f3ef223cec8048bec92e12
Signed-off-by: Tom Pantelis <>
7 years agoFix DistributedEntityOwnershipIntegrationTest failure 24/28024/1
Tom Pantelis [Tue, 6 Oct 2015 13:43:55 +0000 (09:43 -0400)]
Fix DistributedEntityOwnershipIntegrationTest failure

Fixed intermittent failure due the follower2MockListener getting
an ownershipChanged with "false, false, true" if if the original
ownership change with "member-2 is replicated to follower2 after
the listener is registered. The test ran 100 times successfully.

Change-Id: I1f0333e3bc69cc28521bc7388d64b56d18b55544
Signed-off-by: Tom Pantelis <>
(cherry picked from commit de587f935016a300cdbeb85926c2eb677f383fc2)

7 years agoBug 4105: Fix intermittent failure in DistributedEntityOwnershipIntegrationTest 12/28012/1
Tom Pantelis [Sat, 12 Sep 2015 00:32:55 +0000 (20:32 -0400)]
Bug 4105: Fix intermittent failure in DistributedEntityOwnershipIntegrationTest

I saw a test filure on jenkins. After follower2 is stopped there will be
2 onOwnershipChange calls so the test needs to expect both.

Change-Id: I74dc583c2d40e966197315640eb189702fbabd64
Signed-off-by: Tom Pantelis <>
(cherry picked from commit a3a0417b0ee75f040fb4436602ed7ecf5585d44f)

7 years agoFix NPE in AbstractFeatureWrapper 71/27971/1
Tom Pantelis [Mon, 5 Oct 2015 16:10:23 +0000 (12:10 -0400)]
Fix NPE in AbstractFeatureWrapper

Added check in ChildAwareFeatureWrapper#getChildFeatures to verify the
feature exists in the FeaturesService to avoid NPE. This is a similar
workaround as was done in FeatureConfigPusher for a bug in karaf where
the FeaturesService may mysteriously return null for an existing feature.

Change-Id: I006cd012e919ac206d70bb4ee5754c72f0f01b32
Signed-off-by: Tom Pantelis <>
(cherry picked from commit e6076f69f57fe5918c66637414175c6229635841)

7 years agoInitial code for RaftActorServerConfigurationSupport 57/27557/7
Tom Pantelis [Sun, 27 Sep 2015 16:32:12 +0000 (12:32 -0400)]
Initial code for RaftActorServerConfigurationSupport

Added a RaftActorServerConfigurationSupport and unit test class with
mostly initial skeleton code. In RaftActorServerConfigurationSupport,
I implemented the basic checks for leader avaialbility with
corresponding unit tests. If not the leader and there is a leader, it
forwards to the remote leader. If no leader, it returns NO_LEADER

Also in RaftActorServerConfigurationSupport, I added code for the first
steps: add the serverId/address into the RaftActorContext peer map and
add a FollowerLogInformation entry in the AbstractLeader. I added an
initialized field wih getters/setters to FollowerLogInformation. The
entry is added with initialized set to false. I also changed the
followerToLogMap in AbstractLeader to mmutable.

I also modified FollowerLogInformationImpl so it returns false for
isFollowerActive and isOkToReplicate if initialized is false. The idea
is to prevent the leader from sending log entries or a snapshot via
the heartbeat or replication. The leader will send an empty
heartbeat which should be fine. The RaftActorServerConfigurationSupport
will initiate the install snapshot directly.

I added TODO comments in RaftActorServerConfigurationSupport and the
unit test class which outline the remaining work.

I also added the ServerConfigurationPayload class to be used for the log

Change-Id: Ic11ddc99a57edb7ef70c2d4f5fa7906d6a95b35e
Signed-off-by: Tom Pantelis <>
7 years agoReturn throwable in NeverReconnectStrategy 15/27915/2
Claudio D. Gasparini [Mon, 5 Oct 2015 13:36:00 +0000 (15:36 +0200)]
Return throwable in NeverReconnectStrategy

NeverReconnectStrategy returns empty throwable instead of
passed throwabled with the failed previous
connection reasons.

Change-Id: I5695af09379f06a66c37ccf27293ff85657afeaa
Signed-off-by: Claudio D. Gasparini <>
7 years agoAdd PeerAddressResolver for raft actor 88/27588/3
Tom Pantelis [Sun, 27 Sep 2015 21:09:14 +0000 (17:09 -0400)]
Add PeerAddressResolver for raft actor

For upcoming work to dynamically add peers, the peer address may not be
known and, if the cluster MemberUp has already occurred, no
UpdatePeerAddress message will be sent. We need to be bale to
dynamically resolve peer addresses so I added a new PeerAddressResolver
interface whose instance is obtained from the ConfigParams and used by
the RaftActorContextImpl..

Change-Id: I38807b4b6a59a7cb1359d85a9550cd6e98cb13a4
Signed-off-by: Tom Pantelis <>
7 years agoBUG-4367: Use SchemaSourceProvider to retrieve sources for yang 54/27654/8
Maros Marsalek [Wed, 30 Sep 2015 13:28:23 +0000 (15:28 +0200)]
BUG-4367: Use SchemaSourceProvider to retrieve sources for yang

- Not using schema context to provide the sources anymore.
- Transform the modules into capabilities in YangStoreService instead
  of requiring the listeners to do so

Change-Id: I39a144c7472f7944cca01eeff273058aa2fe7d7a
Signed-off-by: Maros Marsalek <>
7 years agoFixed DatastoreContext not found. 48/27848/1
Tony Tkacik [Fri, 2 Oct 2015 21:47:34 +0000 (23:47 +0200)]
Fixed DatastoreContext not found.

Change-Id: Iec5807fe0e9fb270a87095fe036a2a285d564642
Signed-off-by: Tony Tkacik <>
7 years agoSpeed up GlobalBundleScanningSchemaServiceImpl close 81/27781/1
Tom Pantelis [Thu, 1 Oct 2015 21:43:24 +0000 (17:43 -0400)]
Speed up GlobalBundleScanningSchemaServiceImpl close

On close, the GlobalBundleScanningSchemaServiceImpl closes the
BundleTracker which untracks all the bundles and notifies the listener
of removed bundles. This results in a call to tryToUpdateSchemaContext
which causes the remaining yang files to be re-parsed to build a new
SchemaContext. To prevent this extra processing on shutdown, I added
a "stopping" flag to elide tryToUpdateSchemaContext the same we do
with the "starting" flag.

Signed-off-by: Tom Pantelis <>
Change-Id: I9f7c05277df9bf1ffaec1c699453020312aab203

7 years agoRevert ModuleInfoBundleTracker patches 19/27719/1
Tom Pantelis [Thu, 1 Oct 2015 06:54:45 +0000 (02:54 -0400)]
Revert ModuleInfoBundleTracker patches

Reverted patch as it
causes some feature tests to take a long time due to the busy wait.
Also it appears the ModuleFactory OSGi services are needed as the
BlankTransactionServiceTracker listens for them (I'm not clear what this
does). I'll try to figure out another way to accomplish the intent
of the reverted patch.

Change-Id: Ifc91dada86ac7feee1a0a9390a55e68d7f113153
Signed-off-by: Tom Pantelis <>
8 years agoFix ModuleFactoryBundleTracker shutdown hang 26/27626/2
Tom Pantelis [Mon, 28 Sep 2015 07:49:46 +0000 (03:49 -0400)]
Fix ModuleFactoryBundleTracker shutdown hang

If karaf is shutdown quickly after starting, the
ModuleFactoryBundleTracker#getModuleFactoryEntries method may
hang for a while trying to obtain BundleContexts. This has
been seen on jenkins with some feature tests. The ModuleFactoryBundleTracker
does a 1 min busy wait trying to obtain the BundleContext. This was done b/c the
tracker listens for RESOLVED bundles and the BundleContext isn't available
until after the bundle is started. So the busy wait was intended for startup
when bundles transition from RESOLVED -> STARTING. Once obtained, the
BundleContext is cached.

This works fine normally when all bundles start up. However, if stopped
quickly, some bundles may not have started, ie they remain in the
RESOLVED state with null BundleContext, so on shutdown when someone
calls getModuleFactoryEntries, it will busy wait and eventually timeout which
can take minutes.

What we need to do is remove the ModuleFactory entries when bundles are
stopped. The ModuleFactoryBundleTracker#removedBundle method does this
but it wasn't called on shutdown b/c it tracks RESOLVED, STARTING, ACTIVE
and STOPPING states. The solution is to remove STOPPING from the tracked states
so removedBundle will get called on transition ACTIVE -> STOPPING.
However, when transition STOPPING -> RESOLVED occurs the bundle will get
added back to the tracker and we don't want to re-add the ModuleFactory
entries. To prevent this it checks for BundleEvent type STOPPED.

Change-Id: I82889a682809d4217dc4253eb60c922209ad7242
Signed-off-by: Tom Pantelis <>
7 years agoModify ModuleInfoBundleTracker to track RESOLVED bundles 38/27138/5
Tom Pantelis [Sun, 13 Sep 2015 03:55:29 +0000 (23:55 -0400)]
Modify ModuleInfoBundleTracker to track RESOLVED bundles

I've seen issues where a yang-generated class that exists in another
bundle isn't found on startup when a module config is pushed.
Specifically I've seen it when registering RPC implementations. The
BindingDOMRpcProviderServiceAdapter uses the
BindingToNormalizedNodeCodec get the RPC schema and it can fail to
get the RPC input class.

The BindingToNormalizedNodeCodec calls the BindingRuntimeContext to
obtain schema classes which in turn uses the ClassLoadingStrategy OSGi
service to load classes. The backing implementation of
ClassLoadingStrategy is the ModuleInfoBackedContext supplied by the
config manager bundle. This is backed by the ModuleInfoBundleTracker
which scrapes yang files from bundles. However it listens for ACTIVE
bundles. A while ago the GlobalBundleScanningSchemaServiceImpl was
(correctly) changed to listen for RESOLVED bundles which fixed startup
timing issues. It makes sense to also change the
ModuleInfoBundleTracker to listen for RESOLVED bundles so all existing
yang models are loaded on startup prior to use.

The ModuleFactoryBundleTracker piggy-backs the ModuleInfoBundleTracker
to load ModuleFactory instances needed by the config system. It
registers ModuleFactory instances as OSGi services, which are consumed by the
BundleContextBackedModuleFactoriesResolver, however this fails for a
RESOLVED bundle b/c it doesn't have a BundleContext yet (apparently this
is set when the bundle is started/activated). To fix this, I refactored
BundleContextBackedModuleFactoriesResolver and
ModuleFactoryBundleTracker a bit. The ModuleFactoryBundleTracker no
longer registers ModuleFactory instances as OSGi services. Instead it
maintains a list of ModuleFactory/Bundle entries which the
BundleContextBackedModuleFactoriesResolver directly uses to build the
resulting factories map for the ConfigRegistry. A bundle may still not
have a BundleContext at that point so, to safe guard against that, I
added a busy wait for BundleContext.

Change-Id: Ia7bd39f635e3473e6e84011163a0768865c9a931
Signed-off-by: Tom Pantelis <>
7 years agoAdd election info to Snapshot 95/27495/6
Tom Pantelis [Sat, 26 Sep 2015 15:13:06 +0000 (11:13 -0400)]
Add election info to Snapshot

When a snaphot is saved we delete all prior applied data entries from
the journal. However this also has the side-effect of also deleting prior
UpdateElectionTerm entries so, on restart, we lose the election term
info. We need to persist the election term wih the Snapshot.

Change-Id: I0ed140de1868cc03a28cfbc1d6eb909fe4dbc252
Signed-off-by: Tom Pantelis <>
7 years agoAdd Raft AddServer message and reply 14/27514/4
Tom Pantelis [Sun, 27 Sep 2015 01:35:54 +0000 (21:35 -0400)]
Add Raft AddServer message and reply

Change-Id: I59499ab0f0b7c202a309af0412a0c0ae38494d8b
Signed-off-by: Tom Pantelis <>
8 years agoAdd getOwnershipState method to EntityOwnershipService 51/27551/2
Tom Pantelis [Fri, 25 Sep 2015 02:05:24 +0000 (22:05 -0400)]
Add getOwnershipState method to EntityOwnershipService

Added a new method to gte the current ownership state for an entity.
This was requested for OF clustering.

The DistributedEntityOwnershipService obtains the EntityOwnershipShard's
DataTree via a new message GetShardDataTree and reads the entity's owner
leaf in order to build the resulting EntityOwnershipState. The DataTree
is obtained once and cached.

Change-Id: Ib4aa2f4e5370d8d5183908b836417936a51458f7
Signed-off-by: Tom Pantelis <>
(cherry picked from commit dd6976c24f12c7cef7bed8fa6bc645dc699dda4f)

7 years agoYangInstanceIdentifier::toInstance() -> build() 31/27531/2
Stephen Kitt [Mon, 28 Sep 2015 12:25:07 +0000 (14:25 +0200)]
YangInstanceIdentifier::toInstance() -> build()

::toInstance() is gone, which breaks the build.

Change-Id: I51662dd351bf5b02441f58291e85e0e1729d7785
Signed-off-by: Stephen Kitt <>
7 years agoAlways persist and recover election term info 91/27491/9
Tom Pantelis [Sat, 26 Sep 2015 11:27:52 +0000 (07:27 -0400)]
Always persist and recover election term info

With data persistence disabled, this also disabled persistence/recovery
of election term info. This was an oversight - we need to persist and
recover election term info regardless.

Change-Id: I48d33ca5d3b7d95e2aeb8ed7f9c8d5f1aa401ece
Signed-off-by: Tom Pantelis <>
8 years agoRevert "Remove obsolete artifacts from commons.opendaylight" 67/27467/2
Venkatrangan Govindarajan [Fri, 25 Sep 2015 20:29:04 +0000 (20:29 +0000)]
Revert "Remove obsolete artifacts from commons.opendaylight"

This reverts commit 0ff87783a0fb2ab7bd60daf4a399bb8933af244a.

Change-Id: Id9151032657453c816b3dab63bb8982e4b2e8030
Signed-off-by: gvrangan <>
8 years agoRemoved properties from parent pom. 70/26970/4
Tony Tkacik [Tue, 15 Sep 2015 09:45:29 +0000 (11:45 +0200)]
Removed properties from parent pom.

Change-Id: I0b5836369b8be33c88abd491a644364d9c92be55
Signed-off-by: Tony Tkacik <>
8 years agoRemoved unnecessary commons.parent. 69/26969/4
Tony Tkacik [Tue, 15 Sep 2015 09:18:56 +0000 (11:18 +0200)]
Removed unnecessary commons.parent.

Change-Id: Idc3dcdf859bd11edb53a5faa641206a8d9fac1c0
Signed-off-by: Tony Tkacik <>
8 years agoBug 4327 - Fixed DataTreeChangeListener registration in PingPongDataBroker 96/27296/3
Michal Polkorab [Tue, 22 Sep 2015 14:34:06 +0000 (16:34 +0200)]
Bug 4327 - Fixed DataTreeChangeListener registration in PingPongDataBroker

 - delegate broker was incorrectly queried for DOMDataTreeChangeService
 - it must ask for supported extensions instead of instanceof
 - this is lithium branch fix,
   beryllium change:

Change-Id: Ie1757c762018e7188d76a7728f2f8ea52293d73f
Signed-off-by: Michal Polkorab <>
8 years agoRemove expensive uses of Calendar.getInstance() 81/25981/3
Stephen Kitt [Tue, 25 Aug 2015 16:07:50 +0000 (18:07 +0200)]
Remove expensive uses of Calendar.getInstance()

nanoTime() is used instead of currentTimeMillis() to avoid issues with
leap seconds.

Change-Id: Idbfcd994424c91a384c47fe0ad12bc6a7ea33972
Signed-off-by: Stephen Kitt <>
8 years agoRemove obsolete artifacts from commons.opendaylight 89/27189/2
Stephen Kitt [Fri, 18 Sep 2015 14:39:47 +0000 (16:39 +0200)]
Remove obsolete artifacts from commons.opendaylight

commons.opendaylight includes a few obsolete artifacts in its
dependency management: features-base, features-adsal, and
features-nsf. This patch removes them.

Change-Id: Ief98dce25d66439fea23e231470583b971f27756
Signed-off-by: Stephen Kitt <>
8 years agoBug 4202: Migrate also toaster to use mdsal project 69/27369/1
Vratko Polak [Wed, 23 Sep 2015 17:33:28 +0000 (19:33 +0200)]
Bug 4202: Migrate also toaster to use mdsal project

This only changes dependency feature omitted from Change 26079,
perhaps Java edits are also needed to keep toaster working.

Also, git has somehow enforced change of line endings everywhere.

Change-Id: I810fba0ae7a55e123dd6f78ba23a7e77a7118b57
Signed-off-by: Vratko Polak <>
8 years agoBug 4202 - Migrate archetypes to use MD-SAL Project 50/27250/1
adetalhouet [Tue, 22 Sep 2015 01:41:31 +0000 (21:41 -0400)]
Bug 4202 - Migrate archetypes to use MD-SAL Project

Change-Id: Ic5fa0913c3332a20cbe97bc4c6ea64edc7549a1d
Signed-off-by: adetalhouet <>
8 years agoBUG-865: remove YangInstanceIdentifier.toInstance() 63/27163/1
Robert Varga [Fri, 18 Sep 2015 13:59:48 +0000 (15:59 +0200)]
BUG-865: remove YangInstanceIdentifier.toInstance()

This removes the use of a deprecated method.

Change-Id: I46f9a3e3a8c9741fa603aa04e2673a13c6fb5c92
Signed-off-by: Robert Varga <>
8 years agoAdd test scope to karaf-empty artifact in akka feature test pom 49/27149/3
Tomas Cere [Fri, 18 Sep 2015 09:11:09 +0000 (11:11 +0200)]
Add test scope to karaf-empty artifact in akka feature test pom

Change-Id: Ida85537eac861814bf4d137718d4a168036dcc1f
Signed-off-by: Tomas Cere <>
8 years agoAdd "documentation" flags for WriteTransaction 98/25398/6
Stephen Kitt [Tue, 18 Aug 2015 08:37:53 +0000 (10:37 +0200)]
Add "documentation" flags for WriteTransaction

In WriteTransaction, the createMissingParents argument to put() and
merge() is a boolean, which results in code like

    ...put(store, path, data, true);

which isn't immediately readable to neophytes. This patch adds two
client code can be written as

    ...put(store, path, data, CREATE_MISSING_PARENTS);

instead (but without introducing an enum).

The FAIL_ON_MISSING_PARENTS constant also documents the behaviour in
the other path; I named it based on the pre-condition check in
AbstractWriteTransaction (which results in an IllegalArgumentException
if a parent is missing).

Change-Id: Ic95b5e4f3d8574f0014cdf6a00a77013b94b00cc
Signed-off-by: Stephen Kitt <>
8 years agoYang code generator cleanup 70/25570/5
Stephen Kitt [Fri, 21 Aug 2015 11:26:10 +0000 (13:26 +0200)]
Yang code generator cleanup

Two axes:
* make the generated code slightly better
* make the generator code slightly better

Fixes in generator code:
* fields which can be local variables
* map overwrite detection using put()'s return value
* logging with exceptions
* using File's parent/child handling instead of concatenating strings
* if (condition) { return true; } else { return false; }
* if (... == false) -> if (!...)
* interface method declarations are public by default
* Collections.singletonList() instead of Arrays.asList() for
  single-item collections
* StringBuilder instead of StringBuffer
* String concatenation instead of straight-forward StringBuilder
  (i.e. non-conditional append() calls)
* typos: hierarchchical -> hierarchical, intends -> indents
* drop unused parameter from
* when processing only values in a map, use .values() rather than
* split StringBuilder::append(a + b) into two ::append() calls
* clean up the method parameter construction in MethodSerializer (to
  avoid deleting the ", " at the end)

Fixes in generated code:
* use { } as requested the Checkstyle rules
* handle empty service interface sets explicitly

It would be nice to use the <> operator without specifying the type
where possible, but the Eclipse AST parser used in the unit tests is
too old for this (so the generated code is correct and works
elsewhere, but fails the unit tests).

Change-Id: I725ce8d98f9ee389d394772733663ecacaccf8fa
Signed-off-by: Stephen Kitt <>
8 years agoBug 4317: Added the version of yang-maven-plugin. 13/27013/2
Hideyuki Tai [Tue, 15 Sep 2015 18:45:35 +0000 (11:45 -0700)]
Bug 4317: Added the version of yang-maven-plugin.

In the pom.xml of config-parent, the version of yang-maven-plugin was
missing. In the result, Maven downloaded the latest release version
(0.7.1-Lithium-SR1) of yang-maven-plugin, although the latest SNAPSHOT
version (0.8.0-SNAPSHOT) was expected here.
This patch added the version of yang-maven-plugin, and specified the
latest SNAPSHOT version for it.

Change-Id: I9a30aa4fc3c80d81c9342664135be484a219493d
Signed-off-by: Hideyuki Tai <>
8 years agoSplit {copyright} into {copyright-year} and {copyright} 41/26941/5
Flavio Fernandes [Mon, 14 Sep 2015 21:53:17 +0000 (17:53 -0400)]
Split {copyright} into {copyright-year} and {copyright}

With this change, archetype will explicitly use year for copyright to
ensure check style does not fail.

Patch set 3: replace (c) with © symbol
Patch set 4: add default values for copyright-year and version

Change-Id: I5b4bdfc273d578afafd7555a96e5a1fe732677bb
Signed-off-by: Flavio Fernandes <>
8 years agoBUG-2399: take into account new ModificationTypes 10/27110/5
Robert Varga [Thu, 17 Sep 2015 03:42:46 +0000 (05:42 +0200)]
BUG-2399: take into account new ModificationTypes

When structural containers come and go we can see APPEARED/DISAPPEARED

Patch set 5: fix build

Change-Id: Ic3da43398163a01e21adc013586949026075e3c0
Signed-off-by: Robert Varga <>
8 years agoFixed properties not expanded in features.xml 35/27135/3
Tony Tkacik [Thu, 17 Sep 2015 18:40:58 +0000 (20:40 +0200)]
Fixed properties not expanded in features.xml

Change-Id: I8bf4c30be1e6c427cfd9aff8afe5f465a666dc22
Signed-off-by: Tony Tkacik <>
8 years agoBug-4214 - Add support for configurable snapshot chunk size. 13/26413/3
Shaleen Saxena [Mon, 31 Aug 2015 02:25:19 +0000 (22:25 -0400)]
Bug-4214 - Add support for configurable snapshot chunk size.

Added a new variable in the distributed-datastore-provider.yang. This
will be used to configure the snapshot chunk size. Added various
setters/getters to the DatastoreContext. The support for this variable
was added to JMX as well, so that the value can be seen via JConsole.
Moreover, added tests in DatastoreContextTest.

Also fixed a recurring typo in sal-akka-raft. Snapshot was spelled as
snaphot (missing s in shot).

This code was unit tested with different entries in datastore.cfg. Also
tested the case where no special value was provided in datastore.cfg,
and the default value was shown in jconsole.

Change-Id: Ie754075cc25f9eadf01cc65aee726735144c1794
Signed-off-by: Shaleen Saxena <>
(cherry picked from commit f3c38988cc31e07bab473cace946aebf5152c61f)

8 years agoBug 4202: Migration to use mdsal project 79/26079/14
Tony Tkacik [Mon, 7 Sep 2015 10:30:22 +0000 (12:30 +0200)]
Bug 4202: Migration to use mdsal project

Migrated controller to use MD-SAL provided
Java Binding instead of YANG-Tools provided JAVA

This migration deals only with compile time and
in runtime.

Updated following features
  - features-config
  - features-config-netty
  - features-config-persister
  - features-mdsal
  - features-extras
  - features-protocol-framework

to use
  - Java Binding hosted in MD-SAL project
  - features-parent from odlparent

Change-Id: Iba40d74d118e212c9a57fa28711bbbe339fe1bbd
Signed-off-by: Tony Tkacik <>
8 years agoBUG-865: remove the use of ModificationType.MERGE 07/27107/2
Robert Varga [Thu, 17 Sep 2015 03:34:55 +0000 (05:34 +0200)]
BUG-865: remove the use of ModificationType.MERGE

This event is deprecated and is not produced, remove references to it.

Change-Id: I181168a923929a53806164b5ffd530db2c18c299
Signed-off-by: Robert Varga <>
8 years agoBUG 2298: Ask Git to normalize line endings 66/12466/4
Jozef Behran [Mon, 3 Nov 2014 15:08:07 +0000 (16:08 +0100)]
BUG 2298: Ask Git to normalize line endings

Added file attributes configuration file to make GIT aware
of which files are textual and which are binary and allow
it to normalize the line endings in the textual files
without the developers needing to do any special setup on
their Git installation.

Change-Id: I2d4e9fb4eeeab2893209741781e13c7cdfe1b01d
Signed-off-by: Jozef Behran <>
8 years agoRemove sonar.branch property 77/26277/3
Thanh Ha [Tue, 1 Sep 2015 16:48:23 +0000 (12:48 -0400)]
Remove sonar.branch property

This property isn't being used and actually causes build failure in
Sonar 5.x.

Change-Id: Ie3e25b0ed17d699305bc860fdd8a7f12c03d50d8
Signed-off-by: Thanh Ha <>
8 years agoUpgrade archetype-packaging plugin to 2.4 56/26956/2
Stephen Kitt [Tue, 15 Sep 2015 07:01:18 +0000 (09:01 +0200)]
Upgrade archetype-packaging plugin to 2.4

Change-Id: I97ffeb769cbba79389859405e8898c9dd88a1527
Signed-off-by: Stephen Kitt <>
8 years agoFuture-proof the dummy JAR construction 59/26859/3
Stephen Kitt [Fri, 11 Sep 2015 15:48:08 +0000 (17:48 +0200)]
Future-proof the dummy JAR construction

The shade plugin needs a JAR, and the contents of the project
contribute to a standard JAR rather than a test JAR. Add a JAR goal to
the maven-jar-plugin so the shade plugin can find its artifact
(otherwise the build breaks with forthcoming version upgrades).

Change-Id: If4853eb81208134d536040de8e6e934b38ef762f
Signed-off-by: Stephen Kitt <>
8 years agoBUG-865: remove use of DefaultDataTreeCandidate 51/27051/1
Robert Varga [Wed, 16 Sep 2015 12:52:03 +0000 (14:52 +0200)]
BUG-865: remove use of DefaultDataTreeCandidate

The functionality is available via utility method in DataTreeCandidates,
so use that instead.

Change-Id: I44bab58e39ad226c198f3ada1140152be1e4b4aa
Signed-off-by: Robert Varga <>
8 years agoBUG-865; do not use DurationStatsTracker 46/27046/1
Robert Varga [Wed, 16 Sep 2015 12:40:22 +0000 (14:40 +0200)]
BUG-865; do not use DurationStatsTracker

The class has been deprecated, use the alternative.

Change-Id: I29bd049450c0d5e6b3c2a8801538213c58f37c62
Signed-off-by: Robert Varga <>
8 years agoBug 4105: Remove EntityOwnershipCandidate 50/26950/2
Tom Pantelis [Fri, 11 Sep 2015 20:13:24 +0000 (16:13 -0400)]
Bug 4105: Remove EntityOwnershipCandidate

It was decided that we really don't need to pass an
EntityOwnershipCandidate listener when registering a candidate. Since
apps would most likely create a singleton EntityOwnershipCandidate for
all registerCandidate calls, they might as well register the singleton
listener once via registerListener. This simplifies the interface and
also simplifies OF clustering b/c they need an EntityOwnershipListener
anyway for device node cleanup.

Change-Id: I9fb7d68c1ffbf932c9d0e18efef604c1b05fdf96
Signed-off-by: Tom Pantelis <>
(cherry picked from commit 6b0f9975b09044b7c3c8877ae2d2d06f0a29894a)

8 years agoBug 4094: Fix DCNs on initial registration 49/26949/2
Tom Pantelis [Wed, 19 Aug 2015 02:07:52 +0000 (22:07 -0400)]
Bug 4094: Fix DCNs on initial registration

For DataChangeListener, I modified the code to use a
ResolveDataChangeEventsTask to resolve the initial changed event. It
was noted in Bug 4094 to read the registration path up to the first
wildcard. However this did not work. ResolveDataChangeEventsTask
expects the candidate root path and "after" data to be the tree root
to match the structure of the ListenerTree. When a transaction is
committed, the resulting DataTreeCandidate always points to the root.
So I had to read the root path in ShardDataTree. I could've optimized
for non-wildcarded path registrations but I think wildcarded path
registrations will be the norm anyway.

I added a new method, notifyOfInitialData, in ShardDataTree. Because I
had to create a new ListenerTree with the single registration, I
needed to know the path and scope of the original registration so I
changed several method signatures from the general ListenerRegistration
to the specific DataChangeListenerRegistration which provides access to
the path and scope. However we also have an actor class by that name so
to avoid confusion I renamed the actor class to

DataTreeChangeListener was implemented similarly.

Change-Id: I0ab88d0991761c058b6af81d6d26402ff370b78e
Signed-off-by: Tom Pantelis <>
(cherry picked from commit 0a7e13a8c7fed697800c792698cfef32b2ef0d11)

8 years agoRemove sal-rest-connector artifacts 18/26818/4
Thanh Ha [Fri, 11 Sep 2015 05:41:08 +0000 (01:41 -0400)]
Remove sal-rest-connector artifacts

Bug: 4292
Change-Id: I1601e55765c0a5664c1b0cb3e0ef261a0d522f59
Signed-off-by: Thanh Ha <>
8 years agoFixed relativePaths. 97/26597/5
Tony Tkacik [Mon, 7 Sep 2015 10:30:22 +0000 (12:30 +0200)]
Fixed relativePaths.

Change-Id: I12ba628df83fc0fb7d472039bc3c3002e9708f87
Signed-off-by: Tony Tkacik <>
8 years agoBug 4105: Add hasOwner param to EntityOwnershipListener#ownershipChanged 98/26898/2
Tom Pantelis [Fri, 11 Sep 2015 04:13:51 +0000 (00:13 -0400)]
Bug 4105: Add hasOwner param to EntityOwnershipListener#ownershipChanged

OF clustering needs to know when the last candidate is removed for an
entity so it can clean up inventory. We decided to add a new param,
hasOwner, passed to EntityOwnershipListener#ownershipChanged to indicate if
there is at least one remaining candidate and current owner when a
controller node loses ownership. So if
wasOwner=true && isOwner=false && hasOwner=false, the OF code can
remove the device node from inventory.

To simplify the EntityOwnershipListener#ownershipChanged interface and
to allow for possible future parameters w/o breaking the interface, the
parameters are now encapsulated in an EntityOwnershipChanged DTO. There
already was the same EntityOwnershipChanged class in
sal-distributed-datastore - this class was removed.

Change-Id: I07375f154ac55d34062380ad6d0b30d970bd28e7
Signed-off-by: Tom Pantelis <>
(cherry picked from commit 061d4edabfb421ec79d1dc7afe4163aa52828450)

8 years agoDo not override dependency plugin version 40/26240/3
Robert Varga [Mon, 31 Aug 2015 15:16:50 +0000 (17:16 +0200)]
Do not override dependency plugin version

Version 2.6 is ancient and does not work at least here. Remove the
explicit override and inherit the version from odlparent.

Change-Id: Iabd3a603ae9d2faf0fe2a4c7d8ce43b0cc9428ae
Signed-off-by: Robert Varga <>
8 years agoBUG 4291 : odl-clustering-test-app feature must depend on odl-mdsal-broker 31/26831/1
Moiz Raja [Fri, 11 Sep 2015 01:33:38 +0000 (18:33 -0700)]
BUG 4291 : odl-clustering-test-app feature must depend on odl-mdsal-broker

When odl-clustering-test-app feature depends on odl-mdsal-broker-local the
distributed-entity-ownership service does not get resolved.

Change-Id: I0240ea6b210ec5966f680f786a706365b4f6502c
Signed-off-by: Moiz Raja <>
(cherry picked from commit b079e20e9a9f3ac133f4b5871d6c9158d016ab6a)

8 years agoBug 4105: Fixed feature test failure due to missing dependency. 22/26822/1
Shigeru Yasuda [Fri, 11 Sep 2015 08:06:51 +0000 (17:06 +0900)]
Bug 4105: Fixed feature test failure due to missing dependency.

features-mdsal was missing dependency on sal-clustering-config
(type=xml, classifier=entityownershipconfig).

Change-Id: Ifa1380a1071ae3c7b730e79c4e1c8ff09dbe15e2
Signed-off-by: Shigeru Yasuda <>
8 years agoBug 4105: Remove candidates on PeerDown 08/26808/1
Tom Pantelis [Tue, 18 Aug 2015 06:59:47 +0000 (02:59 -0400)]
Bug 4105: Remove candidates on PeerDown

Currently on PeerDown, the EntityOwnershipShard selects a new owner for
the entities owned by the down node and leaves the down node as a
candidate. If the down node is the only candidate, the owner is cleared.
On PeerUp, it selects a new owner for those entities whose owner is clear.
This was done to handle network partition so a node's candidates remain
registered and are re-assigned when the partition is healed.

Howver this has potential issues when a node is actually
stopped/restarted. It's possible, on restart, that the node doesn't
register a candidate for an entity that it had previously registered for.
So it may get ownership of an entity for which it has no registered

To alleviate this, I changed it to remove all the down node's candidates
on PeerDown. If the node was stopped/restarted, then it will
re-register candidates based on local client requests. This case will be
the norm. To handle network partition, when healed, the follower node
will get the replicated commits for its candidate removals from the
leader. So on Candidate removed, it re-adds its removed candidate if it
has a registered EntityOwnershipCandidate.

I realized that one can register a DOMDataTreeChangeListener for a leaf
node. So I simplified EntityOwnerChangeListener to listen for the owner
leaf instead of the entity path. This avoids the extra notifications
when candidayes are added/removed. I actually did this originally b/c I
thought there was a bug when listening at the entity level which turned
out there wasn't but I left it in as an improvement.

I also added the shard's logId to the listener and support classes for
better debugging of unit tests.

Change-Id: I75d2567ce54b9129eee052ba521c8a71777289b6
Signed-off-by: Tom Pantelis <>
8 years agoBug 4105: Implement EntityOwnershipListener registration/notification 07/26807/1
Tom Pantelis [Mon, 17 Aug 2015 09:57:53 +0000 (05:57 -0400)]
Bug 4105: Implement EntityOwnershipListener registration/notification

Change-Id: I49ee7f4b5f48ddde4779d37ba34c88dd776dd47b
Signed-off-by: Tom Pantelis <>
8 years agoBug 4105: Pass ModuleShardConfiguration with CreateShard 06/26806/1
Tom Pantelis [Mon, 17 Aug 2015 00:46:24 +0000 (20:46 -0400)]
Bug 4105: Pass ModuleShardConfiguration with CreateShard

The DistributedEntityOwnershipService first adds the
ModuleShardConfiguration to the Configuration prior to sending the
CreateShard message. However if the ModuleShardConfiguration gets
added before the ShardManager actor is created, the entity-ownership
shard is created via ShardManager.createLocalShards. This results in
the entity-ownership instantiated as Shard instead of
EntityOwnershipShard. I've seen this happen in unit tests - it's not
likely to occur in the production system b/c we wait until the
data store is ready prior to creating the
DistributedEntityOwnershipService. But we should prevent it so I
changed the DistributedEntityOwnershipService to pass the
ModuleShardConfiguration with the CreateShard message. The
ShardManager now adds the ModuleShardConfiguration to the

Change-Id: I9f64a27cdd8c24d31e7eb1389210b57ac7a1f604
Signed-off-by: Tom Pantelis <>
8 years agoBug 4105: Add entity ownership integration test 05/26805/1
Tom Pantelis [Sun, 16 Aug 2015 23:02:41 +0000 (19:02 -0400)]
Bug 4105: Add entity ownership integration test

Change-Id: I9578a37f86db44a90aa208d6d89374ba4d3cfb89
Signed-off-by: Tom Pantelis <>
8 years agoBug 4105: Change ownership on member down/up 04/26804/1
Tom Pantelis [Sat, 15 Aug 2015 21:23:50 +0000 (17:23 -0400)]
Bug 4105: Change ownership on member down/up

Added 2 new messages, PeerUp and PeerDown, that the ShardManager sends
in response to cluster member events.

For PeerDown, the EntityOwnershipShard finds the entities owned by the
down member and selects a new owner based on the remaining candidates.
If there's no other candidates, the owner is cleared (set to "") so new
candidates can become owner. The down members are also tracked via a
downPeerMemberNames set.

For PeerUp, if the up member is in the downPeerMemberNames, the
EntityOwnershipShard finds entities that previously had their owner
cleared and attempts to select a new owner. This handles the case where
a previously down member was the only candidate for an entity so, when
that member comes back up, the entity's owner will be re-assigned to
that member.

Reassigning of owners via PeerDown and PeerUp is only done on the
leader. However that may not handle the case where the leader goes down.
When a new leader is elected we need it to select new owners for
entities owned by the down leader. There are 2 cases here. If the old
leader has not yet been detected as down then eventually we expect to
get PeerDown to handle it. The second case is if PeerDown was already
received prior to the leader change (probably the norm), in which case
PeerDown would not have been processed. To handle this case I overrode
onLeaderChanged to select new owners for entities owned by the old leader
that is passed in. The RaftActor sends the old leader's peerId so I
added a peerIdToMemberNames map to translate - this is populated via
PeerUp. Also I changed the RaftActor to track and pass the actual last valid
leader id, previously it passed the leader id from the previous behavior
which would normally be Candidate which always has a null leaderId.

The newOwner method was changed to ignore candidates in the
downPeerMemberNames set as there's no point in assigning the owner to a
candidate known to be down.

Change-Id: I8f0b78460a1a3e2a6418431f8a8a770a789e8f8d
Signed-off-by: Tom Pantelis <>
8 years agoBug 4105: Add Cars RPC to test entity ownership 03/26803/1
Tom Pantelis [Wed, 12 Aug 2015 04:59:46 +0000 (00:59 -0400)]
Bug 4105: Add Cars RPC to test entity ownership

Change-Id: I8e23698b64ef408ae157ca0d2e94ed1f272128c7
Signed-off-by: Tom Pantelis <>
8 years agoBug 4105: Add general-entities yang model 02/26802/1
Tom Pantelis [Wed, 12 Aug 2015 04:57:45 +0000 (00:57 -0400)]
Bug 4105: Add general-entities yang model

Added a general-entities yang model tha can be used to represent an
entity ID when no existing yang schema exists.

Change-Id: Iec815966fe21ec15cb78ff47c68cda0aa7ae8504
Signed-off-by: Tom Pantelis <>
8 years agoBug 4105: Add dynamic module/shard config for entity-owners shard 01/26801/1
Tom Pantelis [Tue, 11 Aug 2015 00:08:03 +0000 (20:08 -0400)]
Bug 4105: Add dynamic module/shard config for entity-owners shard

Added a new method addModuleShardConfiguration to Configuration.

I simplified the internals of ConfigurationImpl to make it easier to
add a new module/shard config. I combined serveral of the maps into one
moduleConfigMap and reduced the total # of fields to 3. For
synchronization, I kept the maps/sets immutable and used copy-on-write
semantics to update them as they will seldom change. I also made the
fields volatile.

I also removed the singleton nature of ShardStrategyFactory since each
datastore's Configuration will now be different, ie only the operational
datastore's Configuration will have the entity-owners module. The
datastore's ShardStrategyFactory instance is not instantiated and owned
by the ActorContext.

To make things easier for unit tests, I abstracted the file-reading code
in ConfigurationImpl to a new ModuleShardConfigProvider interface and
FileModuleShardConfigProvider implementation in the config package.
I also moved the inner classes to the config package.

While I was at it I also moved Configuration and ConfigurationImpl to the
config package for consistency.

Change-Id: I1d6858d3ae68869ca6f61d4f5a5f0d319d93c485
Signed-off-by: Tom Pantelis <>
8 years agoBug 4105: Implement UnregisterCandidateLocal in EntityOwnershipShard 00/26800/1
Tom Pantelis [Fri, 14 Aug 2015 12:42:02 +0000 (08:42 -0400)]
Bug 4105: Implement UnregisterCandidateLocal in EntityOwnershipShard

Also added a testOwnershipChanges case to EntityOwnershipShardTest to
run thru various ownership change scenarios with local and remote candidates
and local unregistration. As a result I found a couple bugs that I

Change-Id: I4343754fbbc8f471975e6c723ffc0beaedee2860
Signed-off-by: Tom Pantelis <>
8 years agoBug 4105: Integrate EntityOwnerChangeListener with EntityOwnershipShard 99/26799/1
Tom Pantelis [Fri, 14 Aug 2015 10:13:54 +0000 (06:13 -0400)]
Bug 4105: Integrate EntityOwnerChangeListener with EntityOwnershipShard

Change-Id: Ia302d503f9ff65aa48faf7d69f1405ebf5267166
Signed-off-by: Tom Pantelis <>
8 years agoBug 4105: Choose Owner for an Entity based on first come first served basis 98/26798/1
Moiz Raja [Wed, 19 Aug 2015 23:53:10 +0000 (16:53 -0700)]
Bug 4105: Choose Owner for an Entity based on first come first served basis

Change-Id: If40e19cf40e832c9317611bde2950502f7f4897c
Signed-off-by: Moiz Raja <>
Signed-off-by: Tom Pantelis <>
8 years agoBug 4105: Change commit retry mechanism in EntityOwnershipShard 97/26797/1
Tom Pantelis [Fri, 14 Aug 2015 03:21:56 +0000 (23:21 -0400)]
Bug 4105: Change commit retry mechanism in EntityOwnershipShard

Change-Id: Iba640eab1c21672ffe6357531c6d236e65c1cd73
Signed-off-by: Tom Pantelis <>
8 years agoBug 4105: Add EntityOwnerDataChangeListener 96/26796/1
Tom Pantelis [Wed, 12 Aug 2015 19:51:54 +0000 (15:51 -0400)]
Bug 4105: Add EntityOwnerDataChangeListener

Added EntityOwnerDataChangeListener that responds to changes to the
entity owner leaf and notifies the EntityOwnershipListenerSupport

I also added an EntityOwnersModel class that defines various entity-owners
yang model constants (moved from EntityOwnershipShard) and has utilities
for creating NormalizedNodes and paths.

Change-Id: Iaa567b5cba6cf0f5cfca0dce39f0f43c38fee4bc
Signed-off-by: Tom Pantelis <>
8 years agoBug 4105: Add EntityOwnershipListenerActor and support 95/26795/1
Tom Pantelis [Tue, 11 Aug 2015 04:05:38 +0000 (00:05 -0400)]
Bug 4105: Add EntityOwnershipListenerActor and support

Change-Id: Idbeef3e23ab45a11afe5fce56a55fe5d6945729a
Signed-off-by: Tom Pantelis <>
8 years agoBug 4105: Move Configuration classes to config package 94/26794/1
Tom Pantelis [Fri, 14 Aug 2015 02:16:06 +0000 (22:16 -0400)]
Bug 4105: Move Configuration classes to config package

Change-Id: I863600727f5171eb0db3591a541848aa877a68de
Signed-off-by: Tom Pantelis <>
8 years agoBug 4105: Implement RegisterCandidate in EntityOwnershipShard 93/26793/1
Tom Pantelis [Sun, 9 Aug 2015 04:22:02 +0000 (00:22 -0400)]
Bug 4105: Implement RegisterCandidate in EntityOwnershipShard

Change-Id: Idab615399d81a8451e22bfabd30aed9a98e4b037
Signed-off-by: Tom Pantelis <>
8 years agoBug 4105: Implement candidate registration close 92/26792/1
Tom Pantelis [Sat, 8 Aug 2015 10:57:03 +0000 (06:57 -0400)]
Bug 4105: Implement candidate registration close

Added an UnregisterCandidateLocal message which is sent when
a DistributedEntityOwnershipCandidateRegistration is closed.

Change-Id: I6336e1b83a7764bfb4abc2fc37e196175c008dc3
Signed-off-by: Tom Pantelis <>
8 years agoBug 4105: Implement DistributedEntityOwnershipService#registerCandidate 91/26791/1
Tom Pantelis [Sat, 8 Aug 2015 08:20:11 +0000 (04:20 -0400)]
Bug 4105: Implement DistributedEntityOwnershipService#registerCandidate

Added a RegisterCandidateLocal message and implemented registerCandidate
to send the message to the local EntityOwnershipShard.

Change-Id: If941401d00912ce34f74e54188af0430a5ec6fcc
Signed-off-by: Tom Pantelis <>
8 years agoBug 4105: Add entity-owners yang module 90/26790/1
Moiz Raja [Tue, 4 Aug 2015 20:00:52 +0000 (13:00 -0700)]
Bug 4105: Add entity-owners yang module

This module describes the data structure used for storing entity
ownership information by the clustered implementation of

Change-Id: Ib7f8fad74e00b480236b1a2bddb060b093e90ad4
Signed-off-by: Moiz Raja <>
8 years agoBug 4105: Add EntityOwnershipShard 89/26789/1
Tom Pantelis [Fri, 7 Aug 2015 20:20:48 +0000 (16:20 -0400)]
Bug 4105: Add EntityOwnershipShard

Added the EntityOwnershipShard and modified
DistributedEntityOwnershipService to create it.

Change-Id: Id173b148797e90ff5d38d7f7cde177d303943181
Signed-off-by: Tom Pantelis <>