Enum Class DefaultTaskController.TaskState
java.lang.Object
java.lang.Enum<DefaultTaskController.TaskState>
io.aleph0.yap.core.task.DefaultTaskController.TaskState
- All Implemented Interfaces:
Serializable,Comparable<DefaultTaskController.TaskState>,Constable
- Enclosing class:
DefaultTaskController<InputT,OutputT>
The internal state of a task. The task starts in the
READY state. The
controller then moves the task through states according to the various events that occur.-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionThe task is done processing and has shut down.The user hasrequested cancellationand the task is in the process of shutting down.The task is done processing and has shut down.The task is done processing and is in the process of shutting down.The task is done processing and has shut down.One or more workers havecompleted exceptionallyand the task is in the process of shutting down.The initial state of the task.The task is running. -
Method Summary
Modifier and TypeMethodDescriptiongetPhase()abstract DefaultTaskController.TaskStateto(DefaultTaskController.TaskState target) Validate the transition from this state to the target state.Returns the enum constant of this class with the specified name.static DefaultTaskController.TaskState[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
READY
The initial state of the task.On task start, the controller immediately moves toRUNNING. -
RUNNING
The task is running. One or more worker has been started, no workers have completed normally, no workers have completed exceptionally, and the user has not requested cancellation. The controller stays in this state until one of the following events:- If
a worker completes normally, then move toCOMPLETING - If
a worker completes exceptionally, then move toFAILING. - If
the user requests cancellation, then move toCANCELING.
- If
-
COMPLETING
The task is done processing and is in the process of shutting down. The following conditions must be true:- At least one worker has completed normally
- At least one worker is still running
- No workers have completed exceptionally
- The user has not requested cancellation
The controller stays in this state until one of the following events:
- If the last worker
completes normally, then move toCOMPLETED. - If a worker
completes exceptionally, then move toFAILING. If it is the last worker, then move toFAILEDinstead. - If
the user requests cancellation, then move toCANCELING.
-
CANCELING
The user hasrequested cancellationand the task is in the process of shutting down. The following conditions must be true:- The user has requested cancellation
- At least one worker is still running
- No workers have completed exceptionally
The controller stays in this state until one of the following events:
- If the last worker
completes normallyorstops, then move toCANCELED. - If a worker
completes exceptionally, then move toFAILING. If it is the last worker, then move toFAILEDinstead.
-
FAILING
One or more workers havecompleted exceptionallyand the task is in the process of shutting down. The following conditions must be true:- At least one worker has completed exceptionally
- At least one worker is still running
The controller stays in this state until one of the following events:
- The last worker
normally,exceptionally, orstops, then move toFAILED.
-
COMPLETED
The task is done processing and has shut down. The user did not request cancellation, and all workers have completed normally. -
CANCELED
The task is done processing and has shut down. The user requested cancellation, and all workers either completed normally or stopped. -
FAILED
The task is done processing and has shut down. At least one worker completed exceptionally.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
getPhase
-
to
Validate the transition from this state to the target state. The controller will call this method to validate the transition before moving to the target state. If the transition is valid, the method will return the target state. If the transition is invalid, the method will throw anIllegalStateException.- Parameters:
target- the target state- Returns:
- the target state, if the transition is valid
- Throws:
IllegalStateException- if the transition is invalid
-