Rename ActorContext to ActorUtils
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / sharding / ShardedDataTreeActor.java
index 3efbbabeb8fb1a6335995bf236d86098f29093be..679055fa2fd3fd79d243b7214603870279ca3bff 100644 (file)
@@ -8,8 +8,6 @@
 
 package org.opendaylight.controller.cluster.sharding;
 
-import static akka.actor.ActorRef.noSender;
-
 import akka.actor.ActorRef;
 import akka.actor.ActorSelection;
 import akka.actor.ActorSystem;
@@ -43,7 +41,7 @@ import org.opendaylight.controller.cluster.common.actor.AbstractUntypedPersisten
 import org.opendaylight.controller.cluster.datastore.AbstractDataStore;
 import org.opendaylight.controller.cluster.datastore.ClusterWrapper;
 import org.opendaylight.controller.cluster.datastore.config.PrefixShardConfiguration;
-import org.opendaylight.controller.cluster.datastore.utils.ActorContext;
+import org.opendaylight.controller.cluster.datastore.utils.ActorUtils;
 import org.opendaylight.controller.cluster.datastore.utils.ClusterUtils;
 import org.opendaylight.controller.cluster.raft.client.messages.FindLeader;
 import org.opendaylight.controller.cluster.raft.client.messages.FindLeaderReply;
