Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
  *     http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.facebook.presto.execution;
import static com.google.common.base.Preconditions.checkNotNull;
public class QueuedExecution
    private final QueryExecution queryExecution;
    private final List<QueryQueuenextQueues;
    private final ListenableFuture<?> listenableFuture;
    private final Executor executor;
    private final SqlQueryManagerStats stats;
    public static QueuedExecution createQueuedExecution(QueryExecution queryExecutionList<QueryQueuenextQueuesExecutor executorSqlQueryManagerStats stats)
    {
        SettableFuture<?> settableFuture = SettableFuture.create();
        SqlQueryManager.addCompletionCallback(queryExecution, () -> settableFuture.set(null));
        return new QueuedExecution(queryExecutionnextQueuesexecutorstatssettableFuture);
    }
    private QueuedExecution(QueryExecution queryExecutionList<QueryQueuenextQueuesExecutor executorSqlQueryManagerStats statsListenableFuture<?> listenableFuture)
    {
        this. = checkNotNull(queryExecution"queryExecution is null");
        this. = ImmutableList.copyOf(checkNotNull(nextQueues"nextQueues is null"));
        this. = checkNotNull(executor"executor is null");
        this. = checkNotNull(stats"stats is null");
        this. = checkNotNull(listenableFuture"listenableFuture is null");
    }
    {
        return ;
    }
    public void start()
    {
        // Only execute if the query is not already completed (e.g. cancelled)
        if (.isDone()) {
            return;
        }
        if (.isEmpty()) {
            .execute(() -> {
                try (SetThreadName setThreadName = new SetThreadName("Query-%s".getQueryInfo().getQueryId())) {
                    .queryStarted();
                    .addListener(::queryStopped, MoreExecutors.directExecutor());
                    .start();
                }
            });
        }
        else {
                .fail(new IllegalStateException("Entering secondary queue failed"));
            }
        }
    }
New to GrepCode? Check out our FAQ X