Package akka.actor

Class OneForOneStrategy

  • All Implemented Interfaces:
    java.io.Serializable, scala.Equals, scala.Product
    Direct Known Subclasses:
    ClusterMetricsStrategy

    public class OneForOneStrategy
    extends SupervisorStrategy
    implements scala.Product, java.io.Serializable
    Applies the fault handling Directive (Resume, Restart, Stop) specified in the Decider to the child actor that failed, as opposed to 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 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:
    Serialized Form
    • Constructor Detail

      • OneForOneStrategy

        public OneForOneStrategy​(int maxNrOfRetries,
                                 scala.concurrent.duration.Duration withinTimeRange,
                                 boolean loggingEnabled,
                                 scala.PartialFunction<java.lang.Throwable,​SupervisorStrategy.Directive> decider)
      • OneForOneStrategy

        public OneForOneStrategy​(int maxNrOfRetries,
                                 scala.concurrent.duration.Duration withinTimeRange,
                                 Function<java.lang.Throwable,​SupervisorStrategy.Directive> decider,
                                 boolean loggingEnabled)
        Java API
      • OneForOneStrategy

        public OneForOneStrategy​(int maxNrOfRetries,
                                 java.time.Duration withinTimeRange,
                                 Function<java.lang.Throwable,​SupervisorStrategy.Directive> decider,
                                 boolean loggingEnabled)
        Java API
      • OneForOneStrategy

        public OneForOneStrategy​(int maxNrOfRetries,
                                 scala.concurrent.duration.Duration withinTimeRange,
                                 Function<java.lang.Throwable,​SupervisorStrategy.Directive> decider)
        Java API
      • OneForOneStrategy

        public OneForOneStrategy​(int maxNrOfRetries,
                                 java.time.Duration withinTimeRange,
                                 Function<java.lang.Throwable,​SupervisorStrategy.Directive> decider)
        Java API
      • OneForOneStrategy

        public OneForOneStrategy​(int maxNrOfRetries,
                                 scala.concurrent.duration.Duration withinTimeRange,
                                 java.lang.Iterable<java.lang.Class<? extends java.lang.Throwable>> trapExit)
        Java API
      • OneForOneStrategy

        public OneForOneStrategy​(int maxNrOfRetries,
                                 java.time.Duration withinTimeRange,
                                 java.lang.Iterable<java.lang.Class<? extends java.lang.Throwable>> trapExit)
        Java API
      • OneForOneStrategy

        public OneForOneStrategy​(int maxNrOfRetries,
                                 scala.concurrent.duration.Duration withinTimeRange,
                                 scala.PartialFunction<java.lang.Throwable,​SupervisorStrategy.Directive> decider)
        Java API: compatible with lambda expressions
      • OneForOneStrategy

        public OneForOneStrategy​(int maxNrOfRetries,
                                 java.time.Duration withinTimeRange,
                                 scala.PartialFunction<java.lang.Throwable,​SupervisorStrategy.Directive> decider)
        Java API: compatible with lambda expressions
      • OneForOneStrategy

        public OneForOneStrategy​(boolean loggingEnabled,
                                 scala.PartialFunction<java.lang.Throwable,​SupervisorStrategy.Directive> decider)
      • OneForOneStrategy

        public OneForOneStrategy​(scala.PartialFunction<java.lang.Throwable,​SupervisorStrategy.Directive> decider)
        Java API: Restart an infinite number of times. Compatible with lambda expressions.
    • Method Detail

      • $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<java.lang.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<java.lang.Object,​scala.concurrent.duration.Duration,​java.lang.Object>> unapply​(OneForOneStrategy x$0)
      • maxNrOfRetries

        public int maxNrOfRetries()
      • withinTimeRange

        public scala.concurrent.duration.Duration withinTimeRange()
      • decider

        public scala.PartialFunction<java.lang.Throwable,​SupervisorStrategy.Directive> decider()
        Description copied from class: SupervisorStrategy
        Returns the Decider that is associated with this SupervisorStrategy. The Decider is invoked by the default implementation of handleFailure to obtain the Directive to be applied.
        Specified by:
        decider in class SupervisorStrategy
      • withMaxNrOfRetries

        public OneForOneStrategy withMaxNrOfRetries​(int maxNrOfRetries)
      • handleChildTerminated

        public void handleChildTerminated​(ActorContext context,
                                          ActorRef child,
                                          scala.collection.Iterable<ActorRef> children)
        Description copied from class: SupervisorStrategy
        This 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:
        handleChildTerminated in class SupervisorStrategy
      • copy

        public OneForOneStrategy copy​(int maxNrOfRetries,
                                      scala.concurrent.duration.Duration withinTimeRange,
                                      boolean loggingEnabled,
                                      scala.PartialFunction<java.lang.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

        public java.lang.String productPrefix()
        Specified by:
        productPrefix in interface scala.Product
      • productArity

        public int productArity()
        Specified by:
        productArity in interface scala.Product
      • productElement

        public java.lang.Object productElement​(int x$1)
        Specified by:
        productElement in interface scala.Product
      • productIterator

        public scala.collection.Iterator<java.lang.Object> productIterator()
        Specified by:
        productIterator in interface scala.Product
      • canEqual

        public boolean canEqual​(java.lang.Object x$1)
        Specified by:
        canEqual in interface scala.Equals
      • productElementName

        public java.lang.String productElementName​(int x$1)
        Specified by:
        productElementName in interface scala.Product
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object x$1)
        Specified by:
        equals in interface scala.Equals
        Overrides:
        equals in class java.lang.Object