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