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%2FAbstractShardDataTreeNotificationPublisherActorProxy.java;h=fb3e968fe85c43bf933f6982c7342d8460ae3d90;hb=d7c9a8ccfcb57f005490a226803d094289997ef9;hp=61a22d4c2c958be3dddd5a0197710f3339b9919f;hpb=38402d3e9b8976a40d7926efe47a06243210562f;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractShardDataTreeNotificationPublisherActorProxy.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractShardDataTreeNotificationPublisherActorProxy.java index 61a22d4c2c..fb3e968fe8 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractShardDataTreeNotificationPublisherActorProxy.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractShardDataTreeNotificationPublisherActorProxy.java @@ -9,8 +9,9 @@ package org.opendaylight.controller.cluster.datastore; import akka.actor.ActorContext; import akka.actor.ActorRef; +import akka.actor.Props; import javax.annotation.concurrent.NotThreadSafe; -import org.opendaylight.controller.cluster.datastore.utils.Dispatchers; +import org.opendaylight.controller.cluster.common.actor.Dispatchers; import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -23,43 +24,45 @@ import org.slf4j.LoggerFactory; */ @NotThreadSafe abstract class AbstractShardDataTreeNotificationPublisherActorProxy implements ShardDataTreeNotificationPublisher { - private static final Logger LOG = LoggerFactory.getLogger(AbstractShardDataTreeNotificationPublisherActorProxy.class); + protected final Logger log = LoggerFactory.getLogger(getClass()); private final ActorContext actorContext; private final String actorName; - private ActorRef notifierActor; + private final String logContext; + private ActorRef publisherActor; - protected AbstractShardDataTreeNotificationPublisherActorProxy(ActorContext actorContext, String actorName) { + protected AbstractShardDataTreeNotificationPublisherActorProxy(ActorContext actorContext, String actorName, + String logContext) { this.actorContext = actorContext; this.actorName = actorName; + this.logContext = logContext; } - protected AbstractShardDataTreeNotificationPublisherActorProxy( - AbstractShardDataTreeNotificationPublisherActorProxy other) { - this.actorContext = null; - this.actorName = null; - this.notifierActor = other.getNotifierActor(); + protected abstract Props props(); + + protected final String actorName() { + return actorName; } - protected abstract ShardDataTreeNotificationPublisher getDelegatePublisher(); + protected final String logContext() { + return logContext; + } @Override - public void publishChanges(DataTreeCandidate candidate, String logContext) { - getNotifierActor().tell(new ShardDataTreeNotificationPublisherActor.PublishNotifications( - getDelegatePublisher(), candidate, logContext), ActorRef.noSender()); + public void publishChanges(DataTreeCandidate candidate) { + publisherActor().tell(new ShardDataTreeNotificationPublisherActor.PublishNotifications(candidate), + ActorRef.noSender()); } - private ActorRef getNotifierActor() { - if(notifierActor == null) { - LOG.debug("Creating actor {}", actorName); - + protected final ActorRef publisherActor() { + if (publisherActor == null) { String dispatcher = new Dispatchers(actorContext.system().dispatchers()).getDispatcherPath( Dispatchers.DispatcherType.Notification); - notifierActor = actorContext.actorOf(ShardDataTreeNotificationPublisherActor.props(actorName) - .withDispatcher(dispatcher).withMailbox( - org.opendaylight.controller.cluster.datastore.utils.ActorContext.BOUNDED_MAILBOX), actorName); + publisherActor = actorContext.actorOf(props().withDispatcher(dispatcher), actorName); + + log.debug("{}: Created publisher actor {} with name {}", logContext, publisherActor, actorName); } - return notifierActor; + return publisherActor; } }