Package org.apache.pekko.actor
Class OneForOneStrategy
java.lang.Object
org.apache.pekko.actor.SupervisorStrategy
org.apache.pekko.actor.OneForOneStrategy
- All Implemented Interfaces:
Serializable,scala.Equals,scala.Product
- Direct Known Subclasses:
ClusterMetricsStrategy
Applies the fault handling
Directive (Resume, Restart, Stop) specified in the Decider
to the child actor that failed, as opposed to pekko.actor.AllForOneStrategy that applies
it to all children.
param: maxNrOfRetries the number of times a child actor is allowed to be restarted, negative value means no limit
if the duration is infinite. If the limit is exceeded the child actor is stopped
param: withinTimeRange duration of the time window for maxNrOfRetries, Duration.Inf means no window
param: decider mapping from Throwable to pekko.actor.SupervisorStrategy.Directive, you can also use a
Seq of Throwables which maps the given Throwables to restarts, otherwise escalates.
param: loggingEnabled the strategy logs the failure if this is enabled (true), by default it is enabled
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.pekko.actor.SupervisorStrategy
SupervisorStrategy.Directive, SupervisorStrategy.Escalate$, SupervisorStrategy.Restart$, SupervisorStrategy.Resume$, SupervisorStrategy.Stop$ -
Constructor Summary
ConstructorsConstructorDescriptionOneForOneStrategy(boolean loggingEnabled, scala.PartialFunction<Throwable, SupervisorStrategy.Directive> decider) OneForOneStrategy(int maxNrOfRetries, Duration withinTimeRange, Iterable<Class<? extends Throwable>> trapExit) Java APIOneForOneStrategy(int maxNrOfRetries, Duration withinTimeRange, Function<Throwable, SupervisorStrategy.Directive> decider) Java APIOneForOneStrategy(int maxNrOfRetries, Duration withinTimeRange, Function<Throwable, SupervisorStrategy.Directive> decider, boolean loggingEnabled) Java APIOneForOneStrategy(int maxNrOfRetries, Duration withinTimeRange, scala.PartialFunction<Throwable, SupervisorStrategy.Directive> decider) Java API: compatible with lambda expressionsOneForOneStrategy(int maxNrOfRetries, scala.concurrent.duration.Duration withinTimeRange, boolean loggingEnabled, scala.PartialFunction<Throwable, SupervisorStrategy.Directive> decider) OneForOneStrategy(int maxNrOfRetries, scala.concurrent.duration.Duration withinTimeRange, Iterable<Class<? extends Throwable>> trapExit) Java APIOneForOneStrategy(int maxNrOfRetries, scala.concurrent.duration.Duration withinTimeRange, Function<Throwable, SupervisorStrategy.Directive> decider) Java APIOneForOneStrategy(int maxNrOfRetries, scala.concurrent.duration.Duration withinTimeRange, Function<Throwable, SupervisorStrategy.Directive> decider, boolean loggingEnabled) Java APIOneForOneStrategy(int maxNrOfRetries, scala.concurrent.duration.Duration withinTimeRange, scala.PartialFunction<Throwable, SupervisorStrategy.Directive> decider) Java API: compatible with lambda expressionsOneForOneStrategy(scala.PartialFunction<Throwable, SupervisorStrategy.Directive> decider) Java API: Restart an infinite number of times. -
Method Summary
Modifier and TypeMethodDescriptionstatic intstatic scala.concurrent.duration.Durationstatic booleanstatic OneForOneStrategyapply(int maxNrOfRetries, scala.concurrent.duration.Duration withinTimeRange, boolean loggingEnabled, scala.PartialFunction<Throwable, SupervisorStrategy.Directive> decider) static intstatic scala.concurrent.duration.Durationstatic booleanbooleancopy(int maxNrOfRetries, scala.concurrent.duration.Duration withinTimeRange, boolean loggingEnabled, scala.PartialFunction<Throwable, SupervisorStrategy.Directive> decider) intscala.concurrent.duration.Durationbooleanscala.PartialFunction<Throwable,SupervisorStrategy.Directive> decider()Returns the Decider that is associated with this SupervisorStrategy.booleanvoidhandleChildTerminated(ActorContext context, ActorRef child, scala.collection.Iterable<ActorRef> children) This method is called after the child has been removed from the set of children.inthashCode()booleanLogging of actor failures is done when this istrue.intvoidprocessFailure(ActorContext context, boolean restart, ActorRef child, Throwable cause, ChildRestartStats stats, scala.collection.Iterable<ChildRestartStats> children) This method is called to act on the failure of a child: restart if the flag is true, stop otherwise.intproductElement(int x$1) productElementName(int x$1) scala.collection.Iterator<Object>toString()unapply(OneForOneStrategy x$0) scala.concurrent.duration.DurationwithMaxNrOfRetries(int maxNrOfRetries) Methods inherited from class org.apache.pekko.actor.SupervisorStrategy
defaultDecider, defaultStrategy, escalate, handleFailure, logFailure, makeDecider, makeDecider, makeDecider, makeDecider, restart, restart, restartChild, resume, resume, resumeChild, seqCauseDirective2Decider, seqThrowable2Decider, stop, stop, stoppingStrategyMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface scala.Product
productElementNames
-
Constructor Details
-
OneForOneStrategy
public OneForOneStrategy(int maxNrOfRetries, scala.concurrent.duration.Duration withinTimeRange, boolean loggingEnabled, scala.PartialFunction<Throwable, SupervisorStrategy.Directive> decider) -
OneForOneStrategy
public OneForOneStrategy(int maxNrOfRetries, scala.concurrent.duration.Duration withinTimeRange, Function<Throwable, SupervisorStrategy.Directive> decider, boolean loggingEnabled) Java API -
OneForOneStrategy
public OneForOneStrategy(int maxNrOfRetries, Duration withinTimeRange, Function<Throwable, SupervisorStrategy.Directive> decider, boolean loggingEnabled) Java API -
OneForOneStrategy
public OneForOneStrategy(int maxNrOfRetries, scala.concurrent.duration.Duration withinTimeRange, Function<Throwable, SupervisorStrategy.Directive> decider) Java API -
OneForOneStrategy
public OneForOneStrategy(int maxNrOfRetries, Duration withinTimeRange, Function<Throwable, SupervisorStrategy.Directive> decider) Java API -
OneForOneStrategy
public OneForOneStrategy(int maxNrOfRetries, scala.concurrent.duration.Duration withinTimeRange, Iterable<Class<? extends Throwable>> trapExit) Java API -
OneForOneStrategy
public OneForOneStrategy(int maxNrOfRetries, Duration withinTimeRange, Iterable<Class<? extends Throwable>> trapExit) Java API -
OneForOneStrategy
public OneForOneStrategy(int maxNrOfRetries, scala.concurrent.duration.Duration withinTimeRange, scala.PartialFunction<Throwable, SupervisorStrategy.Directive> decider) Java API: compatible with lambda expressions -
OneForOneStrategy
public OneForOneStrategy(int maxNrOfRetries, Duration withinTimeRange, scala.PartialFunction<Throwable, SupervisorStrategy.Directive> decider) Java API: compatible with lambda expressions -
OneForOneStrategy
public OneForOneStrategy(boolean loggingEnabled, scala.PartialFunction<Throwable, SupervisorStrategy.Directive> decider) -
OneForOneStrategy
Java API: Restart an infinite number of times. Compatible with lambda expressions.
-
-
Method Details
-
$lessinit$greater$default$1
public static int $lessinit$greater$default$1() -
$lessinit$greater$default$2
public static scala.concurrent.duration.Duration $lessinit$greater$default$2() -
$lessinit$greater$default$3
public static boolean $lessinit$greater$default$3() -
apply
public static OneForOneStrategy apply(int maxNrOfRetries, scala.concurrent.duration.Duration withinTimeRange, boolean loggingEnabled, scala.PartialFunction<Throwable, SupervisorStrategy.Directive> decider) -
apply$default$1
public static int apply$default$1() -
apply$default$2
public static scala.concurrent.duration.Duration apply$default$2() -
apply$default$3
public static boolean apply$default$3() -
unapply
public static scala.Option<scala.Tuple3<Object,scala.concurrent.duration.Duration, unapplyObject>> (OneForOneStrategy x$0) -
maxNrOfRetries
public int maxNrOfRetries() -
withinTimeRange
public scala.concurrent.duration.Duration withinTimeRange() -
loggingEnabled
public boolean loggingEnabled()Description copied from class:SupervisorStrategyLogging of actor failures is done when this istrue.- Overrides:
loggingEnabledin classSupervisorStrategy
-
decider
Description copied from class:SupervisorStrategyReturns the Decider that is associated with this SupervisorStrategy. The Decider is invoked by the default implementation ofhandleFailureto obtain the Directive to be applied.- Specified by:
deciderin classSupervisorStrategy
-
withMaxNrOfRetries
-
handleChildTerminated
public void handleChildTerminated(ActorContext context, ActorRef child, scala.collection.Iterable<ActorRef> children) Description copied from class:SupervisorStrategyThis method is called after the child has been removed from the set of children. It does not need to do anything special. Exceptions thrown from this method do NOT make the actor fail if this happens during termination.- Specified by:
handleChildTerminatedin classSupervisorStrategy
-
processFailure
public void processFailure(ActorContext context, boolean restart, ActorRef child, Throwable cause, ChildRestartStats stats, scala.collection.Iterable<ChildRestartStats> children) Description copied from class:SupervisorStrategyThis method is called to act on the failure of a child: restart if the flag is true, stop otherwise.- Specified by:
processFailurein classSupervisorStrategy
-
copy
public OneForOneStrategy copy(int maxNrOfRetries, scala.concurrent.duration.Duration withinTimeRange, boolean loggingEnabled, scala.PartialFunction<Throwable, SupervisorStrategy.Directive> decider) -
copy$default$1
public int copy$default$1() -
copy$default$2
public scala.concurrent.duration.Duration copy$default$2() -
copy$default$3
public boolean copy$default$3() -
productPrefix
- Specified by:
productPrefixin interfacescala.Product
-
productArity
public int productArity()- Specified by:
productArityin interfacescala.Product
-
productElement
- Specified by:
productElementin interfacescala.Product
-
productIterator
- Specified by:
productIteratorin interfacescala.Product
-
canEqual
- Specified by:
canEqualin interfacescala.Equals
-
productElementName
- Specified by:
productElementNamein interfacescala.Product
-
hashCode
public int hashCode() -
toString
-
equals
-