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%2Fsharding%2FShardedDataTreeActor.java;h=f7c0d223072860149a57c3f91f216465963ac779;hp=5ab402ce59671c60dc3341839563606dd8a52fe2;hb=f0e8f9a9547dca1e232a7e8d3912a86de69bcc6a;hpb=3d8f5da25156aa5ca2a82c7bfa1c1abbd80e8d73 diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/ShardedDataTreeActor.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/ShardedDataTreeActor.java index 5ab402ce59..f7c0d22307 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/ShardedDataTreeActor.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/ShardedDataTreeActor.java @@ -7,6 +7,8 @@ */ package org.opendaylight.controller.cluster.sharding; +import static java.util.Objects.requireNonNull; + import akka.actor.ActorRef; import akka.actor.ActorSelection; import akka.actor.ActorSystem; @@ -25,7 +27,6 @@ import akka.cluster.Member; import akka.dispatch.OnComplete; import akka.pattern.Patterns; import akka.util.Timeout; -import com.google.common.base.Preconditions; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -37,8 +38,8 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.TimeUnit; import org.opendaylight.controller.cluster.access.concepts.MemberName; import org.opendaylight.controller.cluster.common.actor.AbstractUntypedPersistentActor; -import org.opendaylight.controller.cluster.datastore.AbstractDataStore; import org.opendaylight.controller.cluster.datastore.ClusterWrapper; +import org.opendaylight.controller.cluster.datastore.DistributedDataStoreInterface; import org.opendaylight.controller.cluster.datastore.config.PrefixShardConfiguration; import org.opendaylight.controller.cluster.datastore.utils.ActorUtils; import org.opendaylight.controller.cluster.datastore.utils.ClusterUtils; @@ -89,8 +90,8 @@ public class ShardedDataTreeActor extends AbstractUntypedPersistentActor { // for calls that need specific actor context tied to a datastore use the one provided in the DistributedDataStore private final ActorUtils actorUtils; private final ShardingServiceAddressResolver resolver; - private final AbstractDataStore distributedConfigDatastore; - private final AbstractDataStore distributedOperDatastore; + private final DistributedDataStoreInterface distributedConfigDatastore; + private final DistributedDataStoreInterface distributedOperDatastore; private final int lookupTaskMaxRetries; private final Map idToProducer = new HashMap<>(); @@ -498,14 +499,14 @@ public class ShardedDataTreeActor extends AbstractUntypedPersistentActor { final Future ask = Patterns.ask(shard, FindLeader.INSTANCE, context.getOperationTimeout()); - ask.onComplete(new OnComplete() { + ask.onComplete(new OnComplete<>() { @Override public void onComplete(final Throwable throwable, final Object findLeaderReply) { if (throwable != null) { tryReschedule(throwable); } else { final FindLeaderReply findLeader = (FindLeaderReply) findLeaderReply; - final java.util.Optional leaderActor = findLeader.getLeaderActor(); + final Optional leaderActor = findLeader.getLeaderActor(); if (leaderActor.isPresent()) { // leader is found, backend seems ready, check if the frontend is ready LOG.debug("{} - Leader for shard[{}] backend ready, starting frontend lookup..", @@ -575,7 +576,7 @@ public class ShardedDataTreeActor extends AbstractUntypedPersistentActor { return false; } - if (YangInstanceIdentifier.EMPTY.equals(prefix.getRootIdentifier())) { + if (YangInstanceIdentifier.empty().equals(prefix.getRootIdentifier())) { return true; } @@ -724,14 +725,14 @@ public class ShardedDataTreeActor extends AbstractUntypedPersistentActor { public void run() { final Future ask = Patterns.ask(shard, FindLeader.INSTANCE, context.getOperationTimeout()); - ask.onComplete(new OnComplete() { + ask.onComplete(new OnComplete<>() { @Override public void onComplete(final Throwable throwable, final Object findLeaderReply) { if (throwable != null) { tryReschedule(throwable); } else { final FindLeaderReply findLeader = (FindLeaderReply) findLeaderReply; - final java.util.Optional leaderActor = findLeader.getLeaderActor(); + final Optional leaderActor = findLeader.getLeaderActor(); if (leaderActor.isPresent()) { // leader is found, backend seems ready, check if the frontend is ready LOG.debug("{} - Leader for config shard is ready. Ending lookup.", @@ -749,8 +750,8 @@ public class ShardedDataTreeActor extends AbstractUntypedPersistentActor { public static class ShardedDataTreeActorCreator { private DistributedShardedDOMDataTree shardingService; - private AbstractDataStore distributedConfigDatastore; - private AbstractDataStore distributedOperDatastore; + private DistributedDataStoreInterface distributedConfigDatastore; + private DistributedDataStoreInterface distributedOperDatastore; private ActorSystem actorSystem; private ClusterWrapper cluster; private int maxRetries; @@ -782,22 +783,22 @@ public class ShardedDataTreeActor extends AbstractUntypedPersistentActor { return cluster; } - public AbstractDataStore getDistributedConfigDatastore() { + public DistributedDataStoreInterface getDistributedConfigDatastore() { return distributedConfigDatastore; } public ShardedDataTreeActorCreator setDistributedConfigDatastore( - final AbstractDataStore distributedConfigDatastore) { + final DistributedDataStoreInterface distributedConfigDatastore) { this.distributedConfigDatastore = distributedConfigDatastore; return this; } - public AbstractDataStore getDistributedOperDatastore() { + public DistributedDataStoreInterface getDistributedOperDatastore() { return distributedOperDatastore; } public ShardedDataTreeActorCreator setDistributedOperDatastore( - final AbstractDataStore distributedOperDatastore) { + final DistributedDataStoreInterface distributedOperDatastore) { this.distributedOperDatastore = distributedOperDatastore; return this; } @@ -812,11 +813,11 @@ public class ShardedDataTreeActor extends AbstractUntypedPersistentActor { } private void verify() { - Preconditions.checkNotNull(shardingService); - Preconditions.checkNotNull(actorSystem); - Preconditions.checkNotNull(cluster); - Preconditions.checkNotNull(distributedConfigDatastore); - Preconditions.checkNotNull(distributedOperDatastore); + requireNonNull(shardingService); + requireNonNull(actorSystem); + requireNonNull(cluster); + requireNonNull(distributedConfigDatastore); + requireNonNull(distributedOperDatastore); } public Props props() {