use of com.facebook.presto.tracing.QueryStateTracingListener in project presto by prestodb.
the class LocalDispatchQueryFactory method createDispatchQuery.
@Override
public DispatchQuery createDispatchQuery(Session session, String query, PreparedQuery preparedQuery, String slug, int retryCount, ResourceGroupId resourceGroup, Optional<QueryType> queryType, WarningCollector warningCollector, Consumer<DispatchQuery> queryQueuer) {
QueryStateMachine stateMachine = QueryStateMachine.begin(query, preparedQuery.getPrepareSql(), session, locationFactory.createQueryLocation(session.getQueryId()), resourceGroup, queryType, isTransactionControlStatement(preparedQuery.getStatement()), transactionManager, accessControl, executor, metadata, warningCollector);
stateMachine.addStateChangeListener(new QueryStateTracingListener(stateMachine.getSession().getTracer().orElse(NoopTracerProvider.NOOP_TRACER)));
queryMonitor.queryCreatedEvent(stateMachine.getBasicQueryInfo(Optional.empty()));
ListenableFuture<QueryExecution> queryExecutionFuture = executor.submit(() -> {
QueryExecutionFactory<?> queryExecutionFactory = executionFactories.get(preparedQuery.getStatement().getClass());
if (queryExecutionFactory == null) {
throw new PrestoException(NOT_SUPPORTED, "Unsupported statement type: " + preparedQuery.getStatement().getClass().getSimpleName());
}
return queryExecutionFactory.createQueryExecution(preparedQuery, stateMachine, slug, retryCount, warningCollector, queryType);
});
return new LocalDispatchQuery(stateMachine, queryMonitor, queryExecutionFuture, clusterSizeMonitor, executor, queryQueuer, queryManager::createQuery, retryCount > 0, queryPrerequisitesManager);
}
Aggregations