Skip to content

Commit 0332745

Browse files
authored
fix rcActor supervisor (#652)
1 parent a11cc30 commit 0332745

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

mantis-control-plane/mantis-control-plane-server/src/main/java/io/mantisrx/master/resourcecluster/ResourceClusterActor.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,11 @@
2020

2121
import akka.actor.AbstractActorWithTimers;
2222
import akka.actor.ActorRef;
23+
import akka.actor.OneForOneStrategy;
2324
import akka.actor.Props;
2425
import akka.actor.Status;
26+
import akka.actor.SupervisorStrategy;
27+
import akka.japi.pf.DeciderBuilder;
2528
import akka.japi.pf.ReceiveBuilder;
2629
import com.netflix.spectator.api.Tag;
2730
import com.netflix.spectator.api.TagList;
@@ -95,6 +98,24 @@
9598
@ToString(of = {"clusterID"})
9699
@Slf4j
97100
class ResourceClusterActor extends AbstractActorWithTimers {
101+
/**
102+
* For ResourceClusterActor instances, we need to ensure they are always running after encountering error so that
103+
* TaskExecutors can still remain connected. If there is a fatal error that needs to be escalated to terminate the
104+
* whole system/leader you can define a fatal exception type and override its behavior to
105+
* SupervisorStrategy.escalate() instead.
106+
*/
107+
private static SupervisorStrategy resourceClusterActorStrategy =
108+
new OneForOneStrategy(
109+
3,
110+
Duration.ofSeconds(60),
111+
DeciderBuilder
112+
.match(Exception.class, e -> SupervisorStrategy.restart())
113+
.build());
114+
115+
@Override
116+
public SupervisorStrategy supervisorStrategy() {
117+
return resourceClusterActorStrategy;
118+
}
98119

99120
private final Duration heartbeatTimeout;
100121
private final Duration assignmentTimeout;

0 commit comments

Comments
 (0)