Class QueryStateProcessor

java.lang.Object
org.apache.drill.exec.work.foreman.QueryStateProcessor
All Implemented Interfaces:
AutoCloseable

public class QueryStateProcessor extends Object implements AutoCloseable
Is responsible for query transition from one state to another, incrementing / decrementing query statuses counters.
  • Constructor Details

  • Method Details

    • getState

      Returns:
      current query state
    • moveToState

      public void moveToState(UserBitShared.QueryResult.QueryState newState, Exception exception)
      Moves one query state to another, will fail when requested query state transition is not allowed.
      Parameters:
      newState - new query state
      exception - exception if failure occurred
    • recordNewState

      public void recordNewState(UserBitShared.QueryResult.QueryState newState)
      Directly moves query from one state to another and updates ephemeral query store.
      Parameters:
      newState - new query state
    • cancel

      public void cancel()
      Transition query to CANCELLATION_REQUESTED state if it is not already in the terminal states {@link QueryState#CANCELED, CANCELED}, {@link QueryState#COMPLETED, COMPLETED} or {@link QueryState#FAILED, FAILED}. See the implementation of moveToState(QueryState, Exception) for details. Note this can be called from outside of run() on another thread, or after run() completes
    • addToEventQueue

      public void addToEventQueue(UserBitShared.QueryResult.QueryState newState, Exception exception)
      Tells the foreman to move to a new state.
      This will be added to the end of the event queue and will be processed once the foreman is ready to accept external events.
      Parameters:
      newState - the state to move to
      exception - if not null, the exception that drove this state transition (usually a failure)
    • startProcessingEvents

      public void startProcessingEvents()
      Starts processing all events that were enqueued while all fragments were sending out.
    • close

      public void close()
      On close set proper increment / decrement counters depending on final query state.
      Specified by:
      close in interface AutoCloseable