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=87706763c5f59d64c73fedfb81d17d8c18a81f5b;hb=28e9832cc97a345d5ceb69262784e5c8fef77e37;hpb=2f77e92af7a68b4a97dbfb709c6cc9b11a49878a;ds=sidebyside 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 87706763c5..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 @@ -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; } @@ -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; + } + }