public class QueryStateProcessor extends Object implements AutoCloseable
| Constructor and Description |
|---|
QueryStateProcessor(String queryIdString,
QueryManager queryManager,
DrillbitContext drillbitContext,
Foreman.ForemanResult foremanResult) |
| Modifier and Type | Method and Description |
|---|---|
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. |
void |
cancel()
Transition query to
CANCELLATION_REQUESTED state if it is
not already in the terminal states QueryState#CANCELED, CANCELED, QueryState#COMPLETED, COMPLETED or
QueryState#FAILED, FAILED. |
void |
close()
On close set proper increment / decrement counters depending on final query state.
|
UserBitShared.QueryResult.QueryState |
getState() |
void |
moveToState(UserBitShared.QueryResult.QueryState newState,
Exception exception)
Moves one query state to another, will fail when requested query state transition is not allowed.
|
void |
recordNewState(UserBitShared.QueryResult.QueryState newState)
Directly moves query from one state to another and updates ephemeral query store.
|
void |
startProcessingEvents()
Starts processing all events that were enqueued while all fragments were sending out.
|
public QueryStateProcessor(String queryIdString, QueryManager queryManager, DrillbitContext drillbitContext, Foreman.ForemanResult foremanResult)
public UserBitShared.QueryResult.QueryState getState()
public void moveToState(UserBitShared.QueryResult.QueryState newState, Exception exception)
newState - new query stateexception - exception if failure occurredpublic void recordNewState(UserBitShared.QueryResult.QueryState newState)
newState - new query statepublic void cancel()
CANCELLATION_REQUESTED state if it is
not already in the terminal states QueryState#CANCELED, CANCELED, QueryState#COMPLETED, COMPLETED or
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() completespublic void addToEventQueue(UserBitShared.QueryResult.QueryState newState, Exception exception)
newState - the state to move toexception - if not null, the exception that drove this state transition (usually a failure)public void startProcessingEvents()
public void close()
close in interface AutoCloseableCopyright © 2021 The Apache Software Foundation. All rights reserved.