use of com.facebook.presto.execution.scheduler.SqlQuerySchedulerInterface in project presto by prestodb.
the class SqlQueryExecution method getTotalMemoryReservation.
@Override
public DataSize getTotalMemoryReservation() {
// acquire reference to scheduler before checking finalQueryInfo, because
// state change listener sets finalQueryInfo and then clears scheduler when
// the query finishes.
SqlQuerySchedulerInterface scheduler = queryScheduler.get();
Optional<QueryInfo> finalQueryInfo = stateMachine.getFinalQueryInfo();
if (finalQueryInfo.isPresent()) {
return finalQueryInfo.get().getQueryStats().getTotalMemoryReservation();
}
if (scheduler == null) {
return new DataSize(0, BYTE);
}
return succinctBytes(scheduler.getTotalMemoryReservation());
}
use of com.facebook.presto.execution.scheduler.SqlQuerySchedulerInterface in project presto by prestodb.
the class SqlQueryExecution method getTotalCpuTime.
@Override
public Duration getTotalCpuTime() {
SqlQuerySchedulerInterface scheduler = queryScheduler.get();
Optional<QueryInfo> finalQueryInfo = stateMachine.getFinalQueryInfo();
if (finalQueryInfo.isPresent()) {
return finalQueryInfo.get().getQueryStats().getTotalCpuTime();
}
if (scheduler == null) {
return new Duration(0, SECONDS);
}
return scheduler.getTotalCpuTime();
}
use of com.facebook.presto.execution.scheduler.SqlQuerySchedulerInterface in project presto by prestodb.
the class SqlQueryExecution method start.
@Override
public void start() {
try (SetThreadName ignored = new SetThreadName("Query-%s", stateMachine.getQueryId())) {
try {
// transition to planning
if (!stateMachine.transitionToPlanning()) {
// query already started or finished
return;
}
// analyze query
PlanRoot plan = analyzeQuery();
metadata.beginQuery(getSession(), plan.getConnectors());
// plan distribution of query
planDistribution(plan);
// transition to starting
if (!stateMachine.transitionToStarting()) {
// query already started or finished
return;
}
// if query is not finished, start the scheduler, otherwise cancel it
SqlQuerySchedulerInterface scheduler = queryScheduler.get();
if (!stateMachine.isDone()) {
scheduler.start();
}
} catch (Throwable e) {
fail(e);
throwIfInstanceOf(e, Error.class);
}
}
}
Aggregations