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);
}
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);
}
Aggregations