Package io.trino.execution
Class SqlQueryManager
- java.lang.Object
-
- io.trino.execution.SqlQueryManager
-
- All Implemented Interfaces:
QueryManager
@ThreadSafe public class SqlQueryManager extends Object implements QueryManager
-
-
Constructor Summary
Constructors Constructor Description SqlQueryManager(ClusterMemoryManager memoryManager, QueryManagerConfig queryManagerConfig)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddFinalQueryInfoListener(QueryId queryId, StateMachine.StateChangeListener<QueryInfo> stateChangeListener)voidaddOutputInfoListener(QueryId queryId, Consumer<QueryExecution.QueryOutputInfo> listener)Add a listener that fires once the query output locations are known.voidaddStateChangeListener(QueryId queryId, StateMachine.StateChangeListener<QueryState> listener)Add a listener that fires each time the query state changes.voidcancelQuery(QueryId queryId)Attempts to fail the query due to a user cancellation.voidcancelStage(StageId stageId)Attempts to cancel the stage and continue the query.voidcreateQuery(QueryExecution queryExecution)Creates a new query using the specified query execution.voidfailQuery(QueryId queryId, Throwable cause)Attempts to fail the query for the specified reason.io.airlift.concurrent.ThreadPoolExecutorMBeangetExecutor()QueryInfogetFullQueryInfo(QueryId queryId)io.airlift.concurrent.ThreadPoolExecutorMBeangetManagementExecutor()List<BasicQueryInfo>getQueries()BasicQueryInfogetQueryInfo(QueryId queryId)PlangetQueryPlan(QueryId queryId)SessiongetQuerySession(QueryId queryId)SluggetQuerySlug(QueryId queryId)QueryStategetQueryState(QueryId queryId)com.google.common.util.concurrent.ListenableFuture<QueryState>getStateChange(QueryId queryId, QueryState currentState)Gets a future that completes when the query changes from the specified current state or immediately if the query is already in a final state.voidoutputTaskFailed(TaskId taskId, Throwable failure)Notify that one of the output tasks failed for a given queryvoidrecordHeartbeat(QueryId queryId)Updates the client heartbeat time, to prevent the query from be automatically purged.voidstart()voidstop()
-
-
-
Constructor Detail
-
SqlQueryManager
@Inject public SqlQueryManager(ClusterMemoryManager memoryManager, QueryManagerConfig queryManagerConfig)
-
-
Method Detail
-
start
@PostConstruct public void start()
-
stop
@PreDestroy public void stop()
-
getQueries
public List<BasicQueryInfo> getQueries()
- Specified by:
getQueriesin interfaceQueryManager
-
addOutputInfoListener
public void addOutputInfoListener(QueryId queryId, Consumer<QueryExecution.QueryOutputInfo> listener)
Description copied from interface:QueryManagerAdd a listener that fires once the query output locations are known.- Specified by:
addOutputInfoListenerin interfaceQueryManager
-
outputTaskFailed
public void outputTaskFailed(TaskId taskId, Throwable failure)
Description copied from interface:QueryManagerNotify that one of the output tasks failed for a given query- Specified by:
outputTaskFailedin interfaceQueryManager
-
addStateChangeListener
public void addStateChangeListener(QueryId queryId, StateMachine.StateChangeListener<QueryState> listener)
Description copied from interface:QueryManagerAdd a listener that fires each time the query state changes. Listener is always notified asynchronously using a dedicated notification thread pool so, care should be taken to avoid leakingthiswhen adding a listener in a constructor. Additionally, it is possible notifications are observed out of order due to the asynchronous execution.- Specified by:
addStateChangeListenerin interfaceQueryManager
-
getStateChange
public com.google.common.util.concurrent.ListenableFuture<QueryState> getStateChange(QueryId queryId, QueryState currentState)
Description copied from interface:QueryManagerGets a future that completes when the query changes from the specified current state or immediately if the query is already in a final state. If the query does not exist, the future will contain aNoSuchElementException- Specified by:
getStateChangein interfaceQueryManager
-
getQueryInfo
public BasicQueryInfo getQueryInfo(QueryId queryId)
- Specified by:
getQueryInfoin interfaceQueryManager
-
getFullQueryInfo
public QueryInfo getFullQueryInfo(QueryId queryId) throws NoSuchElementException
- Specified by:
getFullQueryInfoin interfaceQueryManager- Throws:
NoSuchElementException- if query does not exist
-
getQuerySession
public Session getQuerySession(QueryId queryId) throws NoSuchElementException
- Specified by:
getQuerySessionin interfaceQueryManager- Throws:
NoSuchElementException- if query does not exist
-
getQuerySlug
public Slug getQuerySlug(QueryId queryId)
- Specified by:
getQuerySlugin interfaceQueryManager
-
addFinalQueryInfoListener
public void addFinalQueryInfoListener(QueryId queryId, StateMachine.StateChangeListener<QueryInfo> stateChangeListener)
-
getQueryState
public QueryState getQueryState(QueryId queryId)
- Specified by:
getQueryStatein interfaceQueryManager
-
recordHeartbeat
public void recordHeartbeat(QueryId queryId)
Description copied from interface:QueryManagerUpdates the client heartbeat time, to prevent the query from be automatically purged. If the query does not exist, the call is ignored.- Specified by:
recordHeartbeatin interfaceQueryManager
-
createQuery
public void createQuery(QueryExecution queryExecution)
Description copied from interface:QueryManagerCreates a new query using the specified query execution.- Specified by:
createQueryin interfaceQueryManager
-
failQuery
public void failQuery(QueryId queryId, Throwable cause)
Description copied from interface:QueryManagerAttempts to fail the query for the specified reason. If the query is already in a final state, the call is ignored. If the query does not exist, the call is ignored.- Specified by:
failQueryin interfaceQueryManager
-
cancelQuery
public void cancelQuery(QueryId queryId)
Description copied from interface:QueryManagerAttempts to fail the query due to a user cancellation. If the query is already in a final state, the call is ignored. If the query does not exist, the call is ignored.- Specified by:
cancelQueryin interfaceQueryManager
-
cancelStage
public void cancelStage(StageId stageId)
Description copied from interface:QueryManagerAttempts to cancel the stage and continue the query. If the stage is already in a final state, the call is ignored. If the query does not exist, the call is ignored.- Specified by:
cancelStagein interfaceQueryManager
-
getExecutor
public io.airlift.concurrent.ThreadPoolExecutorMBean getExecutor()
-
getManagementExecutor
public io.airlift.concurrent.ThreadPoolExecutorMBean getManagementExecutor()
-
-