X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2FShardDataTreeChangeListenerPublisherActorProxy.java;h=83209731c4abfd59b5b090eb4719a1c4894b9707;hb=HEAD;hp=7196f839e4ca876e7ae67ec519f54b6751d603db;hpb=925cb4a228d0fda99c7bfeb432eb25285a223887;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTreeChangeListenerPublisherActorProxy.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTreeChangeListenerPublisherActorProxy.java index 7196f839e4..83209731c4 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTreeChangeListenerPublisherActorProxy.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTreeChangeListenerPublisherActorProxy.java @@ -8,45 +8,41 @@ package org.opendaylight.controller.cluster.datastore; import akka.actor.ActorContext; -import javax.annotation.concurrent.NotThreadSafe; -import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener; -import org.opendaylight.yangtools.concepts.ListenerRegistration; +import akka.actor.ActorRef; +import akka.actor.Props; +import java.util.Optional; +import java.util.function.Consumer; +import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener; +import org.opendaylight.yangtools.concepts.Registration; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidate; /** - * Implementation of ShardDataTreeChangeListenerPublisher that offloads the generation and publication - * of data tree change notifications to an actor. + * Implementation of ShardDataTreeChangeListenerPublisher that offloads the generation and publication of data tree + * change notifications to an actor. This class is NOT thread-safe. * * @author Thomas Pantelis */ -@NotThreadSafe class ShardDataTreeChangeListenerPublisherActorProxy extends AbstractShardDataTreeNotificationPublisherActorProxy implements ShardDataTreeChangeListenerPublisher { - private final ShardDataTreeChangeListenerPublisher delegatePublisher = - new DefaultShardDataTreeChangeListenerPublisher(); - - ShardDataTreeChangeListenerPublisherActorProxy(ActorContext actorContext, String actorName) { - super(actorContext, actorName); - } - - private ShardDataTreeChangeListenerPublisherActorProxy(ShardDataTreeChangeListenerPublisherActorProxy other) { - super(other); - } - - @Override - public ListenerRegistration registerTreeChangeListener( - YangInstanceIdentifier treeId, L listener) { - return delegatePublisher.registerTreeChangeListener(treeId, listener); + ShardDataTreeChangeListenerPublisherActorProxy(final ActorContext actorContext, final String actorName, + final String logContext) { + super(actorContext, actorName, logContext); } @Override - public ShardDataTreeChangeListenerPublisher newInstance() { - return new ShardDataTreeChangeListenerPublisherActorProxy(this); + public void registerTreeChangeListener(final YangInstanceIdentifier treeId, + final DOMDataTreeChangeListener listener, final Optional currentState, + final Consumer onRegistration) { + final ShardDataTreeChangePublisherActor.RegisterListener regMessage = + new ShardDataTreeChangePublisherActor.RegisterListener(treeId, listener, currentState, onRegistration); + log.debug("{}: Sending {} to publisher actor {}", logContext(), regMessage, publisherActor()); + publisherActor().tell(regMessage, ActorRef.noSender()); } @Override - protected ShardDataTreeNotificationPublisher getDelegatePublisher() { - return delegatePublisher; + protected Props props() { + return ShardDataTreeChangePublisherActor.props(actorName(), logContext()); } }