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%2Fdatabroker%2Factors%2Fdds%2FAbstractShardBackendResolver.java;fp=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatabroker%2Factors%2Fdds%2FAbstractShardBackendResolver.java;h=eddbba6acdd92992bf4e145c8fb3f20596fb3000;hp=d2b10c1b7067a038e90d910b16a0749ff4b76212;hb=f83b2d36fdd7e953ba72492ffb684cd112aa04a6;hpb=800b391dd8f6c0d4de0e7cf9e65961146e2f6c94 diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/AbstractShardBackendResolver.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/AbstractShardBackendResolver.java index d2b10c1b70..eddbba6acd 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/AbstractShardBackendResolver.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/AbstractShardBackendResolver.java @@ -7,9 +7,11 @@ */ package org.opendaylight.controller.cluster.databroker.actors.dds; +import static com.google.common.base.Preconditions.checkArgument; +import static java.util.Objects.requireNonNull; + import akka.actor.ActorRef; import akka.util.Timeout; -import com.google.common.base.Preconditions; import com.google.common.primitives.UnsignedLong; import java.util.Set; import java.util.concurrent.CompletableFuture; @@ -35,7 +37,7 @@ import org.opendaylight.controller.cluster.datastore.exceptions.NoShardLeaderExc import org.opendaylight.controller.cluster.datastore.exceptions.NotInitializedException; import org.opendaylight.controller.cluster.datastore.exceptions.PrimaryNotFoundException; import org.opendaylight.controller.cluster.datastore.messages.PrimaryShardInfo; -import org.opendaylight.controller.cluster.datastore.utils.ActorContext; +import org.opendaylight.controller.cluster.datastore.utils.ActorUtils; import org.opendaylight.yangtools.concepts.Registration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -45,7 +47,7 @@ import scala.compat.java8.FutureConverters; /** * {@link BackendInfoResolver} implementation for static shard configuration based on ShardManager. Each string-named * shard is assigned a single cookie and this mapping is stored in a bidirectional map. Information about corresponding - * shard leader is resolved via {@link ActorContext}. The product of resolution is {@link ShardBackendInfo}. + * shard leader is resolved via {@link ActorUtils}. The product of resolution is {@link ShardBackendInfo}. * * @author Robert Varga */ @@ -57,7 +59,7 @@ abstract class AbstractShardBackendResolver extends BackendInfoResolver stage) { - this.stage = Preconditions.checkNotNull(stage); + this.stage = requireNonNull(stage); stage.whenComplete(this::onStageResolved); } @@ -71,7 +73,7 @@ abstract class AbstractShardBackendResolver extends BackendInfoResolver connectFunction; - private final ActorContext actorContext; + private final ActorUtils actorUtils; private final Set> staleBackendInfoCallbacks = ConcurrentHashMap.newKeySet(); // FIXME: we really need just ActorContext.findPrimaryShardAsync() - AbstractShardBackendResolver(final ClientIdentifier clientId, final ActorContext actorContext) { - this.actorContext = Preconditions.checkNotNull(actorContext); + AbstractShardBackendResolver(final ClientIdentifier clientId, final ActorUtils actorUtils) { + this.actorUtils = requireNonNull(actorUtils); this.connectFunction = ExplicitAsk.toScala(t -> new ConnectClientRequest(clientId, t, ABIVersion.BORON, ABIVersion.current())); } @@ -108,19 +110,19 @@ abstract class AbstractShardBackendResolver extends BackendInfoResolver callback.accept(cookie)); } - protected ActorContext actorContext() { - return actorContext; + protected ActorUtils actorUtils() { + return actorUtils; } protected final void flushCache(final String shardName) { - actorContext.getPrimaryShardInfoCache().remove(shardName); + actorUtils.getPrimaryShardInfoCache().remove(shardName); } protected final ShardState resolveBackendInfo(final String shardName, final long cookie) { LOG.debug("Resolving cookie {} to shard {}", cookie, shardName); final CompletableFuture future = new CompletableFuture<>(); - FutureConverters.toJava(actorContext.findPrimaryShardAsync(shardName)).whenComplete((info, failure) -> { + FutureConverters.toJava(actorUtils.findPrimaryShardAsync(shardName)).whenComplete((info, failure) -> { if (failure == null) { connectShard(shardName, cookie, info, future); return; @@ -146,7 +148,7 @@ abstract class AbstractShardBackendResolver extends BackendInfoResolver