X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2FAbstractDataStore.java;h=dce5368218f30685f30fcc2894a5be73c08cab5a;hp=36c822cd0b10d6586afde0bcdd5ebc434bbd328c;hb=28e9832cc97a345d5ceb69262784e5c8fef77e37;hpb=5a0edd493bafc365647bc6311b4b7da86a78645d diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractDataStore.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractDataStore.java index 36c822cd0b..dce5368218 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractDataStore.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractDataStore.java @@ -25,7 +25,7 @@ import org.opendaylight.controller.cluster.datastore.config.Configuration; import org.opendaylight.controller.cluster.datastore.identifiers.ShardManagerIdentifier; import org.opendaylight.controller.cluster.datastore.jmx.mbeans.DatastoreConfigurationMXBeanImpl; import org.opendaylight.controller.cluster.datastore.jmx.mbeans.DatastoreInfoMXBeanImpl; -import org.opendaylight.controller.cluster.datastore.messages.DatastoreSnapshot; +import org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot; import org.opendaylight.controller.cluster.datastore.shardmanager.ShardManagerCreator; import org.opendaylight.controller.cluster.datastore.utils.ActorContext; import org.opendaylight.controller.cluster.datastore.utils.Dispatchers; @@ -136,6 +136,16 @@ public abstract class AbstractDataStore implements DistributedDataStoreInterface .duration().toMillis() * READY_WAIT_FACTOR; } + @VisibleForTesting + protected AbstractDataStore(final ActorContext actorContext, final ClientIdentifier identifier, + final DataStoreClient clientActor) { + this.actorContext = Preconditions.checkNotNull(actorContext, "actorContext should not be null"); + this.client = clientActor; + this.identifier = Preconditions.checkNotNull(identifier); + this.waitTillReadyTimeInMillis = actorContext.getDatastoreContext().getShardLeaderElectionTimeout() + .duration().toMillis() * READY_WAIT_FACTOR; + } + protected final DataStoreClient getClient() { return client; } @@ -179,8 +189,8 @@ public abstract class AbstractDataStore implements DistributedDataStoreInterface LOG.debug("Registering tree listener: {} for tree: {} shard: {}", listener, treeId, shardName); final DataTreeChangeListenerProxy listenerRegistrationProxy = - new DataTreeChangeListenerProxy<>(actorContext, listener); - listenerRegistrationProxy.init(shardName, treeId); + new DataTreeChangeListenerProxy<>(actorContext, listener, treeId); + listenerRegistrationProxy.init(shardName); return listenerRegistrationProxy; } @@ -287,4 +297,26 @@ public abstract class AbstractDataStore implements DistributedDataStoreInterface public CountDownLatch getWaitTillReadyCountDownLatch() { return waitTillReadyCountDownLatch; } + + @SuppressWarnings("unchecked") + public ListenerRegistration registerProxyListener( + final YangInstanceIdentifier shardLookup, + final YangInstanceIdentifier insideShard, + final org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener delegate) { + + Preconditions.checkNotNull(shardLookup, "shardLookup should not be null"); + Preconditions.checkNotNull(insideShard, "insideShard should not be null"); + Preconditions.checkNotNull(delegate, "delegate should not be null"); + + final String shardName = actorContext.getShardStrategyFactory().getStrategy(shardLookup).findShard(shardLookup); + LOG.debug("Registering tree listener: {} for tree: {} shard: {}, path inside shard: {}", + delegate,shardLookup, shardName, insideShard); + + final DataTreeChangeListenerProxy listenerRegistrationProxy = + new DataTreeChangeListenerProxy<>(actorContext, delegate::onDataTreeChanged, insideShard); + listenerRegistrationProxy.init(shardName); + + return (ListenerRegistration) listenerRegistrationProxy; + } + }