Class PipelinedStageExecution
- java.lang.Object
-
- io.trino.execution.scheduler.PipelinedStageExecution
-
- All Implemented Interfaces:
StageExecution
public class PipelinedStageExecution extends Object implements StageExecution
This class is designed to facilitate the pipelined mode of execution.In the pipeline mode the tasks are executed in all-or-nothing fashion with all the intermediate data being "piped" between stages in a streaming way.
This class has two main responsibilities:
1. Linking pipelined stages together. If a new task is scheduled the implementation notifies upstream stages to add an additional output buffer for the task as well as it notifies the downstream stage to update a list of source tasks. It is also responsible of notifying both upstream and downstream stages when no more tasks will be added.
2. Facilitates state transitioning for a pipelined stage execution according to the all-or-noting model. If any of the tasks fail the implementation is responsible for terminating all remaining tasks as well as propagating the original error. If all the tasks finish successfully the implementation is responsible for notifying the scheduler about a successful completion of a given stage.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface io.trino.execution.scheduler.StageExecution
StageExecution.State
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidabort()voidaddCompletedDriverGroupsChangedListener(Consumer<Set<Lifespan>> newlyCompletedDriverGroupConsumer)voidaddStateChangeListener(StateMachine.StateChangeListener<StageExecution.State> stateChangeListener)Listener is always notified asynchronously using a dedicated notification thread pool so, care should be taken to avoid leakingthiswhen adding a listener in a constructor.voidbeginScheduling()voidcancel()static PipelinedStageExecutioncreatePipelinedStageExecution(SqlStage stage, Map<PlanFragmentId,io.trino.execution.scheduler.OutputBufferManager> outputBufferManagers, TaskLifecycleListener taskLifecycleListener, FailureDetector failureDetector, Executor executor, Optional<int[]> bucketToPartition, int attempt)voidfail(Throwable failureCause)voidfailTask(TaskId taskId, Throwable failureCause)List<RemoteTask>getAllTasks()intgetAttemptId()Optional<ExecutionFailureInfo>getFailureCause()PlanFragmentgetFragment()StageIdgetStageId()StageExecution.StategetState()TaskLifecycleListenergetTaskLifecycleListener()List<TaskStatus>getTaskStatuses()booleanisAnyTaskBlocked()voidrecordGetSplitTime(long start)Optional<RemoteTask>scheduleTask(InternalNode node, int partition, com.google.common.collect.Multimap<PlanNodeId,Split> initialSplits, com.google.common.collect.Multimap<PlanNodeId,Lifespan> noMoreSplitsForLifespan)voidschedulingComplete()voidschedulingComplete(PlanNodeId partitionedSource)voidtransitionToSchedulingSplits()
-
-
-
Method Detail
-
createPipelinedStageExecution
public static PipelinedStageExecution createPipelinedStageExecution(SqlStage stage, Map<PlanFragmentId,io.trino.execution.scheduler.OutputBufferManager> outputBufferManagers, TaskLifecycleListener taskLifecycleListener, FailureDetector failureDetector, Executor executor, Optional<int[]> bucketToPartition, int attempt)
-
getState
public StageExecution.State getState()
- Specified by:
getStatein interfaceStageExecution
-
addStateChangeListener
public void addStateChangeListener(StateMachine.StateChangeListener<StageExecution.State> stateChangeListener)
Listener is always notified asynchronously using a dedicated notification thread pool so, care should be taken to avoid leakingthiswhen adding a listener in a constructor.- Specified by:
addStateChangeListenerin interfaceStageExecution
-
addCompletedDriverGroupsChangedListener
public void addCompletedDriverGroupsChangedListener(Consumer<Set<Lifespan>> newlyCompletedDriverGroupConsumer)
- Specified by:
addCompletedDriverGroupsChangedListenerin interfaceStageExecution
-
beginScheduling
public void beginScheduling()
- Specified by:
beginSchedulingin interfaceStageExecution
-
transitionToSchedulingSplits
public void transitionToSchedulingSplits()
- Specified by:
transitionToSchedulingSplitsin interfaceStageExecution
-
schedulingComplete
public void schedulingComplete()
- Specified by:
schedulingCompletein interfaceStageExecution
-
schedulingComplete
public void schedulingComplete(PlanNodeId partitionedSource)
- Specified by:
schedulingCompletein interfaceStageExecution
-
cancel
public void cancel()
- Specified by:
cancelin interfaceStageExecution
-
abort
public void abort()
- Specified by:
abortin interfaceStageExecution
-
fail
public void fail(Throwable failureCause)
-
failTask
public void failTask(TaskId taskId, Throwable failureCause)
- Specified by:
failTaskin interfaceStageExecution
-
scheduleTask
public Optional<RemoteTask> scheduleTask(InternalNode node, int partition, com.google.common.collect.Multimap<PlanNodeId,Split> initialSplits, com.google.common.collect.Multimap<PlanNodeId,Lifespan> noMoreSplitsForLifespan)
- Specified by:
scheduleTaskin interfaceStageExecution
-
getTaskLifecycleListener
public TaskLifecycleListener getTaskLifecycleListener()
- Specified by:
getTaskLifecycleListenerin interfaceStageExecution
-
getAllTasks
public List<RemoteTask> getAllTasks()
- Specified by:
getAllTasksin interfaceStageExecution
-
getTaskStatuses
public List<TaskStatus> getTaskStatuses()
- Specified by:
getTaskStatusesin interfaceStageExecution
-
isAnyTaskBlocked
public boolean isAnyTaskBlocked()
- Specified by:
isAnyTaskBlockedin interfaceStageExecution
-
recordGetSplitTime
public void recordGetSplitTime(long start)
- Specified by:
recordGetSplitTimein interfaceStageExecution
-
getStageId
public StageId getStageId()
- Specified by:
getStageIdin interfaceStageExecution
-
getAttemptId
public int getAttemptId()
- Specified by:
getAttemptIdin interfaceStageExecution
-
getFragment
public PlanFragment getFragment()
- Specified by:
getFragmentin interfaceStageExecution
-
getFailureCause
public Optional<ExecutionFailureInfo> getFailureCause()
- Specified by:
getFailureCausein interfaceStageExecution
-
-