Class SqlStage

java.lang.Object
io.trino.execution.SqlStage

@ThreadSafe public final class SqlStage extends Object
This class is merely a container used by coordinator to track tasks for a single stage.

It is designed to keep track of execution statistics for tasks from the same stage as well as aggregating them and providing a final stage info when the stage execution is completed.

This class doesn't imply anything about the nature of execution. It is not responsible for scheduling tasks in a certain order, gang scheduling or any other execution primitives.

  • Method Details

    • createSqlStage

      public static SqlStage createSqlStage(StageId stageId, PlanFragment fragment, Map<PlanNodeId,TableInfo> tables, RemoteTaskFactory remoteTaskFactory, Session session, boolean summarizeTaskInfo, NodeTaskMap nodeTaskMap, Executor stateMachineExecutor, io.opentelemetry.api.trace.Tracer tracer, io.opentelemetry.api.trace.Span schedulerSpan, SplitSchedulerStats schedulerStats)
    • getStageId

      public StageId getStageId()
    • getStageSpan

      public io.opentelemetry.api.trace.Span getStageSpan()
    • getState

      public StageState getState()
    • finish

      public void finish()
    • abort

      public void abort()
    • fail

      public void fail(Throwable throwable)
    • failTaskRemotely

      public void failTaskRemotely(TaskId taskId, Throwable failureCause)
    • addFinalStageInfoListener

      public void addFinalStageInfoListener(StateMachine.StateChangeListener<StageInfo> stateChangeListener)
      Add a listener for the final stage info. This notification is guaranteed to be fired only once. Listener is always notified asynchronously using a dedicated notification thread pool so, care should be taken to avoid leaking this when adding a listener in a constructor. Additionally, it is possible notifications are observed out of order due to the asynchronous execution.
    • getFragment

      public PlanFragment getFragment()
    • getUserMemoryReservation

      public long getUserMemoryReservation()
    • getTotalMemoryReservation

      public long getTotalMemoryReservation()
    • getTotalCpuTime

      public io.airlift.units.Duration getTotalCpuTime()
    • getBasicStageStats

      public BasicStageStats getBasicStageStats()
    • getStageInfo

      public StageInfo getStageInfo()
    • getBasicStageInfo

      public BasicStageInfo getBasicStageInfo()
    • createTask

      public Optional<RemoteTask> createTask(InternalNode node, int partition, int attempt, Optional<int[]> bucketToPartition, OutputBuffers outputBuffers, com.google.common.collect.Multimap<PlanNodeId,Split> splits, Set<PlanNodeId> noMoreSplits, Optional<io.airlift.units.DataSize> estimatedMemory, boolean speculative)
    • recordGetSplitTime

      public void recordGetSplitTime(long start)
    • toString

      public String toString()
      Overrides:
      toString in class Object