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 <L extends DOMDataTreeChangeListener> ListenerRegistration<L> 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<DataTreeCandidate> currentState,
+ final Consumer<ListenerRegistration<DOMDataTreeChangeListener>> 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());
}
}