Renamed more things to SupervisorStrategy. Updated more docs. See #1711
This commit is contained in:
parent
66e0a7cf0b
commit
9e15d2062b
19 changed files with 166 additions and 148 deletions
|
|
@ -6,8 +6,8 @@ package akka.docs.actor;
|
|||
//#testkit
|
||||
import akka.actor.ActorRef;
|
||||
import akka.actor.ActorSystem;
|
||||
import akka.actor.FaultHandlingStrategy;
|
||||
import static akka.actor.FaultHandlingStrategy.*;
|
||||
import akka.actor.SupervisorStrategy;
|
||||
import static akka.actor.SupervisorStrategy.*;
|
||||
import akka.actor.OneForOneStrategy;
|
||||
import akka.actor.Props;
|
||||
import akka.actor.Terminated;
|
||||
|
|
@ -38,7 +38,7 @@ public class FaultHandlingTestBase {
|
|||
static public class Supervisor extends UntypedActor {
|
||||
|
||||
//#strategy
|
||||
private static FaultHandlingStrategy strategy = new OneForOneStrategy(new Function<Throwable, Action>() {
|
||||
private static SupervisorStrategy strategy = new OneForOneStrategy(new Function<Throwable, Action>() {
|
||||
@Override
|
||||
public Action apply(Throwable t) {
|
||||
if (t instanceof ArithmeticException) {
|
||||
|
|
@ -54,7 +54,7 @@ public class FaultHandlingTestBase {
|
|||
}, 10, 60000);
|
||||
|
||||
@Override
|
||||
public FaultHandlingStrategy supervisorStrategy() {
|
||||
public SupervisorStrategy supervisorStrategy() {
|
||||
return strategy;
|
||||
}
|
||||
|
||||
|
|
@ -75,7 +75,7 @@ public class FaultHandlingTestBase {
|
|||
static public class Supervisor2 extends UntypedActor {
|
||||
|
||||
//#strategy2
|
||||
private static FaultHandlingStrategy strategy = new OneForOneStrategy(new Function<Throwable, Action>() {
|
||||
private static SupervisorStrategy strategy = new OneForOneStrategy(new Function<Throwable, Action>() {
|
||||
@Override
|
||||
public Action apply(Throwable t) {
|
||||
if (t instanceof ArithmeticException) {
|
||||
|
|
@ -91,7 +91,7 @@ public class FaultHandlingTestBase {
|
|||
}, 10, 60000);
|
||||
|
||||
@Override
|
||||
public FaultHandlingStrategy supervisorStrategy() {
|
||||
public SupervisorStrategy supervisorStrategy() {
|
||||
return strategy;
|
||||
}
|
||||
|
||||
|
|
@ -147,7 +147,7 @@ public class FaultHandlingTestBase {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void mustEmployFaultHandler() {
|
||||
public void mustEmploySupervisorStrategy() {
|
||||
// code here
|
||||
//#testkit
|
||||
EventFilter ex1 = (EventFilter) new ErrorFilter(ArithmeticException.class);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
.. _fault-tolerance-java:
|
||||
|
||||
Fault Handling Strategies (Java)
|
||||
=================================
|
||||
Fault Tolerance (Java)
|
||||
======================
|
||||
|
||||
.. sidebar:: Contents
|
||||
|
||||
|
|
@ -12,8 +12,8 @@ children, and as such each actor defines fault handling supervisor strategy.
|
|||
This strategy cannot be changed afterwards as it is an integral part of the
|
||||
actor system’s structure.
|
||||
|
||||
Creating a Fault Handling Strategy
|
||||
----------------------------------
|
||||
Creating a Supervisor Strategy
|
||||
------------------------------
|
||||
|
||||
For the sake of demonstration let us consider the following strategy:
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ it's located in ``akka.actor.TypedActor``.
|
|||
:include: typed-actor-extension-tools
|
||||
|
||||
.. warning::
|
||||
|
||||
|
||||
Same as not exposing ``this`` of an Akka Actor, it's important not to expose ``this`` of a Typed Actor,
|
||||
instead you should pass the external proxy reference, which is obtained from within your Typed Actor as
|
||||
``TypedActor.self()``, this is your external identity, as the ``ActorRef`` is the external identity of
|
||||
|
|
@ -127,7 +127,7 @@ Request-reply-with-future message send
|
|||
.. includecode:: code/akka/docs/actor/TypedActorDocTestBase.java
|
||||
:include: typed-actor-call-future
|
||||
|
||||
This call is asynchronous, and the Future returned can be used for asynchronous composition.
|
||||
This call is asynchronous, and the Future returned can be used for asynchronous composition.
|
||||
|
||||
Stopping Typed Actors
|
||||
---------------------
|
||||
|
|
@ -153,6 +153,13 @@ you can create child Typed Actors by invoking ``typedActorOf(..)`` on that.
|
|||
|
||||
This also works for creating child Typed Actors in regular Akka Actors.
|
||||
|
||||
Supervisor Strategy
|
||||
-------------------
|
||||
|
||||
By having your Typed Actor implementation class implement ``TypedActor.Supervisor``
|
||||
you can define the strategy to use for supervising child actors, as described in
|
||||
:ref:`supervision` and :ref:`fault-tolerance-java`.
|
||||
|
||||
Lifecycle callbacks
|
||||
-------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -129,6 +129,7 @@ In addition, it offers:
|
|||
|
||||
* :obj:`getSelf()` reference to the :class:`ActorRef` of the actor
|
||||
* :obj:`getSender()` reference sender Actor of the last received message, typically used as described in :ref:`UntypedActor.Reply`
|
||||
* :obj:`supervisorStrategy()` user overridable definition the strategy to use for supervising child actors
|
||||
* :obj:`getContext()` exposes contextual information for the actor and the current message, such as:
|
||||
|
||||
* factory methods to create child actors (:meth:`actorOf`)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue