Class Foreman

java.lang.Object
org.apache.drill.exec.work.foreman.Foreman
All Implemented Interfaces:
Runnable

public class Foreman extends Object implements Runnable
Foreman manages all the fragments (local and remote) for a single query where this is the driving/root node. The flow is as follows:
  • While Foreman is initialized query is in preparing state.
  • Foreman is submitted as a runnable.
  • Runnable does query planning.
  • Runnable submits query to be enqueued.
  • The Runnable's run() completes, but the Foreman stays around to listen to state changes.
  • Once query is enqueued, starting fragments are sent out.
  • Status listener are activated
  • Foreman listens for state change messages.
  • State change messages can drive the state to FAILED or CANCELED, in which case messages are sent to running fragments to terminate.
  • When all fragments is completed, state change messages drive the state to COMPLETED.
  • Constructor Details

  • Method Details

    • getQueryId

      public UserBitShared.QueryId getQueryId()
      Returns:
      query id
    • getState

      Returns:
      current query state
    • getQueryText

      public String getQueryText()
      Returns:
      sql query text of the query request
    • getQueryContext

      public QueryContext getQueryContext()
      Get the QueryContext created for the query.
      Returns:
      the QueryContext
    • getQueryManager

      public QueryManager getQueryManager()
      Get the QueryManager created for the query.
      Returns:
      the QueryManager
    • cancel

      public void cancel()
      Cancel the query (move query in cancellation requested state). Query execution will be canceled once possible.
    • addToEventQueue

      public void addToEventQueue(UserBitShared.QueryResult.QueryState state, Exception exception)
      Adds query status in the event queue to process it when foreman is ready.
      Parameters:
      state - new query state
      exception - exception if failure has occurred
    • resume

      public void resume()
      Resume the query. Regardless of the current state, this method sends a resume signal to all fragments. This method can be called multiple times.
    • run

      public void run()
      Called by execution pool to do query setup, and kick off remote execution.

      Note that completion of this function is not the end of the Foreman's role in the query's lifecycle.

      Specified by:
      run in interface Runnable
    • startProcessingEvents

      public void startProcessingEvents()
      While one fragments where sanding out, other might have been completed. We don't want to process completed / failed events until all fragments are sent out. This method triggers events processing when all fragments were sent out.
    • getRuntimeFilterRouter

      public RuntimeFilterRouter getRuntimeFilterRouter()