Class Foreman
java.lang.Object
org.apache.drill.exec.work.foreman.Foreman
- All Implemented Interfaces:
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.
-
Nested Class Summary
Modifier and TypeClassDescriptionclass
Manages the end-state processing for Foreman.static class
static enum
-
Constructor Summary
ConstructorDescriptionForeman
(WorkManager.WorkerBee bee, DrillbitContext drillbitContext, UserClientConnection connection, UserBitShared.QueryId queryId, UserProtos.RunQuery queryRequest) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addToEventQueue
(UserBitShared.QueryResult.QueryState state, Exception exception) Adds query status in the event queue to process it when foreman is ready.void
cancel()
Cancel the query (move query in cancellation requested state).Get the QueryContext created for the query.Get the QueryManager created for the query.getState()
void
resume()
Resume the query.void
run()
Called by execution pool to do query setup, and kick off remote execution.void
While one fragments where sanding out, other might have been completed.
-
Constructor Details
-
Method Details
-
getQueryId
- Returns:
- query id
-
getState
- Returns:
- current query state
-
getQueryText
- Returns:
- sql query text of the query request
-
getQueryContext
Get the QueryContext created for the query.- Returns:
- the QueryContext
-
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. -
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.
-
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
-