Interface PipelineController
- All Known Implementing Classes:
DefaultPipelineController
public interface PipelineController
The PipelineController is responsible for controlling the lifecycle of a
Pipeline. The
PipelineManager will call the methods of this interface to notify the PipelineController
of various events that occur during the lifecycle of a pipeline, and the PipelineController will
return the list of PipelineActions to perform in response to those events. The
TaskController is generally free to decide how to respond to these events, for example
implementing task-level retry logic or implementing a circuit-breaker pattern, but to ensure
correctness, it must conform to the high-level task lifecycle defined by the
PipelineManager.-
Method Summary
Modifier and TypeMethodDescriptionThe maximum amount of time to wait for a lifecycle event, after whichonHeartbeat()will be called.Called when the pipeline has been requested to be cancelled.Called when no lifecycle events have occurred withinthe heartbeat interval.voidCalled when the pipeline has been cancelled.voidCalled when the pipeline has been completed.voidCalled when the pipeline has failed.Called when the pipeline has been started.Called when a task has been cancelled.Called when a task has been completed.onTaskFailed(String id, Throwable error) Called when a task has failed.onTaskStarted(String id) Called when a task has been started.
-
Method Details
-
onPipelineStarted
List<PipelineAction> onPipelineStarted()Called when the pipeline has been started. Called as the first event only.- Returns:
- the next actions to perform
-
onTaskStarted
Called when a task has been started. Called for each task as the first event.- Parameters:
id- the id of the task- Returns:
- the next actions to perform
-
onTaskCompleted
Called when a task has been completed. No more events will be sent for this task.- Parameters:
id- the id of the task- Returns:
- the next actions to perform
-
onTaskCancelled
Called when a task has been cancelled. No more events will be sent for this task.- Parameters:
id- the id of the task- Returns:
- the next actions to perform
-
onTaskFailed
Called when a task has failed. No more events will be sent for this task.- Parameters:
id- the id of the taskerror- the error that caused the task to fail- Returns:
- the next actions to perform
-
onHeartbeat
List<PipelineAction> onHeartbeat()Called when no lifecycle events have occurred withinthe heartbeat interval. This ensures that the controller has periodic access to execute actions even if no lifecycle events are occurring, for example to time out tasks or to perform maintenance tasks.- Returns:
- the next action to perform
-
getHeartbeatInterval
Duration getHeartbeatInterval()The maximum amount of time to wait for a lifecycle event, after whichonHeartbeat()will be called. -
onCancelRequested
List<PipelineAction> onCancelRequested()Called when the pipeline has been requested to be cancelled. This is a request, not a command, and the pipeline may choose to ignore it.- Returns:
- the next actions to perform
-
onPipelineCompleted
void onPipelineCompleted()Called when the pipeline has been completed. This is the last event that will be called. -
onPipelineFailed
Called when the pipeline has failed. This is the last event that will be called. -
onPipelineCancelled
void onPipelineCancelled()Called when the pipeline has been cancelled. This is the last event that will be called.
-