Jump to: navigation, search

Difference between revisions of "TaskFlow/States of Task and Flow"

(Appendix A: Diagrams)
(wordy description of flow states; put flow states before task states)
Line 1: Line 1:
 +
== Flow States ==
 +
 +
[[File:Tf flow state diagram.png|150px|thumb|Flow state diagram]]
 +
 +
Flow starts its life in '''PENDING''' state. Then, when it is run, it transitions to '''RUNNING''' state. When all tasks are finished successfully, flow transitions to '''SUCCESS''' state. In case of failure, flow is reverted; when it happens, flow first transitions to '''REVERTING''' state, then revert happens, then flow transitions to REVERTED state, and then to '''FAILURE'''.
 +
 +
Transition from '''REVERTED''' to '''FAILURE''' state happens immediately. The main purpose of '''REVERTED''' state is notifications.
 +
 +
In '''RUNNING''' and '''REVERTING''' state flow can be interrupted. When this happens, flow transitions to '''INTERRUPTED''' state. From that state, flow can run on (transition back to '''RUNNING''') or be reverted (and transition to '''REVERTED''' state).
 +
 +
There is also special flow state, '''RESUMING''' (not shown on diagram). Any flow is in this state when it is resumed (loaded) from storage. '''RESUMING''' state is never saved to storage and exists only for notifications.
 +
 +
<br clear=all>
 +
 
== Task States ==
 
== Task States ==
  
Line 10: Line 24:
  
 
Transition from '''REVERTED''' to '''PENDING''' state happens immediately. The main purpose of '''REVERTED''' state is notifications.
 
Transition from '''REVERTED''' to '''PENDING''' state happens immediately. The main purpose of '''REVERTED''' state is notifications.
 
'''Discuss''': it may be worth to perform transition from '''REVERTED''' to '''PENDING''' automatically when resuming flow from storage.
 
 
<br clear=all>
 
 
== Flow States ==
 
 
[[File:Tf flow state diagram.png|150px|thumb|Flow state diagram]]
 
 
'''TODO(imelnikov)''' There are more flow states defined then present on the diagram: it does not include '''RESUMING''', '''CANCELED''', '''INCOMPLETE'''. Still need to figure out their precise semantics.
 
  
 
<br clear=all>
 
<br clear=all>
Line 25: Line 29:
 
== Appendix A: Diagrams ==
 
== Appendix A: Diagrams ==
  
The diagrams were drawn using [[http://plantuml.sourceforge.net/ PlantUML]]. You can re-create them offline or online [[http://www.plantuml.com/plantuml/form here]].
+
The diagrams were drawn using [http://plantuml.sourceforge.net/ PlantUML]. You can re-create them offline or online [http://www.plantuml.com/plantuml/form here].
  
 
Source for task state diagram:
 
Source for task state diagram:

Revision as of 11:24, 11 September 2013

Flow States

Flow state diagram

Flow starts its life in PENDING state. Then, when it is run, it transitions to RUNNING state. When all tasks are finished successfully, flow transitions to SUCCESS state. In case of failure, flow is reverted; when it happens, flow first transitions to REVERTING state, then revert happens, then flow transitions to REVERTED state, and then to FAILURE.

Transition from REVERTED to FAILURE state happens immediately. The main purpose of REVERTED state is notifications.

In RUNNING and REVERTING state flow can be interrupted. When this happens, flow transitions to INTERRUPTED state. From that state, flow can run on (transition back to RUNNING) or be reverted (and transition to REVERTED state).

There is also special flow state, RESUMING (not shown on diagram). Any flow is in this state when it is resumed (loaded) from storage. RESUMING state is never saved to storage and exists only for notifications.


Task States

Task state diagram

When task just added to the flow, it is in PENDING state, which means it can be executed or waits for all of task it depends on to complete. Then, when task is executed, it transitions to RUNNING state, and stays in it until its execute() method returns. When task is finished, it transitions to SUCCESS state if it was finished successfully, or to FAILURE state if not.

When flow is reverted, all tasks in PENDING state are left as is; tasks from all the other states transition to REVERTING state, and their revert() method is called. When that method returns, task transitions to REVERTED state, and then to PENDING.

Transition from RUNNING to REVERTING state happens when task was interrupted while running, and then revert occurs. This may take place e.g. when daemon is killed while running the task.

Transition from REVERTED to PENDING state happens immediately. The main purpose of REVERTED state is notifications.


Appendix A: Diagrams

The diagrams were drawn using PlantUML. You can re-create them offline or online here.

Source for task state diagram:

 [*] --> PENDING
 PENDING --> RUNNING
 RUNNING --> SUCCESS
 RUNNING --> FAILURE
 RUNNING --> REVERTING
 SUCCESS --> REVERTING
 FAILURE --> REVERTING
 REVERTING -up-> REVERTED
 REVERTING -up-> FAILURE
 REVERTED -up-> PENDING

Source for flow state diagram:

 [*] --> PENDING
 PENDING --> RUNNING
 RUNNING --> SUCCESS
 RUNNING --> REVERTING : failure
 RUNNING --> INTERRUPTED
 REVERTING --> INTERRUPTED
 INTERRUPTED -l-> RUNNING
 INTERRUPTED --> REVERTING
 REVERTING --> REVERTED
 REVERTED --> FAILURE