Back to Akka

Diagrams of the Fault Tolerance Sample

akka-docs/src/main/paradox/fault-tolerance-sample.md

10.1.03.9 KB
Original Source

<a id="fault-tolerance-sample"></a>

Diagrams of the Fault Tolerance Sample

The above diagram illustrates the normal message flow.

Normal flow:

StepDescription
1The progress Listener starts the work.
2The Worker schedules work by sending Do messages periodically to itself
3, 4, 5When receiving Do the Worker tells the CounterService to increment the counter, three times. The Increment message is forwarded to the Counter, which updates its counter variable and sends current value to the Storage.
6, 7The Worker asks the CounterService of current value of the counter and pipes the result back to the Listener.

The above diagram illustrates what happens in case of storage failure.

Failure flow:

StepDescription
1The Storage throws StorageException.
2The CounterService is supervisor of the Storage and restarts the Storage when StorageException is thrown.
3, 4, 5, 6The Storage continues to fail and is restarted.
7After 3 failures and restarts within 5 seconds the Storage is stopped by its supervisor, i.e. the CounterService.
8The CounterService is also watching the Storage for termination and receives the Terminated message when the Storage has been stopped ...
9, 10, 11and tells the Counter that there is no Storage.
12The CounterService schedules a Reconnect message to itself.
13, 14When it receives the Reconnect message it creates a new Storage ...
15, 16and tells the Counter to use the new Storage

Full Source Code of the Fault Tolerance Sample

Scala : @@snip FaultHandlingDocSample.scala { #all }

Java : @@snip FaultHandlingDocSample.java { #all }