Search in sources :

Example 6 with TaskInfo

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();
}
Also used : ComparisonExpressionType(com.facebook.presto.sql.tree.ComparisonExpressionType) Arrays(java.util.Arrays) FrameBound(com.facebook.presto.sql.tree.FrameBound) DistinctLimitNode(com.facebook.presto.sql.planner.plan.DistinctLimitNode) OperatorStats(com.facebook.presto.operator.OperatorStats) StageInfo(com.facebook.presto.execution.StageInfo) MarkDistinctNode(com.facebook.presto.sql.planner.plan.MarkDistinctNode) Map(java.util.Map) IndexJoinNode(com.facebook.presto.sql.planner.plan.IndexJoinNode) ImmutableCollectors.toImmutableList(com.facebook.presto.util.ImmutableCollectors.toImmutableList) Double.max(java.lang.Double.max) StageInfo.getAllStages(com.facebook.presto.execution.StageInfo.getAllStages) StageStats(com.facebook.presto.execution.StageStats) RowNumberNode(com.facebook.presto.sql.planner.plan.RowNumberNode) Set(java.util.Set) VARCHAR(com.facebook.presto.spi.type.VarcharType.VARCHAR) MILLISECONDS(java.util.concurrent.TimeUnit.MILLISECONDS) ExceptNode(com.facebook.presto.sql.planner.plan.ExceptNode) Domain(com.facebook.presto.spi.predicate.Domain) Stream(java.util.stream.Stream) OperatorNotFoundException(com.facebook.presto.metadata.OperatorNotFoundException) ApplyNode(com.facebook.presto.sql.planner.plan.ApplyNode) AssignUniqueId(com.facebook.presto.sql.planner.plan.AssignUniqueId) LimitNode(com.facebook.presto.sql.planner.plan.LimitNode) Lists.reverse(com.google.common.collect.Lists.reverse) Joiner(com.google.common.base.Joiner) Iterables(com.google.common.collect.Iterables) SINGLE_DISTRIBUTION(com.facebook.presto.sql.planner.SystemPartitioningHandle.SINGLE_DISTRIBUTION) Slice(io.airlift.slice.Slice) GroupIdNode(com.facebook.presto.sql.planner.plan.GroupIdNode) DomainUtils.simplifyDomain(com.facebook.presto.sql.planner.DomainUtils.simplifyDomain) DataSize.succinctBytes(io.airlift.units.DataSize.succinctBytes) ArrayList(java.util.ArrayList) TableScanNode(com.facebook.presto.sql.planner.plan.TableScanNode) Strings(com.google.common.base.Strings) Lists(com.google.common.collect.Lists) Type(com.facebook.presto.spi.type.Type) PlanNode(com.facebook.presto.sql.planner.plan.PlanNode) PlanFragmentId(com.facebook.presto.sql.planner.plan.PlanFragmentId) PlanNodeId(com.facebook.presto.sql.planner.plan.PlanNodeId) Functions(com.google.common.base.Functions) PipelineStats(com.facebook.presto.operator.PipelineStats) WindowNode(com.facebook.presto.sql.planner.plan.WindowNode) Session(com.facebook.presto.Session) Throwables(com.google.common.base.Throwables) Iterables.getOnlyElement(com.google.common.collect.Iterables.getOnlyElement) Range(com.facebook.presto.spi.predicate.Range) Math.sqrt(java.lang.Math.sqrt) ColumnHandle(com.facebook.presto.spi.ColumnHandle) FunctionInvoker(com.facebook.presto.sql.FunctionInvoker) SemiJoinNode(com.facebook.presto.sql.planner.plan.SemiJoinNode) FilterNode(com.facebook.presto.sql.planner.plan.FilterNode) TaskInfo(com.facebook.presto.execution.TaskInfo) Metadata(com.facebook.presto.metadata.Metadata) TaskStats(com.facebook.presto.operator.TaskStats) ExplainAnalyzeNode(com.facebook.presto.sql.planner.plan.ExplainAnalyzeNode) RemoteSourceNode(com.facebook.presto.sql.planner.plan.RemoteSourceNode) SortNode(com.facebook.presto.sql.planner.plan.SortNode) MetadataDeleteNode(com.facebook.presto.sql.planner.plan.MetadataDeleteNode) TableWriterNode(com.facebook.presto.sql.planner.plan.TableWriterNode) ValuesNode(com.facebook.presto.sql.planner.plan.ValuesNode) Duration(io.airlift.units.Duration) GraphvizPrinter(com.facebook.presto.util.GraphvizPrinter) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) Collectors.toMap(java.util.stream.Collectors.toMap) Locale(java.util.Locale) TopNRowNumberNode(com.facebook.presto.sql.planner.plan.TopNRowNumberNode) IndexSourceNode(com.facebook.presto.sql.planner.plan.IndexSourceNode) TopNNode(com.facebook.presto.sql.planner.plan.TopNNode) Assignments(com.facebook.presto.sql.planner.plan.Assignments) NullableValue(com.facebook.presto.spi.predicate.NullableValue) DataSize.succinctDataSize(io.airlift.units.DataSize.succinctDataSize) FunctionCall(com.facebook.presto.sql.tree.FunctionCall) OutputNode(com.facebook.presto.sql.planner.plan.OutputNode) SymbolReference(com.facebook.presto.sql.tree.SymbolReference) ImmutableSet(com.google.common.collect.ImmutableSet) Scope(com.facebook.presto.sql.planner.plan.ExchangeNode.Scope) ImmutableMap(com.google.common.collect.ImmutableMap) Collection(java.util.Collection) Iterables.getLast(com.google.common.collect.Iterables.getLast) Marker(com.facebook.presto.spi.predicate.Marker) Collectors(java.util.stream.Collectors) BinaryOperator(java.util.function.BinaryOperator) String.format(java.lang.String.format) Preconditions.checkState(com.google.common.base.Preconditions.checkState) TupleDomain(com.facebook.presto.spi.predicate.TupleDomain) DataSize(io.airlift.units.DataSize) List(java.util.List) Window(com.facebook.presto.sql.tree.Window) SampleNode(com.facebook.presto.sql.planner.plan.SampleNode) Optional(java.util.Optional) ConnectorTableLayoutHandle(com.facebook.presto.spi.ConnectorTableLayoutHandle) HashMap(java.util.HashMap) HashSet(java.util.HashSet) WindowFrame(com.facebook.presto.sql.tree.WindowFrame) PlanVisitor(com.facebook.presto.sql.planner.plan.PlanVisitor) ImmutableList(com.google.common.collect.ImmutableList) Objects.requireNonNull(java.util.Objects.requireNonNull) Double.isFinite(java.lang.Double.isFinite) LinkedList(java.util.LinkedList) AggregationNode(com.facebook.presto.sql.planner.plan.AggregationNode) UnnestNode(com.facebook.presto.sql.planner.plan.UnnestNode) JoinNode(com.facebook.presto.sql.planner.plan.JoinNode) Collections.emptyMap(java.util.Collections.emptyMap) TableLayout(com.facebook.presto.metadata.TableLayout) CaseFormat(com.google.common.base.CaseFormat) Signature(com.facebook.presto.metadata.Signature) HashCollisionsInfo(com.facebook.presto.operator.HashCollisionsInfo) ComparisonExpression(com.facebook.presto.sql.tree.ComparisonExpression) DeleteNode(com.facebook.presto.sql.planner.plan.DeleteNode) ProjectNode(com.facebook.presto.sql.planner.plan.ProjectNode) UPPER_UNDERSCORE(com.google.common.base.CaseFormat.UPPER_UNDERSCORE) Collectors.toList(java.util.stream.Collectors.toList) UnionNode(com.facebook.presto.sql.planner.plan.UnionNode) Expression(com.facebook.presto.sql.tree.Expression) TableHandle(com.facebook.presto.metadata.TableHandle) TableFinishNode(com.facebook.presto.sql.planner.plan.TableFinishNode) BYTE(io.airlift.units.DataSize.Unit.BYTE) IntersectNode(com.facebook.presto.sql.planner.plan.IntersectNode) EnforceSingleRowNode(com.facebook.presto.sql.planner.plan.EnforceSingleRowNode) ExchangeNode(com.facebook.presto.sql.planner.plan.ExchangeNode) PlanNodeId(com.facebook.presto.sql.planner.plan.PlanNodeId) TaskInfo(com.facebook.presto.execution.TaskInfo) HashMap(java.util.HashMap) StageInfo(com.facebook.presto.execution.StageInfo)

