Search in sources :

Example 11 with TaskStatus

use of com.facebook.presto.execution.TaskStatus in project presto by prestodb.

the class TaskSystemTable method cursor.

@Override
public RecordCursor cursor(ConnectorTransactionHandle transactionHandle, ConnectorSession session, TupleDomain<Integer> constraint) {
    Builder table = InMemoryRecordSet.builder(TASK_TABLE);
    for (TaskInfo taskInfo : taskManager.getAllTaskInfo()) {
        TaskStats stats = taskInfo.getStats();
        TaskStatus taskStatus = taskInfo.getTaskStatus();
        table.addRow(nodeId, taskInfo.getTaskId().toString(), taskInfo.getTaskId().getStageExecutionId().toString(), taskInfo.getTaskId().getStageExecutionId().getStageId().toString(), taskInfo.getTaskId().getQueryId().toString(), taskStatus.getState().toString(), (long) stats.getTotalDrivers(), (long) stats.getQueuedDrivers(), (long) stats.getRunningDrivers(), (long) stats.getCompletedDrivers(), NANOSECONDS.toMillis(stats.getTotalScheduledTimeInNanos()), NANOSECONDS.toMillis(stats.getTotalCpuTimeInNanos()), NANOSECONDS.toMillis(stats.getTotalBlockedTimeInNanos()), stats.getRawInputDataSizeInBytes(), stats.getRawInputPositions(), stats.getProcessedInputDataSizeInBytes(), stats.getProcessedInputPositions(), stats.getOutputDataSizeInBytes(), stats.getOutputPositions(), stats.getPhysicalWrittenDataSizeInBytes(), toTimeStamp(stats.getCreateTime()), toTimeStamp(stats.getFirstStartTime()), toTimeStamp(taskInfo.getLastHeartbeat()), toTimeStamp(stats.getEndTime()));
    }
    return table.build().cursor();
}
Also used : TaskInfo(com.facebook.presto.execution.TaskInfo) TableMetadataBuilder.tableMetadataBuilder(com.facebook.presto.metadata.MetadataUtil.TableMetadataBuilder.tableMetadataBuilder) Builder(com.facebook.presto.spi.InMemoryRecordSet.Builder) TaskStats(com.facebook.presto.operator.TaskStats) TaskStatus(com.facebook.presto.execution.TaskStatus)

Example 12 with TaskStatus

use of com.facebook.presto.execution.TaskStatus in project presto by prestodb.

the class ContinuousTaskStatusFetcher method scheduleNextRequest.

private synchronized void scheduleNextRequest() {
    // stopped or done?
    TaskStatus taskStatus = getTaskStatus();
    if (!running || taskStatus.getState().isDone()) {
        return;
    }
    // outstanding request?
    if (future != null && !future.isDone()) {
        // this should never happen
        log.error("Can not reschedule update because an update is already running");
        return;
    }
    // if throttled due to error, asynchronously wait for timeout and try again
    ListenableFuture<?> errorRateLimit = errorTracker.acquireRequestPermit();
    if (!errorRateLimit.isDone()) {
        errorRateLimit.addListener(this::scheduleNextRequest, executor);
        return;
    }
    Request.Builder requestBuilder;
    ResponseHandler responseHandler;
    if (thriftTransportEnabled) {
        requestBuilder = ThriftRequestUtils.prepareThriftGet(thriftProtocol);
        responseHandler = new ThriftResponseHandler(unwrapThriftCodec(taskStatusCodec));
    } else if (binaryTransportEnabled) {
        requestBuilder = getBinaryTransportBuilder(prepareGet());
        responseHandler = createFullSmileResponseHandler((SmileCodec<TaskStatus>) taskStatusCodec);
    } else {
        requestBuilder = getJsonTransportBuilder(prepareGet());
        responseHandler = createAdaptingJsonResponseHandler((JsonCodec<TaskStatus>) taskStatusCodec);
    }
    Request request = requestBuilder.setUri(uriBuilderFrom(taskStatus.getSelf()).appendPath("status").build()).setHeader(PRESTO_CURRENT_STATE, taskStatus.getState().toString()).setHeader(PRESTO_MAX_WAIT, refreshMaxWait.toString()).build();
    errorTracker.startRequest();
    future = httpClient.executeAsync(request, responseHandler);
    currentRequestStartNanos.set(System.nanoTime());
    FutureCallback callback;
    if (thriftTransportEnabled) {
        callback = new ThriftHttpResponseHandler(this, request.getUri(), stats.getHttpResponseStats(), REMOTE_TASK_ERROR);
    } else {
        callback = new SimpleHttpResponseHandler<>(this, request.getUri(), stats.getHttpResponseStats(), REMOTE_TASK_ERROR);
    }
    Futures.addCallback(future, callback, executor);
}
Also used : ThriftResponseHandler(com.facebook.airlift.http.client.thrift.ThriftResponseHandler) SimpleHttpResponseHandler(com.facebook.presto.server.SimpleHttpResponseHandler) ThriftHttpResponseHandler(com.facebook.presto.server.thrift.ThriftHttpResponseHandler) FullSmileResponseHandler.createFullSmileResponseHandler(com.facebook.presto.server.smile.FullSmileResponseHandler.createFullSmileResponseHandler) ResponseHandler(com.facebook.airlift.http.client.ResponseHandler) AdaptingJsonResponseHandler.createAdaptingJsonResponseHandler(com.facebook.presto.server.smile.AdaptingJsonResponseHandler.createAdaptingJsonResponseHandler) ThriftHttpResponseHandler(com.facebook.presto.server.thrift.ThriftHttpResponseHandler) Request(com.facebook.airlift.http.client.Request) ThriftResponseHandler(com.facebook.airlift.http.client.thrift.ThriftResponseHandler) TaskStatus(com.facebook.presto.execution.TaskStatus) FutureCallback(com.google.common.util.concurrent.FutureCallback)

