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=d737b55437ff9af482272313ccd2aafdcb8952ae;hb=55a9b9f42a14c56060f74b38f84d444c0fbfecc4;hp=2ac3ee8843d61cdc13d3da13ef2cacae764c7805;hpb=a46305fbc6bb7ec6883c21298d356a5e4fbbb015;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 2ac3ee8843..d737b55437 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,44 +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 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.ListenerRegistration; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.schema.tree.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()); } }