Class TaskManager<WorkerMetricsT>

java.lang.Object
io.aleph0.yap.core.task.TaskManager<WorkerMetricsT>
All Implemented Interfaces:
Measureable<TaskManager.Metrics<WorkerMetricsT>>

public class TaskManager<WorkerMetricsT> extends Object implements Measureable<TaskManager.Metrics<WorkerMetricsT>>
TaskManager manages the lifecycle of a logical pipeline task, including starting and stopping workers, handling task actions, and notifying lifecycle listeners. It is designed to be used in a multi-threaded environment and provides methods for managing worker threads and task actions.

The TaskManager delegates decision making to a TaskController instance, which is responsible for deciding what actions to take based on the current state of the task and the workers, and the TaskManager is responsible for executing those actions.

Internally, the TaskManager models the task state as a finite state machine with the following states:

                                  
     READY ─► RUNNING ─► COMPLETED
               │  │               
               │  └────► CANCELLED
               │                  
               └───────► FAILED
 
 

To ensure correctness, it enforces that the task can only perform the above transitions between states. (So, for example, the TaskManager will fail if the controller attempts to transition from COMPLETED to RUNNING or from FAILED to CANCELLED.) Within the boundaries of these constraints, the TaskController is completely free to decide what actions to take.