Class TaskDescriptorStorage

java.lang.Object
io.trino.execution.scheduler.faulttolerant.TaskDescriptorStorage

public class TaskDescriptorStorage extends Object
  • Constructor Details

    • TaskDescriptorStorage

      @Inject public TaskDescriptorStorage(QueryManagerConfig config, io.airlift.json.JsonCodec<Split> splitJsonCodec)
    • TaskDescriptorStorage

      public TaskDescriptorStorage(io.airlift.units.DataSize maxMemory, io.airlift.json.JsonCodec<Split> splitJsonCodec)
  • Method Details

    • initialize

      public void initialize(QueryId queryId)
      Initializes task descriptor storage for a given queryId. It is expected to be called before query scheduling begins.
    • put

      public void put(StageId stageId, TaskDescriptor descriptor)
      Stores TaskDescriptor for a task identified by the stageId and partitionId. The partitionId is obtained from the TaskDescriptor by calling TaskDescriptor.getPartitionId(). If the query has been terminated the call is ignored.
      Throws:
      IllegalStateException - if the storage already has a task descriptor for a given task
    • get

      public Optional<TaskDescriptor> get(StageId stageId, int partitionId)
      Get task descriptor
      Returns:
      Non empty TaskDescriptor for a task identified by the stageId and partitionId. Returns Optional.empty() if the query of a given stageId has been finished (e.g.: cancelled by the user or finished early).
      Throws:
      NoSuchElementException - if TaskDescriptor for a given task does not exist
    • remove

      public void remove(StageId stageId, int partitionId)
      Removes TaskDescriptor for a task identified by the stageId and partitionId. If the query has been terminated the call is ignored.
      Throws:
      NoSuchElementException - if TaskDescriptor for a given task does not exist
    • destroy

      public void destroy(QueryId queryId)
      Notifies the storage that the query with a given queryId has been finished and the task descriptors can be safely discarded.

      The engine may decided to destroy the storage while the scheduling is still in process (for example if query was cancelled). Under such circumstances the implementation will ignore future calls to put(StageId, TaskDescriptor) and return Optional.empty() from get(StageId, int). The scheduler is expected to handle this condition appropriately.

    • getStats