Search in sources :

Example 6 with SqlQuerySchedulerInterface

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());
}
Also used : SqlQuerySchedulerInterface(com.facebook.presto.execution.scheduler.SqlQuerySchedulerInterface) DataSize(io.airlift.units.DataSize) BasicQueryInfo(com.facebook.presto.server.BasicQueryInfo)

Example 7 with SqlQuerySchedulerInterface

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();
}
Also used : SqlQuerySchedulerInterface(com.facebook.presto.execution.scheduler.SqlQuerySchedulerInterface) Duration(io.airlift.units.Duration) BasicQueryInfo(com.facebook.presto.server.BasicQueryInfo)

Example 8 with SqlQuerySchedulerInterface

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);
        }
    }
}
Also used : SetThreadName(com.facebook.airlift.concurrent.SetThreadName) SqlQuerySchedulerInterface(com.facebook.presto.execution.scheduler.SqlQuerySchedulerInterface)

Aggregations

SqlQuerySchedulerInterface (com.facebook.presto.execution.scheduler.SqlQuerySchedulerInterface)8 BasicQueryInfo (com.facebook.presto.server.BasicQueryInfo)5 DataSize (io.airlift.units.DataSize)4 SetThreadName (com.facebook.airlift.concurrent.SetThreadName)1 OutputBuffers (com.facebook.presto.execution.buffer.OutputBuffers)1 OutputBuffers.createInitialEmptyOutputBuffers (com.facebook.presto.execution.buffer.OutputBuffers.createInitialEmptyOutputBuffers)1 OutputBuffers.createSpoolingOutputBuffers (com.facebook.presto.execution.buffer.OutputBuffers.createSpoolingOutputBuffers)1 CloseableSplitSourceProvider (com.facebook.presto.split.CloseableSplitSourceProvider)1 PartitioningHandle (com.facebook.presto.sql.planner.PartitioningHandle)1 SplitSourceFactory (com.facebook.presto.sql.planner.SplitSourceFactory)1 SubPlan (com.facebook.presto.sql.planner.SubPlan)1 Duration (io.airlift.units.Duration)1