@@ -90,7 +88,7 @@ public class ShardedDataTreeActor extends AbstractUntypedPersistentActor {
     private final ClusterWrapper clusterWrapper;
     // helper actorContext used only for static calls to executeAsync etc
     // for calls that need specific actor context tied to a datastore use the one provided in the DistributedDataStore
-    private final ActorContext actorContext;
+    private final ActorUtils actorUtils;
     private final ShardingServiceAddressResolver resolver;
     private final AbstractDataStore distributedConfigDatastore;
     private final AbstractDataStore distributedOperDatastore;
@@ -107,7 +105,7 @@ public class ShardedDataTreeActor extends AbstractUntypedPersistentActor {
         distributedConfigDatastore = builder.getDistributedConfigDatastore();
         distributedOperDatastore = builder.getDistributedOperDatastore();
         lookupTaskMaxRetries = builder.getLookupTaskMaxRetries();
-        actorContext = distributedConfigDatastore.getActorContext();
+        actorUtils = distributedConfigDatastore.getActorUtils();
         resolver = new ShardingServiceAddressResolver(
                 DistributedShardedDOMDataTree.ACTOR_ID, clusterWrapper.getCurrentMemberName());
 
@@ -119,12 +117,12 @@ public class ShardedDataTreeActor extends AbstractUntypedPersistentActor {
     }
 
     @Override
-    protected void handleRecover(final Object message) throws Exception {
+    protected void handleRecover(final Object message) {
         LOG.debug("Received a recover message {}", message);
     }
 
     @Override
-    protected void handleCommand(final Object message) throws Exception {
+    protected void handleCommand(final Object message) {
         LOG.debug("{} : Received {}", clusterWrapper.getCurrentMemberName(), message);
         if (message instanceof ClusterEvent.MemberUp) {
             memberUp((ClusterEvent.MemberUp) message);
@@ -219,7 +217,7 @@ public class ShardedDataTreeActor extends AbstractUntypedPersistentActor {
 
         // fastpath if we have no peers
         if (resolver.getShardingServicePeerActorAddresses().isEmpty()) {
-            getSender().tell(new Status.Success(null), noSender());
+            getSender().tell(new Status.Success(null), ActorRef.noSender());
         }
 
         final ActorRef sender = getSender();
@@ -231,7 +229,7 @@ public class ShardedDataTreeActor extends AbstractUntypedPersistentActor {
             final ActorSelection actorSelection = actorSystem.actorSelection(address);
             futures.add(
                     FutureConverters.toJava(
-                            actorContext.executeOperationAsync(
+                            actorUtils.executeOperationAsync(
                                     actorSelection, new NotifyProducerCreated(subtrees), DEFAULT_ASK_TIMEOUT))
                     .toCompletableFuture());
         }
@@ -240,7 +238,7 @@ public class ShardedDataTreeActor extends AbstractUntypedPersistentActor {
                 futures.toArray(new CompletableFuture[futures.size()]));
 
         combinedFuture
-                .thenRun(() -> sender.tell(new Success(null), noSender()))
+                .thenRun(() -> sender.tell(new Success(null), ActorRef.noSender()))
                 .exceptionally(throwable -> {
                     sender.tell(new Status.Failure(throwable), self());
                     return null;
@@ -271,7 +269,7 @@ public class ShardedDataTreeActor extends AbstractUntypedPersistentActor {
             final ActorSelection selection = actorSystem.actorSelection(address);
 
             futures.add(FutureConverters.toJava(
-                    actorContext.executeOperationAsync(selection, new NotifyProducerRemoved(message.getSubtrees())))
+                    actorUtils.executeOperationAsync(selection, new NotifyProducerRemoved(message.getSubtrees())))
                     .toCompletableFuture());
         }
 
@@ -295,16 +293,16 @@ public class ShardedDataTreeActor extends AbstractUntypedPersistentActor {
         final ActorProducerRegistration registration = idToProducer.remove(message.getSubtrees().iterator().next());
         if (registration == null) {
             LOG.warn("The notification contained a path on which no producer is registered, throwing away");
-            getSender().tell(new Status.Success(null), noSender());
+            getSender().tell(new Status.Success(null), ActorRef.noSender());
             return;
         }
 
         try {
             registration.close();
-            getSender().tell(new Status.Success(null), noSender());
+            getSender().tell(new Status.Success(null), ActorRef.noSender());
         } catch (final DOMDataTreeProducerException e) {
             LOG.error("Unable to close producer", e);
-            getSender().tell(new Status.Failure(e), noSender());
+            getSender().tell(new Status.Failure(e), ActorRef.noSender());
         }
     }
 
@@ -314,8 +312,8 @@ public class ShardedDataTreeActor extends AbstractUntypedPersistentActor {
 
         final DOMDataTreeIdentifier prefix = message.getPrefix();
 
-        final ActorContext context = prefix.getDatastoreType() == LogicalDatastoreType.CONFIGURATION
-                        ? distributedConfigDatastore.getActorContext() : distributedOperDatastore.getActorContext();
+        final ActorUtils context = prefix.getDatastoreType() == LogicalDatastoreType.CONFIGURATION
+                        ? distributedConfigDatastore.getActorUtils() : distributedOperDatastore.getActorUtils();
 
         // schedule a notification task for the reply
         actorSystem.scheduler().scheduleOnce(SHARD_LOOKUP_TASK_INTERVAL,
@@ -336,7 +334,7 @@ public class ShardedDataTreeActor extends AbstractUntypedPersistentActor {
 
         final ShardRemovalLookupTask removalTask =
                 new ShardRemovalLookupTask(actorSystem, getSender(),
-                        actorContext, message.getPrefix(), lookupTaskMaxRetries);
+                        actorUtils, message.getPrefix(), lookupTaskMaxRetries);
 
         actorSystem.scheduler().scheduleOnce(SHARD_LOOKUP_TASK_INTERVAL, removalTask, actorSystem.dispatcher());
     }
@@ -350,9 +348,9 @@ public class ShardedDataTreeActor extends AbstractUntypedPersistentActor {
     private void onStartConfigShardLookup(final StartConfigShardLookup message) {
         LOG.debug("Received StartConfigShardLookup: {}", message);
 
-        final ActorContext context =
+        final ActorUtils context =
                 message.getType().equals(LogicalDatastoreType.CONFIGURATION)
-                        ? distributedConfigDatastore.getActorContext() : distributedOperDatastore.getActorContext();
+                        ? distributedConfigDatastore.getActorUtils() : distributedOperDatastore.getActorUtils();
 
         // schedule a notification task for the reply
         actorSystem.scheduler().scheduleOnce(SHARD_LOOKUP_TASK_INTERVAL,
@@ -410,7 +408,7 @@ public class ShardedDataTreeActor extends AbstractUntypedPersistentActor {
         private final ActorSystem system;
         private final ActorRef replyTo;
         private final ClusterWrapper clusterWrapper;
-        private final ActorContext context;
+        private final ActorUtils context;
         private final DistributedShardedDOMDataTree shardingService;
         private final DOMDataTreeIdentifier toLookup;
         private final int lookupMaxRetries;
@@ -418,7 +416,7 @@ public class ShardedDataTreeActor extends AbstractUntypedPersistentActor {
         ShardCreationLookupTask(final ActorSystem system,
                                 final ActorRef replyTo,
                                 final ClusterWrapper clusterWrapper,
-                                final ActorContext context,
+                                final ActorUtils context,
                                 final DistributedShardedDOMDataTree shardingService,
                                 final DOMDataTreeIdentifier toLookup,
                                 final int lookupMaxRetries) {
@@ -439,7 +437,7 @@ public class ShardedDataTreeActor extends AbstractUntypedPersistentActor {
 
             localShardFuture.onComplete(new OnComplete<ActorRef>() {
                 @Override
-                public void onComplete(Throwable throwable, ActorRef actorRef) throws Throwable {
+                public void onComplete(Throwable throwable, ActorRef actorRef) {
                     if (throwable != null) {
                         tryReschedule(throwable);
                     } else {
@@ -470,7 +468,7 @@ public class ShardedDataTreeActor extends AbstractUntypedPersistentActor {
 
         private final ActorSystem system;
         private final ActorRef replyTo;
-        private final ActorContext context;
+        private final ActorUtils context;
         private final ClusterWrapper clusterWrapper;
         private final ActorRef shard;
         private final DistributedShardedDOMDataTree shardingService;
@@ -479,7 +477,7 @@ public class ShardedDataTreeActor extends AbstractUntypedPersistentActor {
 
         ShardLeaderLookupTask(final ActorSystem system,
                               final ActorRef replyTo,
-                              final ActorContext context,
+                              final ActorUtils context,
                               final ClusterWrapper clusterWrapper,
                               final ActorRef shard,
                               final DistributedShardedDOMDataTree shardingService,
@@ -503,7 +501,7 @@ public class ShardedDataTreeActor extends AbstractUntypedPersistentActor {
 
             ask.onComplete(new OnComplete<Object>() {
                 @Override
-                public void onComplete(final Throwable throwable, final Object findLeaderReply) throws Throwable {
+                public void onComplete(final Throwable throwable, final Object findLeaderReply) {
                     if (throwable != null) {
                         tryReschedule(throwable);
                     } else {
@@ -566,7 +564,7 @@ public class ShardedDataTreeActor extends AbstractUntypedPersistentActor {
                     shardingService.lookupShardFrontend(toLookup);
 
             if (entry != null && tableEntryIdCheck(entry, toLookup) && entry.getValue() != null) {
-                replyTo.tell(new Success(null), noSender());
+                replyTo.tell(new Success(null), ActorRef.noSender());
             } else {
                 tryReschedule(null);
             }
@@ -605,12 +603,12 @@ public class ShardedDataTreeActor extends AbstractUntypedPersistentActor {
 
         private final ActorSystem system;
         private final ActorRef replyTo;
-        private final ActorContext context;
+        private final ActorUtils context;
         private final DOMDataTreeIdentifier toLookup;
 
         ShardRemovalLookupTask(final ActorSystem system,
                                final ActorRef replyTo,
-                               final ActorContext context,
+                               final ActorUtils context,
                                final DOMDataTreeIdentifier toLookup,
                                final int lookupMaxRetries) {
             super(replyTo, lookupMaxRetries);
@@ -627,12 +625,12 @@ public class ShardedDataTreeActor extends AbstractUntypedPersistentActor {
 
             localShardFuture.onComplete(new OnComplete<ActorRef>() {
                 @Override
-                public void onComplete(Throwable throwable, ActorRef actorRef) throws Throwable {
+                public void onComplete(Throwable throwable, ActorRef actorRef) {
                     if (throwable != null) {
                         //TODO Shouldn't we check why findLocalShard failed?
                         LOG.debug("Backend shard[{}] removal lookup successful notifying the registration future",
                                 toLookup);
-                        replyTo.tell(new Success(null), noSender());
+                        replyTo.tell(new Success(null), ActorRef.noSender());
                     } else {
                         tryReschedule(null);
                     }
@@ -656,11 +654,11 @@ public class ShardedDataTreeActor extends AbstractUntypedPersistentActor {
 
         private final ActorSystem system;
         private final ActorRef replyTo;
-        private final ActorContext context;
+        private final ActorUtils context;
 
         ConfigShardLookupTask(final ActorSystem system,
                               final ActorRef replyTo,
-                              final ActorContext context,
+                              final ActorUtils context,
                               final StartConfigShardLookup message,
                               final int lookupMaxRetries) {
             super(replyTo, lookupMaxRetries);
@@ -685,7 +683,7 @@ public class ShardedDataTreeActor extends AbstractUntypedPersistentActor {
                 tryReschedule(null);
             } else {
                 LOG.debug("Local backend for prefix configuration shard lookup successful");
-                replyTo.tell(new Status.Success(null), noSender());
+                replyTo.tell(new Status.Success(null), ActorRef.noSender());
             }
         }
     }
@@ -697,13 +695,13 @@ public class ShardedDataTreeActor extends AbstractUntypedPersistentActor {
 
         private final ActorSystem system;
         private final ActorRef replyTo;
-        private final ActorContext context;
+        private final ActorUtils context;
         private final ClusterWrapper clusterWrapper;
         private final ActorRef shard;
 
         ConfigShardReadinessTask(final ActorSystem system,
                                  final ActorRef replyTo,
-                                 final ActorContext context,
+                                 final ActorUtils context,
                                  final ClusterWrapper clusterWrapper,
                                  final ActorRef shard,
                                  final int lookupMaxRetries) {
@@ -729,7 +727,7 @@ public class ShardedDataTreeActor extends AbstractUntypedPersistentActor {
 
             ask.onComplete(new OnComplete<Object>() {
                 @Override
-                public void onComplete(final Throwable throwable, final Object findLeaderReply) throws Throwable {
+                public void onComplete(final Throwable throwable, final Object findLeaderReply) {
                     if (throwable != null) {
                         tryReschedule(throwable);
                     } else {
@@ -739,7 +737,7 @@ public class ShardedDataTreeActor extends AbstractUntypedPersistentActor {
                             // leader is found, backend seems ready, check if the frontend is ready
                             LOG.debug("{} - Leader for config shard is ready. Ending lookup.",
                                     clusterWrapper.getCurrentMemberName());
-                            replyTo.tell(new Status.Success(null), noSender());
+                            replyTo.tell(new Status.Success(null), ActorRef.noSender());
                         } else {
                             tryReschedule(null);
                         }
@@ -776,8 +774,8 @@ public class ShardedDataTreeActor extends AbstractUntypedPersistentActor {
             return this;
         }
 
-        public ShardedDataTreeActorCreator setClusterWrapper(final ClusterWrapper cluster) {
-            this.cluster = cluster;
+        public ShardedDataTreeActorCreator setClusterWrapper(final ClusterWrapper clusterWrapper) {
+            this.cluster = clusterWrapper;
             return this;
         }
 
@@ -805,8 +803,8 @@ public class ShardedDataTreeActor extends AbstractUntypedPersistentActor {
             return this;
         }
 
-        public ShardedDataTreeActorCreator setLookupTaskMaxRetries(final int maxRetries) {
-            this.maxRetries = maxRetries;
+        public ShardedDataTreeActorCreator setLookupTaskMaxRetries(final int newMaxRetries) {
+            this.maxRetries = newMaxRetries;
             return this;
         }