Add supervisor to EOS singleton actor 57/100357/3
authorShibu Vijayakumar <shibu.vijayakumar@infosys.com>
Fri, 1 Apr 2022 18:14:34 +0000 (18:14 +0000)
committerRobert Varga <robert.varga@pantheon.tech>
Sun, 3 Apr 2022 20:43:29 +0000 (22:43 +0200)
The actor may fail, for example due to AskTimeoutException. This still
needs to be investigated, but mitigate the failure by adding an
OwnerSupervisor to restart it on failure.

JIRA: CONTROLLER-2035
Change-Id: I2dafaa35804357415d9aaa5400372cfd8e54b85b
Signed-off-by: Shibu Vijayakumar <shibu.vijayakumar@infosys.com>
opendaylight/md-sal/eos-dom-akka/src/main/java/org/opendaylight/controller/eos/akka/bootstrap/EOSMain.java

index 83d28823ad81453385936eef754ea563e1c9cfcd..dab699e394d5fc65bca8ab681d1cefdc9b045136 100644 (file)
@@ -9,6 +9,7 @@ package org.opendaylight.controller.eos.akka.bootstrap;
 
 import akka.actor.typed.ActorRef;
 import akka.actor.typed.Behavior;
 
 import akka.actor.typed.ActorRef;
 import akka.actor.typed.Behavior;
+import akka.actor.typed.SupervisorStrategy;
 import akka.actor.typed.javadsl.AbstractBehavior;
 import akka.actor.typed.javadsl.ActorContext;
 import akka.actor.typed.javadsl.Behaviors;
 import akka.actor.typed.javadsl.AbstractBehavior;
 import akka.actor.typed.javadsl.ActorContext;
 import akka.actor.typed.javadsl.Behaviors;
@@ -47,8 +48,8 @@ public final class EOSMain extends AbstractBehavior<BootstrapCommand> {
         final ClusterSingleton clusterSingleton = ClusterSingleton.get(context.getSystem());
         // start the initial sync behavior that switches to the regular one after syncing
         ownerSupervisor = clusterSingleton.init(
         final ClusterSingleton clusterSingleton = ClusterSingleton.get(context.getSystem());
         // start the initial sync behavior that switches to the regular one after syncing
         ownerSupervisor = clusterSingleton.init(
-                SingletonActor.of(IdleSupervisor.create(iidCodec), "OwnerSupervisor"));
-
+                SingletonActor.of(Behaviors.supervise(IdleSupervisor.create(iidCodec))
+                        .onFailure(SupervisorStrategy.restart()), "OwnerSupervisor"));
         candidateRegistry = context.spawn(CandidateRegistryInit.create(ownerSupervisor), "CandidateRegistry");
 
         ownerStateChecker = context.spawn(OwnerStateChecker.create(role, ownerSupervisor, iidCodec),
         candidateRegistry = context.spawn(CandidateRegistryInit.create(ownerSupervisor), "CandidateRegistry");
 
         ownerStateChecker = context.spawn(OwnerStateChecker.create(role, ownerSupervisor, iidCodec),