Example 7 with TaskInfo

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();
}
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 8 with TaskInfo

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();
}
Also used : BufferInfo(com.facebook.presto.execution.buffer.BufferInfo) StageInfo(com.facebook.presto.execution.StageInfo) ArrayList(java.util.ArrayList) QueryInfo(com.facebook.presto.execution.QueryInfo) TaskStatus(com.facebook.presto.execution.TaskStatus) TaskInfo(com.facebook.presto.execution.TaskInfo) NoSuchElementException(java.util.NoSuchElementException) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 9 with TaskInfo

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();
}
Also used : TaskInfo(com.facebook.presto.execution.TaskInfo) Session(com.facebook.presto.Session) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces)

Example 10 with TaskInfo

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();
}
Also used : TaskInfo(com.facebook.presto.execution.TaskInfo) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) Produces(javax.ws.rs.Produces)

Aggregations

TaskInfo (com.facebook.presto.execution.TaskInfo)11 Path (javax.ws.rs.Path)5 Produces (javax.ws.rs.Produces)5 StageInfo (com.facebook.presto.execution.StageInfo)4 TaskStats (com.facebook.presto.operator.TaskStats)4 TaskStatus (com.facebook.presto.execution.TaskStatus)3 Duration (io.airlift.units.Duration)3 Session (com.facebook.presto.Session)2 NodeVersion (com.facebook.presto.client.NodeVersion)2 QueryInfo (com.facebook.presto.execution.QueryInfo)2 QueryStats (com.facebook.presto.execution.QueryStats)2 TaskId (com.facebook.presto.execution.TaskId)2 TaskState (com.facebook.presto.execution.TaskState)2 OperatorStats (com.facebook.presto.operator.OperatorStats)2 TransactionId (com.facebook.presto.transaction.TransactionId)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)2 Throwables (com.google.common.base.Throwables)2 ImmutableList (com.google.common.collect.ImmutableList)2 ImmutableMap (com.google.common.collect.ImmutableMap)2 List (java.util.List)2