Example 13 with TaskStatus

use of com.facebook.presto.execution.TaskStatus in project presto by prestodb.

the class HttpRemoteTask method getPartitionedSplitsInfo.

@Override
public PartitionedSplitsInfo getPartitionedSplitsInfo() {
    TaskStatus taskStatus = getTaskStatus();
    if (taskStatus.getState().isDone()) {
        return PartitionedSplitsInfo.forZeroSplits();
    }
    PartitionedSplitsInfo unacknowledgedSplitsInfo = getUnacknowledgedPartitionedSplitsInfo();
    int count = unacknowledgedSplitsInfo.getCount() + taskStatus.getQueuedPartitionedDrivers() + taskStatus.getRunningPartitionedDrivers();
    long weight = unacknowledgedSplitsInfo.getWeightSum() + taskStatus.getQueuedPartitionedSplitsWeight() + taskStatus.getRunningPartitionedSplitsWeight();
    return PartitionedSplitsInfo.forSplitCountAndWeightSum(count, weight);
}
Also used : PartitionedSplitsInfo(com.facebook.presto.execution.PartitionedSplitsInfo) TaskStatus(com.facebook.presto.execution.TaskStatus)

Example 14 with TaskStatus

use of com.facebook.presto.execution.TaskStatus in project presto by prestodb.

the class HttpRemoteTask method cancel.

@Override
public synchronized void cancel() {
    try (SetThreadName ignored = new SetThreadName("HttpRemoteTask-%s", taskId)) {
        TaskStatus taskStatus = getTaskStatus();
        if (taskStatus.getState().isDone()) {
            return;
        }
        // send cancel to task and ignore response
        HttpUriBuilder uriBuilder = getHttpUriBuilder(taskStatus).addParameter("abort", "false");
        Request request = setContentTypeHeaders(binaryTransportEnabled, prepareDelete()).setUri(uriBuilder.build()).build();
        scheduleAsyncCleanupRequest(createCleanupBackoff(), request, "cancel");
    }
}
Also used : SetThreadName(com.facebook.airlift.concurrent.SetThreadName) HttpUriBuilder(com.facebook.airlift.http.client.HttpUriBuilder) TaskUpdateRequest(com.facebook.presto.server.TaskUpdateRequest) Request(com.facebook.airlift.http.client.Request) TaskStatus(com.facebook.presto.execution.TaskStatus)

Example 15 with TaskStatus

use of com.facebook.presto.execution.TaskStatus in project presto by prestodb.

the class TaskInfoFetcher method sendNextRequest.

