Dynamically update DatastoreContext properties 71/15571/6
authortpantelis <tpanteli@brocade.com>
Thu, 19 Feb 2015 21:00:38 +0000 (16:00 -0500)
committerTom Pantelis <tpanteli@brocade.com>
Sun, 22 Feb 2015 13:25:47 +0000 (08:25 -0500)
commita23ab6d60b7b57184a8fe59e282e46b448c86d6a
tree4e44b1276e3335d30790c86fec8a74209f5fde6f
parent6b9787d26aab04acf95fa30601291380f9b1d5c9
Dynamically update DatastoreContext properties

Added a ConfigurationListener to the DatastoreContextConfigAdminOverlay
that is registered as an OSGi service to receive ConfigurationEvents
from the Config Admin when the
org.opendaylight.controller.cluster.datastore.cfg file is modified.

The DistributedDataStore registers as a listener to the
DatastoreContextConfigAdminOverlay to get updated when the
DatastoreContext instance changes due to a ConfigurationEvent. The
DistributedDataStore sets the new DatastoreContext instance in the
ActorContext which updates its cached instance and properties and
sends the DistributedDataStore instance as a message to the ShardManager.
The ShardManager simply sends it out to all the Shards which update
their cached DatastoreContext state.

The Shard also updates the new ConfigParams instance in the base RaftActor
which sets it in its RaftActorContext. There was one place in
FollowerLogInformationImpl where it had a local cache of a property
obtained from the ConfigParams so I changed the ctor to pass the
RaftActorContext instead and obtain the property each time from the
ConfigParams.

A slight downside to this is that we'll have to be cognizant of not caching
DatastoreContext/ConfigParams properties and assuming they're static. Or
if we do cache we need to handle updates.

I toyed around with trying to restart the DistributedDataStore with a
new DatastoreContext and ActorContext and killing the previous
ShardManager and Shard actors and creating new ones. However recreating
the Shards without being disruptive to clients is tricky and risky, eg handling
infight transactions, and I didn't see a clean way to do it without
possibly causing inflight transactions to fail. .So I went with the simpler
approach of just pushing an updated DatastoreContext to the actors.

Change-Id: Ie608f61da36ac58a806208925a3c4277968c2f5b
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
19 files changed:
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/DefaultConfigParamsImpl.java
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/FollowerLogInformationImpl.java
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActor.java
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorContextImpl.java
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/AbstractLeader.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/FollowerLogInformationImplTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/MockRaftActorContext.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DatastoreContextConfigAdminOverlay.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DatastoreContextIntrospector.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DistributedDataStore.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreFactory.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/Shard.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardCommitCoordinator.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardManager.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/ActorContext.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DatastoreContextConfigAdminOverlayTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/ActorContextTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/resources/simplelogger.properties