Package io.prestosql.execution
Class SqlQueryManager
- java.lang.Object
-
- io.prestosql.execution.SqlQueryManager
-
- All Implemented Interfaces:
QueryManager
@ThreadSafe public class SqlQueryManager extends Object implements QueryManager
-
-
Constructor Summary
Constructors Constructor Description SqlQueryManager(ClusterMemoryManager memoryManager, QueryMonitor queryMonitor, QueryManagerConfig queryManagerConfig)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addFinalQueryInfoListener(QueryId queryId, StateMachine.StateChangeListener<QueryInfo> stateChangeListener)
void
addOutputInfoListener(QueryId queryId, Consumer<QueryExecution.QueryOutputInfo> listener)
Add a listener that fires once the query output locations are known.void
addStateChangeListener(QueryId queryId, StateMachine.StateChangeListener<QueryState> listener)
Add a listener that fires each time the query state changes.void
cancelQuery(QueryId queryId)
Attempts to fail the query due to a user cancellation.void
cancelStage(StageId stageId)
Attempts to cancel the stage and continue the query.void
createQuery(QueryExecution queryExecution)
Creates a new query using the specified query execution.void
failQuery(QueryId queryId, Throwable cause)
Attempts to fail the query for the specified reason.io.airlift.concurrent.ThreadPoolExecutorMBean
getExecutor()
QueryInfo
getFullQueryInfo(QueryId queryId)
io.airlift.concurrent.ThreadPoolExecutorMBean
getManagementExecutor()
List<BasicQueryInfo>
getQueries()
BasicQueryInfo
getQueryInfo(QueryId queryId)
Plan
getQueryPlan(QueryId queryId)
Session
getQuerySession(QueryId queryId)
Slug
getQuerySlug(QueryId queryId)
QueryState
getQueryState(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.void
recordHeartbeat(QueryId queryId)
Updates the client heartbeat time, to prevent the query from be automatically purged.void
start()
void
stop()
-
-
-
Constructor Detail
-
SqlQueryManager
@Inject public SqlQueryManager(ClusterMemoryManager memoryManager, QueryMonitor queryMonitor, QueryManagerConfig queryManagerConfig)
-
-
Method Detail
-
start
@PostConstruct public void start()
-
stop
@PreDestroy public void stop()
-
getQueries
public List<BasicQueryInfo> getQueries()
- Specified by:
getQueries
in interfaceQueryManager
-
addOutputInfoListener
public void addOutputInfoListener(QueryId queryId, Consumer<QueryExecution.QueryOutputInfo> listener)
Description copied from interface:QueryManager
Add a listener that fires once the query output locations are known.- Specified by:
addOutputInfoListener
in interfaceQueryManager
-
addStateChangeListener
public void addStateChangeListener(QueryId queryId, StateMachine.StateChangeListener<QueryState> listener)
Description copied from interface:QueryManager
Add 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 leakingthis
when adding a listener in a constructor. Additionally, it is possible notifications are observed out of order due to the asynchronous execution.- Specified by:
addStateChangeListener
in interfaceQueryManager
-
getStateChange
public com.google.common.util.concurrent.ListenableFuture<QueryState> getStateChange(QueryId queryId, QueryState currentState)
Description copied from interface:QueryManager
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. If the query does not exist, the future will contain aNoSuchElementException
- Specified by:
getStateChange
in interfaceQueryManager
-
getQueryInfo
public BasicQueryInfo getQueryInfo(QueryId queryId)
- Specified by:
getQueryInfo
in interfaceQueryManager
-
getFullQueryInfo
public QueryInfo getFullQueryInfo(QueryId queryId) throws NoSuchElementException
- Specified by:
getFullQueryInfo
in interfaceQueryManager
- Throws:
NoSuchElementException
- if query does not exist
-
getQuerySession
public Session getQuerySession(QueryId queryId) throws NoSuchElementException
- Specified by:
getQuerySession
in interfaceQueryManager
- Throws:
NoSuchElementException
- if query does not exist
-
getQuerySlug
public Slug getQuerySlug(QueryId queryId)
- Specified by:
getQuerySlug
in interfaceQueryManager
-
addFinalQueryInfoListener
public void addFinalQueryInfoListener(QueryId queryId, StateMachine.StateChangeListener<QueryInfo> stateChangeListener)
-
getQueryState
public QueryState getQueryState(QueryId queryId)
- Specified by:
getQueryState
in interfaceQueryManager
-
recordHeartbeat
public void recordHeartbeat(QueryId queryId)
Description copied from interface:QueryManager
Updates the client heartbeat time, to prevent the query from be automatically purged. If the query does not exist, the call is ignored.- Specified by:
recordHeartbeat
in interfaceQueryManager
-
createQuery
public void createQuery(QueryExecution queryExecution)
Description copied from interface:QueryManager
Creates a new query using the specified query execution.- Specified by:
createQuery
in interfaceQueryManager
-
failQuery
public void failQuery(QueryId queryId, Throwable cause)
Description copied from interface:QueryManager
Attempts 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:
failQuery
in interfaceQueryManager
-
cancelQuery
public void cancelQuery(QueryId queryId)
Description copied from interface:QueryManager
Attempts 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:
cancelQuery
in interfaceQueryManager
-
cancelStage
public void cancelStage(StageId stageId)
Description copied from interface:QueryManager
Attempts 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:
cancelStage
in interfaceQueryManager
-
getExecutor
public io.airlift.concurrent.ThreadPoolExecutorMBean getExecutor()
-
getManagementExecutor
public io.airlift.concurrent.ThreadPoolExecutorMBean getManagementExecutor()
-
-