Search in sources :

Example 11 with TaskStatus

use of io.prestosql.execution.TaskStatus in project hetu-core by openlookeng.

the class HttpRemoteTask method cancelToResume.

@Override
public synchronized void cancelToResume() {
    try (SetThreadName ignored = new SetThreadName("HttpRemoteTask-%s", taskId)) {
        // Cancel-to-resume doesn't need retry and backoff mechanisms
        cancelledToResume.set(true);
        TaskStatus taskStatus = getTaskStatus();
        taskStatusFetcher.stop();
        taskInfoFetcher.stop();
        // force send this request even if aborting was true
        aborting.set(false);
        sendCancelRequest(taskStatus, TaskState.CANCELED_TO_RESUME, "cancel-to-resume");
    }
    // This is the last time this class can be used. All subsequent requests are ignored.
    abandoned.set(true);
}
Also used : SetThreadName(io.airlift.concurrent.SetThreadName) TaskStatus(io.prestosql.execution.TaskStatus)

Example 12 with TaskStatus

use of io.prestosql.execution.TaskStatus in project hetu-core by openlookeng.

the class TaskResource method getTaskStatus.

@GET
@Path("{taskId}/status")
@Produces({ MediaType.APPLICATION_JSON, APPLICATION_JACKSON_SMILE })
public void getTaskStatus(@PathParam("taskId") TaskId taskId, @HeaderParam(PRESTO_CURRENT_STATE) TaskState currentState, @HeaderParam(PRESTO_MAX_WAIT) Duration maxWait, @HeaderParam(PRESTO_TASK_INSTANCE_ID) String taskInstanceId, @Context UriInfo uriInfo, @Suspended AsyncResponse asyncResponse) {
    SecurityRequireNonNull.requireNonNull(taskId, "taskId is null");
    if (currentState == null || maxWait == null) {
        asyncResponse.resume(tryGetTaskStatus(uriInfo, taskId, taskInstanceId));
        return;
    }
    ListenableFuture<TaskStatus> futureTaskStatus = taskManager.getTaskStatus(taskId, currentState, taskInstanceId);
    if (futureTaskStatus == null) {
        asyncResponse.resume(createAbortedTaskStatus(taskId, uriInfo.getAbsolutePath()));
        return;
    }
    Duration waitTime = randomizeWaitTime(maxWait);
    // TODO: With current implementation, a newly completed driver group won't trigger immediate HTTP response,
    // leading to a slight delay of approx 1 second, which is not a major issue for any query that are heavy weight enough
    // to justify group-by-group execution. In order to fix this, REST endpoint /v1/{task}/status will need change.
    futureTaskStatus = addTimeout(futureTaskStatus, () -> tryGetTaskStatus(uriInfo, taskId, taskInstanceId), waitTime, timeoutExecutor);
    // For hard timeout, add an additional time to max wait for thread scheduling contention and GC
    Duration timeout = new Duration(waitTime.toMillis() + ADDITIONAL_WAIT_TIME.toMillis(), MILLISECONDS);
    bindAsyncResponse(asyncResponse, futureTaskStatus, responseExecutor).withTimeout(timeout);
}
Also used : Duration(io.airlift.units.Duration) TaskStatus(io.prestosql.execution.TaskStatus) TaskStatus.initialTaskStatus(io.prestosql.execution.TaskStatus.initialTaskStatus) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

TaskStatus (io.prestosql.execution.TaskStatus)12 ResponseHandler (io.airlift.http.client.ResponseHandler)4 AdaptingJsonResponseHandler.createAdaptingJsonResponseHandler (io.prestosql.protocol.AdaptingJsonResponseHandler.createAdaptingJsonResponseHandler)4 FullSmileResponseHandler.createFullSmileResponseHandler (io.prestosql.protocol.FullSmileResponseHandler.createFullSmileResponseHandler)4 SetThreadName (io.airlift.concurrent.SetThreadName)3 Request (io.airlift.http.client.Request)3 HttpUriBuilder (io.airlift.http.client.HttpUriBuilder)2 Duration (io.airlift.units.Duration)2 TaskInfo (io.prestosql.execution.TaskInfo)2 BaseResponse (io.prestosql.protocol.BaseResponse)2 SmileCodec (io.prestosql.protocol.SmileCodec)2 URI (java.net.URI)2 Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)1 Preconditions.checkState (com.google.common.base.Preconditions.checkState)1 Verify.verify (com.google.common.base.Verify.verify)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableMap.toImmutableMap (com.google.common.collect.ImmutableMap.toImmutableMap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1