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%2FDataChangeListenerRegistrationProxy.java;h=534beead0ed4d256c4626870fbee54582add8d9f;hp=b2ae060c3d30c219615432ad59d0b495f93e4294;hb=4aafd13eccad285b5bb3ee277b0fb0b8721612bc;hpb=b5167b9bc04f2792b275cfe0eac78c0f5eb9442d diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataChangeListenerRegistrationProxy.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataChangeListenerRegistrationProxy.java index b2ae060c3d..534beead0e 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataChangeListenerRegistrationProxy.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataChangeListenerRegistrationProxy.java @@ -8,12 +8,11 @@ package org.opendaylight.controller.cluster.datastore; -import java.util.concurrent.TimeUnit; import akka.actor.ActorRef; import akka.actor.ActorSelection; import akka.actor.PoisonPill; import akka.dispatch.OnComplete; -import akka.util.Timeout; +import com.google.common.annotations.VisibleForTesting; import org.opendaylight.controller.cluster.datastore.exceptions.LocalShardNotFoundException; import org.opendaylight.controller.cluster.datastore.messages.CloseDataChangeListenerRegistration; import org.opendaylight.controller.cluster.datastore.messages.RegisterChangeListener; @@ -22,12 +21,12 @@ import org.opendaylight.controller.cluster.datastore.utils.ActorContext; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeListener; +import org.opendaylight.controller.md.sal.dom.api.ClusteredDOMDataChangeListener; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.google.common.annotations.VisibleForTesting; import scala.concurrent.Future; /** @@ -42,8 +41,6 @@ public class DataChangeListenerRegistrationProxy implements ListenerRegistration private static final Logger LOG = LoggerFactory.getLogger(DataChangeListenerRegistrationProxy.class); - public static final Timeout REGISTER_TIMEOUT = new Timeout(5, TimeUnit.MINUTES); - private volatile ActorSelection listenerRegistrationActor; private final AsyncDataChangeListener> listener; private ActorRef dataChangeListenerActor; @@ -89,17 +86,16 @@ public class DataChangeListenerRegistrationProxy implements ListenerRegistration } if(sendCloseMessage) { - listenerRegistrationActor.tell(new - CloseDataChangeListenerRegistration().toSerializable(), null); + listenerRegistrationActor.tell(CloseDataChangeListenerRegistration.INSTANCE, null); } } public void init(final YangInstanceIdentifier path, final AsyncDataBroker.DataChangeScope scope) { dataChangeListenerActor = actorContext.getActorSystem().actorOf( - DataChangeListener.props(listener)); + DataChangeListener.props(listener).withDispatcher(actorContext.getNotificationDispatcherPath())); - Future findFuture = actorContext.findLocalShardAsync(shardName, REGISTER_TIMEOUT); + Future findFuture = actorContext.findLocalShardAsync(shardName); findFuture.onComplete(new OnComplete() { @Override public void onComplete(Throwable failure, ActorRef shard) { @@ -113,15 +109,16 @@ public class DataChangeListenerRegistrationProxy implements ListenerRegistration doRegistration(shard, path, scope); } } - }, actorContext.getActorSystem().dispatcher()); + }, actorContext.getClientDispatcher()); } private void doRegistration(ActorRef shard, final YangInstanceIdentifier path, DataChangeScope scope) { Future future = actorContext.executeOperationAsync(shard, - new RegisterChangeListener(path, dataChangeListenerActor.path(), scope), - REGISTER_TIMEOUT); + new RegisterChangeListener(path, dataChangeListenerActor, scope, + listener instanceof ClusteredDOMDataChangeListener), + actorContext.getDatastoreContext().getShardInitializationTimeout()); future.onComplete(new OnComplete(){ @Override @@ -135,7 +132,7 @@ public class DataChangeListenerRegistrationProxy implements ListenerRegistration reply.getListenerRegistrationPath())); } } - }, actorContext.getActorSystem().dispatcher()); + }, actorContext.getClientDispatcher()); } @Override @@ -148,8 +145,7 @@ public class DataChangeListenerRegistrationProxy implements ListenerRegistration } if(sendCloseMessage) { - listenerRegistrationActor.tell(new CloseDataChangeListenerRegistration().toSerializable(), - ActorRef.noSender()); + listenerRegistrationActor.tell(CloseDataChangeListenerRegistration.INSTANCE, ActorRef.noSender()); listenerRegistrationActor = null; }