X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2FDataTreeCohortRegistrationProxy.java;h=8012a2dcb70817ff604516dbeca499cee984b643;hp=e14db0fe6abf34bd222c58c75b495c6cb4b96fba;hb=HEAD;hpb=634dfac8eead60f443bf75e749c70d1f2bb29198 diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataTreeCohortRegistrationProxy.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataTreeCohortRegistrationProxy.java index e14db0fe6a..4e3c6cb8d7 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataTreeCohortRegistrationProxy.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataTreeCohortRegistrationProxy.java @@ -7,17 +7,17 @@ */ package org.opendaylight.controller.cluster.datastore; +import static java.util.Objects.requireNonNull; + import akka.actor.ActorRef; import akka.dispatch.OnComplete; import akka.pattern.Patterns; import akka.util.Timeout; -import com.google.common.base.Preconditions; import java.util.concurrent.TimeUnit; -import javax.annotation.concurrent.GuardedBy; +import org.checkerframework.checker.lock.qual.GuardedBy; import org.opendaylight.controller.cluster.datastore.exceptions.LocalShardNotFoundException; -import org.opendaylight.controller.cluster.datastore.utils.ActorContext; +import org.opendaylight.controller.cluster.datastore.utils.ActorUtils; import org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohort; -import org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohortRegistration; import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier; import org.opendaylight.yangtools.concepts.AbstractObjectRegistration; import org.slf4j.Logger; @@ -25,29 +25,28 @@ import org.slf4j.LoggerFactory; import scala.concurrent.Future; import scala.concurrent.duration.FiniteDuration; -public class DataTreeCohortRegistrationProxy extends AbstractObjectRegistration - implements DOMDataTreeCommitCohortRegistration { - +public class DataTreeCohortRegistrationProxy extends AbstractObjectRegistration { private static final Logger LOG = LoggerFactory.getLogger(DataTreeCohortRegistrationProxy.class); private static final Timeout TIMEOUT = new Timeout(new FiniteDuration(5, TimeUnit.SECONDS)); + private final DOMDataTreeIdentifier subtree; private final ActorRef actor; - private final ActorContext actorContext; + private final ActorUtils actorUtils; @GuardedBy("this") private ActorRef cohortRegistry; - DataTreeCohortRegistrationProxy(final ActorContext actorContext, final DOMDataTreeIdentifier subtree, + DataTreeCohortRegistrationProxy(final ActorUtils actorUtils, final DOMDataTreeIdentifier subtree, final C cohort) { super(cohort); - this.subtree = Preconditions.checkNotNull(subtree); - this.actorContext = Preconditions.checkNotNull(actorContext); - this.actor = actorContext.getActorSystem().actorOf(DataTreeCohortActor.props(getInstance(), - subtree.getRootIdentifier()).withDispatcher(actorContext.getNotificationDispatcherPath())); + this.subtree = requireNonNull(subtree); + this.actorUtils = requireNonNull(actorUtils); + actor = actorUtils.getActorSystem().actorOf(DataTreeCohortActor.props(getInstance(), + subtree.path()).withDispatcher(actorUtils.getNotificationDispatcherPath())); } public void init(final String shardName) { // FIXME: Add late binding to shard. - Future findFuture = actorContext.findLocalShardAsync(shardName); + Future findFuture = actorUtils.findLocalShardAsync(shardName); findFuture.onComplete(new OnComplete() { @Override public void onComplete(final Throwable failure, final ActorRef shard) { @@ -61,7 +60,7 @@ public class DataTreeCohortRegistrationProxy performRegistration(shard); } } - }, actorContext.getClientDispatcher()); + }, actorUtils.getClientDispatcher()); } private synchronized void performRegistration(final ActorRef shard) { @@ -71,7 +70,7 @@ public class DataTreeCohortRegistrationProxy cohortRegistry = shard; Future future = Patterns.ask(shard, new DataTreeCohortActorRegistry.RegisterCohort(subtree, actor), TIMEOUT); - future.onComplete(new OnComplete() { + future.onComplete(new OnComplete<>() { @Override public void onComplete(final Throwable failure, final Object val) { @@ -83,7 +82,7 @@ public class DataTreeCohortRegistrationProxy } } - }, actorContext.getClientDispatcher()); + }, actorUtils.getClientDispatcher()); } @Override