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%2FDataTreeChangeListenerProxy.java;h=0268b8e36c41a43fb986d96663a7f12d28ff13a4;hb=refs%2Fchanges%2F02%2F83802%2F42;hp=a57a799284921a49582bc857d9453189b77186a0;hpb=634dfac8eead60f443bf75e749c70d1f2bb29198;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataTreeChangeListenerProxy.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataTreeChangeListenerProxy.java index a57a799284..0268b8e36c 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataTreeChangeListenerProxy.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataTreeChangeListenerProxy.java @@ -7,18 +7,20 @@ */ package org.opendaylight.controller.cluster.datastore; +import static java.util.Objects.requireNonNull; + import akka.actor.ActorRef; import akka.actor.ActorSelection; import akka.actor.PoisonPill; import akka.dispatch.OnComplete; import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Preconditions; -import javax.annotation.concurrent.GuardedBy; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; +import org.checkerframework.checker.lock.qual.GuardedBy; import org.opendaylight.controller.cluster.datastore.exceptions.LocalShardNotFoundException; import org.opendaylight.controller.cluster.datastore.messages.CloseDataTreeNotificationListenerRegistration; import org.opendaylight.controller.cluster.datastore.messages.RegisterDataTreeChangeListener; import org.opendaylight.controller.cluster.datastore.messages.RegisterDataTreeNotificationListenerReply; -import org.opendaylight.controller.cluster.datastore.utils.ActorContext; +import org.opendaylight.controller.cluster.datastore.utils.ActorUtils; import org.opendaylight.mdsal.dom.api.ClusteredDOMDataTreeChangeListener; import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener; import org.opendaylight.yangtools.concepts.AbstractListenerRegistration; @@ -36,22 +38,22 @@ import scala.concurrent.Future; final class DataTreeChangeListenerProxy extends AbstractListenerRegistration { private static final Logger LOG = LoggerFactory.getLogger(DataTreeChangeListenerProxy.class); private final ActorRef dataChangeListenerActor; - private final ActorContext actorContext; + private final ActorUtils actorUtils; private final YangInstanceIdentifier registeredPath; @GuardedBy("this") private ActorSelection listenerRegistrationActor; - DataTreeChangeListenerProxy(final ActorContext actorContext, final T listener, + DataTreeChangeListenerProxy(final ActorUtils actorUtils, final T listener, final YangInstanceIdentifier registeredPath) { super(listener); - this.actorContext = Preconditions.checkNotNull(actorContext); - this.registeredPath = Preconditions.checkNotNull(registeredPath); - this.dataChangeListenerActor = actorContext.getActorSystem().actorOf( + this.actorUtils = requireNonNull(actorUtils); + this.registeredPath = requireNonNull(registeredPath); + this.dataChangeListenerActor = actorUtils.getActorSystem().actorOf( DataTreeChangeListenerActor.props(getInstance(), registeredPath) - .withDispatcher(actorContext.getNotificationDispatcherPath())); + .withDispatcher(actorUtils.getNotificationDispatcherPath())); - LOG.debug("{}: Created actor {} for DTCL {}", actorContext.getDatastoreContext().getLogicalStoreType(), + LOG.debug("{}: Created actor {} for DTCL {}", actorUtils.getDatastoreContext().getLogicalStoreType(), dataChangeListenerActor, listener); } @@ -67,7 +69,7 @@ final class DataTreeChangeListenerProxy ext } void init(final String shardName) { - Future findFuture = actorContext.findLocalShardAsync(shardName); + Future findFuture = actorUtils.findLocalShardAsync(shardName); findFuture.onComplete(new OnComplete() { @Override public void onComplete(final Throwable failure, final ActorRef shard) { @@ -82,9 +84,11 @@ final class DataTreeChangeListenerProxy ext doRegistration(shard); } } - }, actorContext.getClientDispatcher()); + }, actorUtils.getClientDispatcher()); } + @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", + justification = "https://github.com/spotbugs/spotbugs/issues/811") private void setListenerRegistrationActor(final ActorSelection actor) { if (actor == null) { LOG.debug("{}: Ignoring null actor on {}", logContext(), this); @@ -102,12 +106,14 @@ final class DataTreeChangeListenerProxy ext actor.tell(CloseDataTreeNotificationListenerRegistration.getInstance(), null); } + @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", + justification = "https://github.com/spotbugs/spotbugs/issues/811") private void doRegistration(final ActorRef shard) { - Future future = actorContext.executeOperationAsync(shard, + Future future = actorUtils.executeOperationAsync(shard, new RegisterDataTreeChangeListener(registeredPath, dataChangeListenerActor, getInstance() instanceof ClusteredDOMDataTreeChangeListener), - actorContext.getDatastoreContext().getShardInitializationTimeout()); + actorUtils.getDatastoreContext().getShardInitializationTimeout()); future.onComplete(new OnComplete() { @Override @@ -117,11 +123,11 @@ final class DataTreeChangeListenerProxy ext getInstance(), registeredPath, failure); } else { RegisterDataTreeNotificationListenerReply reply = (RegisterDataTreeNotificationListenerReply)result; - setListenerRegistrationActor(actorContext.actorSelection( + setListenerRegistrationActor(actorUtils.actorSelection( reply.getListenerRegistrationPath())); } } - }, actorContext.getClientDispatcher()); + }, actorUtils.getClientDispatcher()); } @VisibleForTesting @@ -135,6 +141,6 @@ final class DataTreeChangeListenerProxy ext } private String logContext() { - return actorContext.getDatastoreContext().getLogicalStoreType().toString(); + return actorUtils.getDatastoreContext().getLogicalStoreType().toString(); } }