use of com.facebook.presto.execution.TaskInfo in project presto by prestodb.
the class PlanPrinter method textDistributedPlan.
public static String textDistributedPlan(List<StageInfo> stages, Metadata metadata, Session session) {
StringBuilder builder = new StringBuilder();
List<StageInfo> allStages = stages.stream().flatMap(stage -> getAllStages(Optional.of(stage)).stream()).collect(toImmutableList());
for (StageInfo stageInfo : allStages) {
Map<PlanNodeId, PlanNodeStats> aggregatedStats = new HashMap<>();
List<PlanNodeStats> planNodeStats = stageInfo.getTasks().stream().map(TaskInfo::getStats).flatMap(taskStats -> getPlanNodeStats(taskStats).stream()).collect(toList());
for (PlanNodeStats stats : planNodeStats) {
aggregatedStats.merge(stats.getPlanNodeId(), stats, PlanNodeStats::merge);
}
builder.append(formatFragment(metadata, session, stageInfo.getPlan(), Optional.of(stageInfo.getStageStats()), Optional.of(aggregatedStats)));
}
return builder.toString();
}
use of com.facebook.presto.execution.TaskInfo 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, taskStatus.getTaskId().toString(), taskStatus.getTaskId().getStageId().toString(), taskStatus.getTaskId().getQueryId().toString(), taskStatus.getState().toString(), (long) stats.getTotalDrivers(), (long) stats.getQueuedDrivers(), (long) stats.getRunningDrivers(), (long) stats.getCompletedDrivers(), toMillis(stats.getTotalScheduledTime()), toMillis(stats.getTotalCpuTime()), toMillis(stats.getTotalUserTime()), toMillis(stats.getTotalBlockedTime()), toBytes(stats.getRawInputDataSize()), stats.getRawInputPositions(), toBytes(stats.getProcessedInputDataSize()), stats.getProcessedInputPositions(), toBytes(stats.getOutputDataSize()), stats.getOutputPositions(), toTimeStamp(stats.getCreateTime()), toTimeStamp(stats.getFirstStartTime()), toTimeStamp(taskInfo.getLastHeartbeat()), toTimeStamp(stats.getEndTime()));
}
return table.build().cursor();
}
use of com.facebook.presto.execution.TaskInfo in project presto by prestodb.
the class QueryExecutionResource method getTaskInfo.
@GET
@Path("/v1/query-execution/{queryId}")
@Produces(MediaType.APPLICATION_JSON)
public Response getTaskInfo(@PathParam("queryId") String queryId) {
QueryInfo query;
try {
query = manager.getQueryInfo(QueryId.valueOf(queryId));
} catch (NoSuchElementException e) {
return Response.status(Response.Status.NOT_FOUND).build();
}
List<StageInfo> stages = collectStages(query.getOutputStage());
List<Task> tasks = new ArrayList<>();
List<Flow> flows = new ArrayList<>();
for (StageInfo stage : stages) {
for (TaskInfo task : stage.getTasks()) {
int bufferedPages = 0;
TaskStatus taskStatus = task.getTaskStatus();
for (BufferInfo bufferInfo : task.getOutputBuffers().getBuffers()) {
bufferedPages += bufferInfo.getBufferedPages();
if (!bufferInfo.getBufferId().equals(OUTPUT_TASK_ID)) {
flows.add(new Flow(taskStatus.getTaskId().toString(), bufferInfo.getBufferId().toString(), bufferInfo.getPageBufferInfo().getPagesAdded(), bufferInfo.getBufferedPages(), bufferInfo.isFinished()));
}
}
long last = TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
if (task.getStats().getEndTime() != null) {
last = task.getStats().getEndTime().getMillis();
}
tasks.add(new Task(taskStatus.getTaskId().toString(), taskStatus.getState().toString(), taskStatus.getSelf().getHost(), last - task.getStats().getCreateTime().getMillis(), task.getStats().getTotalCpuTime().roundTo(TimeUnit.MILLISECONDS), task.getStats().getTotalBlockedTime().roundTo(TimeUnit.MILLISECONDS), task.getStats().getRawInputDataSize().roundTo(DataSize.Unit.BYTE), task.getStats().getRawInputPositions(), task.getStats().getOutputDataSize().roundTo(DataSize.Unit.BYTE), task.getStats().getOutputPositions(), task.getStats().getMemoryReservation().roundTo(DataSize.Unit.BYTE), task.getStats().getQueuedDrivers(), task.getStats().getRunningDrivers(), task.getStats().getCompletedDrivers(), bufferedPages));
}
}
Map<String, Object> result = ImmutableMap.<String, Object>builder().put("tasks", tasks).put("flows", flows).build();
return Response.ok(result).build();
}
use of com.facebook.presto.execution.TaskInfo in project presto by prestodb.
the class TaskResource method createOrUpdateTask.
@POST
@Path("{taskId}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response createOrUpdateTask(@PathParam("taskId") TaskId taskId, TaskUpdateRequest taskUpdateRequest, @Context UriInfo uriInfo) {
requireNonNull(taskUpdateRequest, "taskUpdateRequest is null");
Session session = taskUpdateRequest.getSession().toSession(sessionPropertyManager);
TaskInfo taskInfo = taskManager.updateTask(session, taskId, taskUpdateRequest.getFragment(), taskUpdateRequest.getSources(), taskUpdateRequest.getOutputIds());
if (shouldSummarize(uriInfo)) {
taskInfo = taskInfo.summarize();
}
return Response.ok().entity(taskInfo).build();
}
use of com.facebook.presto.execution.TaskInfo in project presto by prestodb.
the class TaskResource method abortResults.
@DELETE
@Path("{taskId}/results/{bufferId}")
@Produces(MediaType.APPLICATION_JSON)
public Response abortResults(@PathParam("taskId") TaskId taskId, @PathParam("bufferId") OutputBufferId bufferId, @Context UriInfo uriInfo) {
requireNonNull(taskId, "taskId is null");
requireNonNull(bufferId, "bufferId is null");
TaskInfo taskInfo = taskManager.abortTaskResults(taskId, bufferId);
if (shouldSummarize(uriInfo)) {
taskInfo = taskInfo.summarize();
}
return Response.ok(taskInfo).build();
}
Aggregations