*/
package org.opendaylight.controller.cluster.sharding;
+import static java.util.Objects.requireNonNull;
+
import akka.actor.ActorRef;
import akka.actor.ActorSelection;
import akka.actor.ActorSystem;
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;
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;
* Actor that tracks currently open producers/shards on remote nodes and handles notifications of remote
* nodes of newly open producers/shards on the local node.
*/
+@Deprecated(forRemoval = true)
public class ShardedDataTreeActor extends AbstractUntypedPersistentActor {
private static final Logger LOG = LoggerFactory.getLogger(ShardedDataTreeActor.class);
// 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<DOMDataTreeIdentifier, ActorProducerRegistration> idToProducer = new HashMap<>();
final Future<Object> ask = Patterns.ask(shard, FindLeader.INSTANCE, context.getOperationTimeout());
- ask.onComplete(new OnComplete<Object>() {
+ 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<String> leaderActor = findLeader.getLeaderActor();
+ final Optional<String> 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..",
return false;
}
- if (YangInstanceIdentifier.EMPTY.equals(prefix.getRootIdentifier())) {
+ if (YangInstanceIdentifier.empty().equals(prefix.getRootIdentifier())) {
return true;
}
public void run() {
final Future<Object> ask = Patterns.ask(shard, FindLeader.INSTANCE, context.getOperationTimeout());
- ask.onComplete(new OnComplete<Object>() {
+ 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<String> leaderActor = findLeader.getLeaderActor();
+ final Optional<String> 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.",
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;
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;
}
}
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() {