private synchronized void sendNextRequest() {
    TaskInfo taskInfo = getTaskInfo();
    TaskStatus taskStatus = taskInfo.getTaskStatus();
    if (!running) {
        return;
    }
    // we already have the final task info
    if (isDone(getTaskInfo())) {
        stop();
        return;
    }
    // if we have an outstanding request
    if (future != null && !future.isDone()) {
        return;
    }
    // if throttled due to error, asynchronously wait for timeout and try again
    ListenableFuture<?> errorRateLimit = errorTracker.acquireRequestPermit();
    if (!errorRateLimit.isDone()) {
        errorRateLimit.addListener(this::sendNextRequest, executor);
        return;
    }
    MetadataUpdates metadataUpdateRequests = taskInfo.getMetadataUpdates();
    if (!metadataUpdateRequests.getMetadataUpdates().isEmpty()) {
        scheduleMetadataUpdates(metadataUpdateRequests);
    }
    HttpUriBuilder httpUriBuilder = uriBuilderFrom(taskStatus.getSelf());
    URI uri = summarizeTaskInfo ? httpUriBuilder.addParameter("summarize").build() : httpUriBuilder.build();
    Request.Builder uriBuilder = setContentTypeHeaders(isBinaryTransportEnabled, prepareGet());
    if (taskInfoRefreshMaxWait.toMillis() != 0L) {
        uriBuilder.setHeader(PRESTO_CURRENT_STATE, taskStatus.getState().toString()).setHeader(PRESTO_MAX_WAIT, taskInfoRefreshMaxWait.toString());
    }
    Request request = uriBuilder.setUri(uri).build();
    ResponseHandler responseHandler;
    if (isBinaryTransportEnabled) {
        responseHandler = createFullSmileResponseHandler((SmileCodec<TaskInfo>) taskInfoCodec);
    } else {
        responseHandler = createAdaptingJsonResponseHandler((JsonCodec<TaskInfo>) taskInfoCodec);
    }
    errorTracker.startRequest();
    future = httpClient.executeAsync(request, responseHandler);
    currentRequestStartNanos.set(System.nanoTime());
    Futures.addCallback(future, new SimpleHttpResponseHandler<>(this, request.getUri(), stats.getHttpResponseStats(), REMOTE_TASK_ERROR), executor);
}
Also used : TaskInfo(com.facebook.presto.execution.TaskInfo) MetadataUpdates(com.facebook.presto.metadata.MetadataUpdates) SmileCodec(com.facebook.airlift.json.smile.SmileCodec) JsonCodec(com.facebook.airlift.json.JsonCodec) SimpleHttpResponseHandler(com.facebook.presto.server.SimpleHttpResponseHandler) FullSmileResponseHandler.createFullSmileResponseHandler(com.facebook.presto.server.smile.FullSmileResponseHandler.createFullSmileResponseHandler) ResponseHandler(com.facebook.airlift.http.client.ResponseHandler) AdaptingJsonResponseHandler.createAdaptingJsonResponseHandler(com.facebook.presto.server.smile.AdaptingJsonResponseHandler.createAdaptingJsonResponseHandler) HttpUriBuilder(com.facebook.airlift.http.client.HttpUriBuilder) Request(com.facebook.airlift.http.client.Request) TaskStatus(com.facebook.presto.execution.TaskStatus) URI(java.net.URI)

Aggregations

TaskStatus (com.facebook.presto.execution.TaskStatus)17 TaskInfo (com.facebook.presto.execution.TaskInfo)6 Request (com.facebook.airlift.http.client.Request)5 ResponseHandler (com.facebook.airlift.http.client.ResponseHandler)4 SimpleHttpResponseHandler (com.facebook.presto.server.SimpleHttpResponseHandler)4 TaskUpdateRequest (com.facebook.presto.server.TaskUpdateRequest)4 AdaptingJsonResponseHandler.createAdaptingJsonResponseHandler (com.facebook.presto.server.smile.AdaptingJsonResponseHandler.createAdaptingJsonResponseHandler)4 FullSmileResponseHandler.createFullSmileResponseHandler (com.facebook.presto.server.smile.FullSmileResponseHandler.createFullSmileResponseHandler)4 HttpUriBuilder (com.facebook.airlift.http.client.HttpUriBuilder)3 QueryManagerConfig (com.facebook.presto.execution.QueryManagerConfig)3 JsonCodec (com.facebook.airlift.json.JsonCodec)2 SmileCodec (com.facebook.airlift.json.smile.SmileCodec)2 NodeTaskMap (com.facebook.presto.execution.NodeTaskMap)2 MetadataUpdates (com.facebook.presto.metadata.MetadataUpdates)2 TaskStats (com.facebook.presto.operator.TaskStats)2 BaseResponse (com.facebook.presto.server.smile.BaseResponse)2 URI (java.net.URI)2 Bootstrap (com.facebook.airlift.bootstrap.Bootstrap)1 SetThreadName (com.facebook.airlift.concurrent.SetThreadName)1 ConfigBinder.configBinder (com.facebook.airlift.configuration.ConfigBinder.configBinder)1