Search in sources :

Example 1 with StageGcStatistics

use of com.facebook.presto.spi.eventlistener.StageGcStatistics in project presto by prestodb.

the class TestQueryStats method assertExpectedQueryStats.

private static void assertExpectedQueryStats(QueryStats actual) {
    assertEquals(actual.getCreateTime(), new DateTime(1, UTC));
    assertEquals(actual.getExecutionStartTime(), new DateTime(2, UTC));
    assertEquals(actual.getLastHeartbeat(), new DateTime(3, UTC));
    assertEquals(actual.getEndTime(), new DateTime(4, UTC));
    assertEquals(actual.getElapsedTime(), new Duration(6, NANOSECONDS));
    assertEquals(actual.getQueuedTime(), new Duration(5, NANOSECONDS));
    assertEquals(actual.getResourceWaitingTime(), new Duration(31, NANOSECONDS));
    assertEquals(actual.getSemanticAnalyzingTime(), new Duration(15, NANOSECONDS));
    assertEquals(actual.getColumnAccessPermissionCheckingTime(), new Duration(15, NANOSECONDS));
    assertEquals(actual.getDispatchingTime(), new Duration(32, NANOSECONDS));
    assertEquals(actual.getExecutionTime(), new Duration(41, NANOSECONDS));
    assertEquals(actual.getAnalysisTime(), new Duration(7, NANOSECONDS));
    assertEquals(actual.getTotalPlanningTime(), new Duration(100, NANOSECONDS));
    assertEquals(actual.getFinishingTime(), new Duration(200, NANOSECONDS));
    assertEquals(actual.getTotalTasks(), 9);
    assertEquals(actual.getRunningTasks(), 10);
    assertEquals(actual.getPeakRunningTasks(), 11);
    assertEquals(actual.getCompletedTasks(), 11);
    assertEquals(actual.getTotalDrivers(), 12);
    assertEquals(actual.getQueuedDrivers(), 13);
    assertEquals(actual.getRunningDrivers(), 15);
    assertEquals(actual.getBlockedDrivers(), 30);
    assertEquals(actual.getCompletedDrivers(), 16);
    assertEquals(actual.getCumulativeUserMemory(), 17.0);
    assertEquals(actual.getUserMemoryReservation(), new DataSize(18, BYTE));
    assertEquals(actual.getTotalMemoryReservation(), new DataSize(19, BYTE));
    assertEquals(actual.getPeakUserMemoryReservation(), new DataSize(20, BYTE));
    assertEquals(actual.getPeakTotalMemoryReservation(), new DataSize(21, BYTE));
    assertEquals(actual.getPeakTaskUserMemory(), new DataSize(22, BYTE));
    assertEquals(actual.getPeakTaskTotalMemory(), new DataSize(23, BYTE));
    assertEquals(actual.getSpilledDataSize(), new DataSize(690, BYTE));
    assertEquals(actual.getTotalScheduledTime(), new Duration(20, NANOSECONDS));
    assertEquals(actual.getTotalCpuTime(), new Duration(21, NANOSECONDS));
    assertEquals(actual.getTotalBlockedTime(), new Duration(23, NANOSECONDS));
    assertEquals(actual.getTotalAllocation(), new DataSize(123, BYTE));
    assertEquals(actual.getRawInputDataSize(), new DataSize(24, BYTE));
    assertEquals(actual.getRawInputPositions(), 25);
    assertEquals(actual.getProcessedInputDataSize(), new DataSize(26, BYTE));
    assertEquals(actual.getProcessedInputPositions(), 27);
    assertEquals(actual.getOutputDataSize(), new DataSize(28, BYTE));
    assertEquals(actual.getOutputPositions(), 29);
    assertEquals(actual.getWrittenOutputPositions(), 30);
    assertEquals(actual.getWrittenOutputLogicalDataSize(), new DataSize(31, BYTE));
    assertEquals(actual.getWrittenOutputPhysicalDataSize(), new DataSize(32, BYTE));
    assertEquals(actual.getWrittenIntermediatePhysicalDataSize(), new DataSize(33, BYTE));
    assertEquals(actual.getStageGcStatistics().size(), 1);
    StageGcStatistics gcStatistics = actual.getStageGcStatistics().get(0);
    assertEquals(gcStatistics.getStageId(), 101);
    assertEquals(gcStatistics.getStageExecutionId(), 1001);
    assertEquals(gcStatistics.getTasks(), 102);
    assertEquals(gcStatistics.getFullGcTasks(), 103);
    assertEquals(gcStatistics.getMinFullGcSec(), 104);
    assertEquals(gcStatistics.getMaxFullGcSec(), 105);
    assertEquals(gcStatistics.getTotalFullGcSec(), 106);
    assertEquals(gcStatistics.getAverageFullGcSec(), 107);
    assertRuntimeMetricEquals(actual.getRuntimeStats().getMetric(TEST_METRIC_NAME), RuntimeMetric.merge(TEST_RUNTIME_METRIC_1, TEST_RUNTIME_METRIC_2));
}
Also used : DataSize(io.airlift.units.DataSize) Duration(io.airlift.units.Duration) StageGcStatistics(com.facebook.presto.spi.eventlistener.StageGcStatistics) DateTime(org.joda.time.DateTime)

Example 2 with StageGcStatistics

use of com.facebook.presto.spi.eventlistener.StageGcStatistics in project presto by prestodb.

the class StageExecutionInfo method create.

public static StageExecutionInfo create(StageExecutionId stageExecutionId, StageExecutionState state, Optional<ExecutionFailureInfo> failureInfo, List<TaskInfo> taskInfos, DateTime schedulingComplete, DistributionSnapshot getSplitDistribution, DataSize peakUserMemoryReservation, DataSize peakNodeTotalMemoryReservation, int finishedLifespans, int totalLifespans) {
    int totalTasks = taskInfos.size();
    int runningTasks = 0;
    int completedTasks = 0;
    int totalDrivers = 0;
    int queuedDrivers = 0;
    int runningDrivers = 0;
    int blockedDrivers = 0;
    int completedDrivers = 0;
    double cumulativeUserMemory = 0;
    double cumulativeTotalMemory = 0;
    long userMemoryReservation = 0;
    long totalMemoryReservation = 0;
    long totalScheduledTime = 0;
    long totalCpuTime = 0;
    long retriedCpuTime = 0;
    long totalBlockedTime = 0;
    long totalAllocation = 0;
    long rawInputDataSize = 0;
    long rawInputPositions = 0;
    long processedInputDataSize = 0;
    long processedInputPositions = 0;
    long bufferedDataSize = 0;
    long outputDataSize = 0;
    long outputPositions = 0;
    long physicalWrittenDataSize = 0;
    int fullGcCount = 0;
    int fullGcTaskCount = 0;
    int minFullGcSec = 0;
    int maxFullGcSec = 0;
    int totalFullGcSec = 0;
    boolean fullyBlocked = true;
    Set<BlockedReason> blockedReasons = new HashSet<>();
    Map<String, OperatorStats> operatorToStats = new HashMap<>();
    RuntimeStats mergedRuntimeStats = new RuntimeStats();
    mergedRuntimeStats.addMetricValueIgnoreZero(GET_SPLITS_TIME_NANOS, (long) getSplitDistribution.getTotal());
    for (TaskInfo taskInfo : taskInfos) {
        TaskState taskState = taskInfo.getTaskStatus().getState();
        if (taskState.isDone()) {
            completedTasks++;
        } else {
            runningTasks++;
        }
        TaskStats taskStats = taskInfo.getStats();
        totalDrivers += taskStats.getTotalDrivers();
        queuedDrivers += taskStats.getQueuedDrivers();
        runningDrivers += taskStats.getRunningDrivers();
        blockedDrivers += taskStats.getBlockedDrivers();
        completedDrivers += taskStats.getCompletedDrivers();
        cumulativeUserMemory += taskStats.getCumulativeUserMemory();
        cumulativeTotalMemory += taskStats.getCumulativeTotalMemory();
        long taskUserMemory = taskStats.getUserMemoryReservationInBytes();
        long taskSystemMemory = taskStats.getSystemMemoryReservationInBytes();
        userMemoryReservation += taskUserMemory;
        totalMemoryReservation += taskUserMemory + taskSystemMemory;
        totalScheduledTime += taskStats.getTotalScheduledTimeInNanos();
        totalCpuTime += taskStats.getTotalCpuTimeInNanos();
        if (state == FINISHED && taskInfo.getTaskStatus().getState() == TaskState.FAILED) {
            retriedCpuTime += taskStats.getTotalCpuTimeInNanos();
        }
        totalBlockedTime += taskStats.getTotalBlockedTimeInNanos();
        if (!taskState.isDone()) {
            fullyBlocked &= taskStats.isFullyBlocked();
            blockedReasons.addAll(taskStats.getBlockedReasons());
        }
        totalAllocation += taskStats.getTotalAllocationInBytes();
        rawInputDataSize += taskStats.getRawInputDataSizeInBytes();
        rawInputPositions += taskStats.getRawInputPositions();
        processedInputDataSize += taskStats.getProcessedInputDataSizeInBytes();
        processedInputPositions += taskStats.getProcessedInputPositions();
        bufferedDataSize += taskInfo.getOutputBuffers().getTotalBufferedBytes();
        outputDataSize += taskStats.getOutputDataSizeInBytes();
        outputPositions += taskStats.getOutputPositions();
        physicalWrittenDataSize += taskStats.getPhysicalWrittenDataSizeInBytes();
        fullGcCount += taskStats.getFullGcCount();
        fullGcTaskCount += taskStats.getFullGcCount() > 0 ? 1 : 0;
        int gcSec = toIntExact(MILLISECONDS.toSeconds(taskStats.getFullGcTimeInMillis()));
        totalFullGcSec += gcSec;
        minFullGcSec = min(minFullGcSec, gcSec);
        maxFullGcSec = max(maxFullGcSec, gcSec);
        for (PipelineStats pipeline : taskStats.getPipelines()) {
            for (OperatorStats operatorStats : pipeline.getOperatorSummaries()) {
                String id = pipeline.getPipelineId() + "." + operatorStats.getOperatorId();
                operatorToStats.compute(id, (k, v) -> v == null ? operatorStats : v.add(operatorStats));
            }
        }
        mergedRuntimeStats.mergeWith(taskStats.getRuntimeStats());
        mergedRuntimeStats.addMetricValue(RuntimeMetricName.DRIVER_COUNT_PER_TASK, taskStats.getTotalDrivers());
        mergedRuntimeStats.addMetricValue(RuntimeMetricName.TASK_ELAPSED_TIME_NANOS, taskStats.getElapsedTimeInNanos());
        mergedRuntimeStats.addMetricValueIgnoreZero(RuntimeMetricName.TASK_QUEUED_TIME_NANOS, taskStats.getQueuedTimeInNanos());
        mergedRuntimeStats.addMetricValue(RuntimeMetricName.TASK_SCHEDULED_TIME_NANOS, taskStats.getTotalScheduledTimeInNanos());
        mergedRuntimeStats.addMetricValueIgnoreZero(RuntimeMetricName.TASK_BLOCKED_TIME_NANOS, taskStats.getTotalBlockedTimeInNanos());
    }
    StageExecutionStats stageExecutionStats = new StageExecutionStats(schedulingComplete, getSplitDistribution, totalTasks, runningTasks, completedTasks, totalLifespans, finishedLifespans, totalDrivers, queuedDrivers, runningDrivers, blockedDrivers, completedDrivers, cumulativeUserMemory, cumulativeTotalMemory, succinctBytes(userMemoryReservation), succinctBytes(totalMemoryReservation), peakUserMemoryReservation, peakNodeTotalMemoryReservation, succinctDuration(totalScheduledTime, NANOSECONDS), succinctDuration(totalCpuTime, NANOSECONDS), succinctDuration(retriedCpuTime, NANOSECONDS), succinctDuration(totalBlockedTime, NANOSECONDS), fullyBlocked && runningTasks > 0, blockedReasons, succinctBytes(totalAllocation), succinctBytes(rawInputDataSize), rawInputPositions, succinctBytes(processedInputDataSize), processedInputPositions, succinctBytes(bufferedDataSize), succinctBytes(outputDataSize), outputPositions, succinctBytes(physicalWrittenDataSize), new StageGcStatistics(stageExecutionId.getStageId().getId(), stageExecutionId.getId(), totalTasks, fullGcTaskCount, minFullGcSec, maxFullGcSec, totalFullGcSec, (int) (1.0 * totalFullGcSec / fullGcCount)), ImmutableList.copyOf(operatorToStats.values()), mergedRuntimeStats);
    return new StageExecutionInfo(state, stageExecutionStats, taskInfos, failureInfo);
}
Also used : PipelineStats(com.facebook.presto.operator.PipelineStats) BlockedReason(com.facebook.presto.operator.BlockedReason) HashMap(java.util.HashMap) RuntimeStats(com.facebook.presto.common.RuntimeStats) OperatorStats(com.facebook.presto.operator.OperatorStats) TaskStats(com.facebook.presto.operator.TaskStats) StageGcStatistics(com.facebook.presto.spi.eventlistener.StageGcStatistics) HashSet(java.util.HashSet)

Example 3 with StageGcStatistics

use of com.facebook.presto.spi.eventlistener.StageGcStatistics in project presto by prestodb.

the class QueryStats method create.

public static QueryStats create(QueryStateTimer queryStateTimer, Optional<StageInfo> rootStage, int peakRunningTasks, DataSize peakUserMemoryReservation, DataSize peakTotalMemoryReservation, DataSize peakTaskUserMemory, DataSize peakTaskTotalMemory, DataSize peakNodeTotalMemory, RuntimeStats runtimeStats) {
    int totalTasks = 0;
    int runningTasks = 0;
    int completedTasks = 0;
    int totalDrivers = 0;
    int queuedDrivers = 0;
    int runningDrivers = 0;
    int blockedDrivers = 0;
    int completedDrivers = 0;
    double cumulativeUserMemory = 0;
    double cumulativeTotalMemory = 0;
    long userMemoryReservation = 0;
    long totalMemoryReservation = 0;
    long totalScheduledTime = 0;
    long totalCpuTime = 0;
    long retriedCpuTime = 0;
    long totalBlockedTime = 0;
    long totalAllocation = 0;
    long rawInputDataSize = 0;
    long rawInputPositions = 0;
    long processedInputDataSize = 0;
    long processedInputPositions = 0;
    long outputDataSize = 0;
    long outputPositions = 0;
    long writtenOutputPositions = 0;
    long writtenOutputLogicalDataSize = 0;
    long writtenOutputPhysicalDataSize = 0;
    long writtenIntermediatePhysicalDataSize = 0;
    ImmutableList.Builder<StageGcStatistics> stageGcStatistics = ImmutableList.builder();
    boolean fullyBlocked = rootStage.isPresent();
    Set<BlockedReason> blockedReasons = new HashSet<>();
    ImmutableList.Builder<OperatorStats> operatorStatsSummary = ImmutableList.builder();
    boolean completeInfo = true;
    RuntimeStats mergedRuntimeStats = RuntimeStats.copyOf(runtimeStats);
    for (StageInfo stageInfo : getAllStages(rootStage)) {
        StageExecutionStats stageExecutionStats = stageInfo.getLatestAttemptExecutionInfo().getStats();
        totalTasks += stageExecutionStats.getTotalTasks();
        runningTasks += stageExecutionStats.getRunningTasks();
        completedTasks += stageExecutionStats.getCompletedTasks();
        totalDrivers += stageExecutionStats.getTotalDrivers();
        queuedDrivers += stageExecutionStats.getQueuedDrivers();
        runningDrivers += stageExecutionStats.getRunningDrivers();
        blockedDrivers += stageExecutionStats.getBlockedDrivers();
        completedDrivers += stageExecutionStats.getCompletedDrivers();
        cumulativeUserMemory += stageExecutionStats.getCumulativeUserMemory();
        cumulativeTotalMemory += stageExecutionStats.getCumulativeTotalMemory();
        userMemoryReservation += stageExecutionStats.getUserMemoryReservation().toBytes();
        totalMemoryReservation += stageExecutionStats.getTotalMemoryReservation().toBytes();
        totalScheduledTime += stageExecutionStats.getTotalScheduledTime().roundTo(MILLISECONDS);
        totalCpuTime += stageExecutionStats.getTotalCpuTime().roundTo(MILLISECONDS);
        retriedCpuTime += computeRetriedCpuTime(stageInfo);
        totalBlockedTime += stageExecutionStats.getTotalBlockedTime().roundTo(MILLISECONDS);
        if (!stageInfo.getLatestAttemptExecutionInfo().getState().isDone()) {
            fullyBlocked &= stageExecutionStats.isFullyBlocked();
            blockedReasons.addAll(stageExecutionStats.getBlockedReasons());
        }
        totalAllocation += stageExecutionStats.getTotalAllocation().toBytes();
        if (stageInfo.getPlan().isPresent()) {
            PlanFragment plan = stageInfo.getPlan().get();
            if (!plan.getTableScanSchedulingOrder().isEmpty()) {
                rawInputDataSize += stageExecutionStats.getRawInputDataSize().toBytes();
                rawInputPositions += stageExecutionStats.getRawInputPositions();
                processedInputDataSize += stageExecutionStats.getProcessedInputDataSize().toBytes();
                processedInputPositions += stageExecutionStats.getProcessedInputPositions();
            }
            if (plan.isOutputTableWriterFragment()) {
                writtenOutputPositions += stageExecutionStats.getOperatorSummaries().stream().filter(stats -> stats.getOperatorType().equals(TableWriterOperator.class.getSimpleName())).mapToLong(OperatorStats::getInputPositions).sum();
                writtenOutputLogicalDataSize += stageExecutionStats.getOperatorSummaries().stream().filter(stats -> stats.getOperatorType().equals(TableWriterOperator.class.getSimpleName())).mapToLong(stats -> stats.getInputDataSize().toBytes()).sum();
                writtenOutputPhysicalDataSize += stageExecutionStats.getPhysicalWrittenDataSize().toBytes();
            } else {
                writtenIntermediatePhysicalDataSize += stageExecutionStats.getPhysicalWrittenDataSize().toBytes();
            }
        }
        stageGcStatistics.add(stageExecutionStats.getGcInfo());
        completeInfo = completeInfo && stageInfo.isFinalStageInfo();
        operatorStatsSummary.addAll(stageExecutionStats.getOperatorSummaries());
        // We prepend each metric name with the stage id to avoid merging metrics across stages.
        int stageId = stageInfo.getStageId().getId();
        stageExecutionStats.getRuntimeStats().getMetrics().forEach((name, metric) -> {
            String metricName = String.format("S%d-%s", stageId, name);
            mergedRuntimeStats.mergeMetric(metricName, metric);
        });
    }
    if (rootStage.isPresent()) {
        StageExecutionStats outputStageStats = rootStage.get().getLatestAttemptExecutionInfo().getStats();
        outputDataSize += outputStageStats.getOutputDataSize().toBytes();
        outputPositions += outputStageStats.getOutputPositions();
    }
    return new QueryStats(queryStateTimer.getCreateTime(), queryStateTimer.getExecutionStartTime().orElse(null), queryStateTimer.getLastHeartbeat(), queryStateTimer.getEndTime().orElse(null), queryStateTimer.getElapsedTime(), queryStateTimer.getWaitingForPrerequisitesTime(), queryStateTimer.getQueuedTime(), queryStateTimer.getResourceWaitingTime(), queryStateTimer.getSemanticAnalyzingTime(), queryStateTimer.getColumnAccessPermissionCheckingTime(), queryStateTimer.getDispatchingTime(), queryStateTimer.getExecutionTime(), queryStateTimer.getAnalysisTime(), queryStateTimer.getPlanningTime(), queryStateTimer.getFinishingTime(), totalTasks, runningTasks, peakRunningTasks, completedTasks, totalDrivers, queuedDrivers, runningDrivers, blockedDrivers, completedDrivers, cumulativeUserMemory, cumulativeTotalMemory, succinctBytes(userMemoryReservation), succinctBytes(totalMemoryReservation), peakUserMemoryReservation, peakTotalMemoryReservation, peakTaskUserMemory, peakTaskTotalMemory, peakNodeTotalMemory, isScheduled(rootStage), succinctDuration(totalScheduledTime, MILLISECONDS), succinctDuration(totalCpuTime, MILLISECONDS), succinctDuration(retriedCpuTime, MILLISECONDS), succinctDuration(totalBlockedTime, MILLISECONDS), fullyBlocked, blockedReasons, succinctBytes(totalAllocation), succinctBytes(rawInputDataSize), rawInputPositions, succinctBytes(processedInputDataSize), processedInputPositions, succinctBytes(outputDataSize), outputPositions, writtenOutputPositions, succinctBytes(writtenOutputLogicalDataSize), succinctBytes(writtenOutputPhysicalDataSize), succinctBytes(writtenIntermediatePhysicalDataSize), stageGcStatistics.build(), operatorStatsSummary.build(), mergedRuntimeStats);
}
Also used : JsonProperty(com.fasterxml.jackson.annotation.JsonProperty) OptionalDouble(java.util.OptionalDouble) DataSize.succinctBytes(io.airlift.units.DataSize.succinctBytes) StageGcStatistics(com.facebook.presto.spi.eventlistener.StageGcStatistics) Duration(io.airlift.units.Duration) OperatorStats(com.facebook.presto.operator.OperatorStats) HashSet(java.util.HashSet) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) PlanFragment(com.facebook.presto.sql.planner.PlanFragment) ImmutableList(com.google.common.collect.ImmutableList) Objects.requireNonNull(java.util.Objects.requireNonNull) RuntimeStats(com.facebook.presto.common.RuntimeStats) Duration.succinctDuration(io.airlift.units.Duration.succinctDuration) Nullable(javax.annotation.Nullable) StageInfo.getAllStages(com.facebook.presto.execution.StageInfo.getAllStages) BlockedReason(com.facebook.presto.operator.BlockedReason) ImmutableSet(com.google.common.collect.ImmutableSet) DateTime(org.joda.time.DateTime) Set(java.util.Set) Math.min(java.lang.Math.min) MILLISECONDS(java.util.concurrent.TimeUnit.MILLISECONDS) TableWriterOperator(com.facebook.presto.operator.TableWriterOperator) DataSize(io.airlift.units.DataSize) List(java.util.List) JsonCreator(com.fasterxml.jackson.annotation.JsonCreator) Optional(java.util.Optional) BYTE(io.airlift.units.DataSize.Unit.BYTE) BlockedReason(com.facebook.presto.operator.BlockedReason) ImmutableList(com.google.common.collect.ImmutableList) RuntimeStats(com.facebook.presto.common.RuntimeStats) OperatorStats(com.facebook.presto.operator.OperatorStats) PlanFragment(com.facebook.presto.sql.planner.PlanFragment) TableWriterOperator(com.facebook.presto.operator.TableWriterOperator) StageGcStatistics(com.facebook.presto.spi.eventlistener.StageGcStatistics) HashSet(java.util.HashSet)

Example 4 with StageGcStatistics

use of com.facebook.presto.spi.eventlistener.StageGcStatistics in project presto by prestodb.

the class TestBasicQueryInfo method testConstructor.

@Test
public void testConstructor() {
    BasicQueryInfo basicInfo = new BasicQueryInfo(new QueryInfo(new QueryId("0"), TEST_SESSION.toSessionRepresentation(), RUNNING, new MemoryPoolId("reserved"), false, URI.create("1"), ImmutableList.of("2", "3"), "SELECT 4", Optional.empty(), Optional.empty(), new QueryStats(DateTime.parse("1991-09-06T05:00-05:30"), DateTime.parse("1991-09-06T05:01-05:30"), DateTime.parse("1991-09-06T05:02-05:30"), DateTime.parse("1991-09-06T06:00-05:30"), Duration.valueOf("8m"), Duration.valueOf("5m"), Duration.valueOf("7m"), Duration.valueOf("34m"), Duration.valueOf("5m"), Duration.valueOf("6m"), Duration.valueOf("35m"), Duration.valueOf("44m"), Duration.valueOf("9m"), Duration.valueOf("10m"), Duration.valueOf("11m"), 13, 14, 21, 15, 16, 17, 18, 34, 19, 20.0, 43.0, DataSize.valueOf("21GB"), DataSize.valueOf("22GB"), DataSize.valueOf("23GB"), DataSize.valueOf("24GB"), DataSize.valueOf("25GB"), DataSize.valueOf("26GB"), DataSize.valueOf("42GB"), true, Duration.valueOf("23m"), Duration.valueOf("24m"), Duration.valueOf("0m"), Duration.valueOf("26m"), true, ImmutableSet.of(BlockedReason.WAITING_FOR_MEMORY), DataSize.valueOf("123MB"), DataSize.valueOf("27GB"), 28, DataSize.valueOf("29GB"), 30, DataSize.valueOf("31GB"), 32, 33, DataSize.valueOf("34GB"), DataSize.valueOf("35GB"), DataSize.valueOf("36GB"), ImmutableList.of(new StageGcStatistics(101, 1002, 102, 103, 104, 105, 106, 107)), ImmutableList.of(), new RuntimeStats()), Optional.empty(), Optional.empty(), ImmutableMap.of(), ImmutableSet.of(), ImmutableMap.of(), ImmutableMap.of(), ImmutableSet.of(), Optional.empty(), false, "33", Optional.empty(), null, StandardErrorCode.ABANDONED_QUERY.toErrorCode(), ImmutableList.of(), ImmutableSet.of(), Optional.empty(), false, Optional.empty(), Optional.of(QueryType.INSERT), Optional.empty(), Optional.empty(), ImmutableMap.of(), ImmutableSet.of()));
    assertEquals(basicInfo.getQueryId().getId(), "0");
    assertEquals(basicInfo.getState(), RUNNING);
    assertEquals(basicInfo.getMemoryPool().getId(), "reserved");
    assertEquals(basicInfo.isScheduled(), false);
    assertEquals(basicInfo.getQuery(), "SELECT 4");
    assertEquals(basicInfo.getQueryType(), Optional.of(QueryType.INSERT));
    assertEquals(basicInfo.getQueryStats().getCreateTime(), DateTime.parse("1991-09-06T05:00-05:30"));
    assertEquals(basicInfo.getQueryStats().getEndTime(), DateTime.parse("1991-09-06T06:00-05:30"));
    assertEquals(basicInfo.getQueryStats().getElapsedTime(), Duration.valueOf("8m"));
    assertEquals(basicInfo.getQueryStats().getExecutionTime(), Duration.valueOf("44m"));
    assertEquals(basicInfo.getQueryStats().getWaitingForPrerequisitesTime(), Duration.valueOf("5m"));
    assertEquals(basicInfo.getQueryStats().getTotalDrivers(), 16);
    assertEquals(basicInfo.getQueryStats().getQueuedDrivers(), 17);
    assertEquals(basicInfo.getQueryStats().getRunningDrivers(), 18);
    assertEquals(basicInfo.getQueryStats().getCompletedDrivers(), 19);
    assertEquals(basicInfo.getQueryStats().getCumulativeUserMemory(), 20.0);
    assertEquals(basicInfo.getQueryStats().getUserMemoryReservation(), DataSize.valueOf("21GB"));
    assertEquals(basicInfo.getQueryStats().getPeakUserMemoryReservation(), DataSize.valueOf("23GB"));
    assertEquals(basicInfo.getQueryStats().getPeakTotalMemoryReservation(), DataSize.valueOf("24GB"));
    assertEquals(basicInfo.getQueryStats().getPeakTaskTotalMemoryReservation(), DataSize.valueOf("26GB"));
    assertEquals(basicInfo.getQueryStats().getPeakNodeTotalMemorReservation(), DataSize.valueOf("42GB"));
    assertEquals(basicInfo.getQueryStats().getTotalCpuTime(), Duration.valueOf("24m"));
    assertEquals(basicInfo.getQueryStats().isFullyBlocked(), true);
    assertEquals(basicInfo.getQueryStats().getBlockedReasons(), ImmutableSet.of(BlockedReason.WAITING_FOR_MEMORY));
    assertEquals(basicInfo.getQueryStats().getTotalAllocation(), DataSize.valueOf("123MB"));
    assertEquals(basicInfo.getQueryStats().getProgressPercentage(), OptionalDouble.of(100));
    assertEquals(basicInfo.getErrorCode(), StandardErrorCode.ABANDONED_QUERY.toErrorCode());
    assertEquals(basicInfo.getErrorType(), StandardErrorCode.ABANDONED_QUERY.toErrorCode().getType());
}
Also used : QueryStats(com.facebook.presto.execution.QueryStats) RuntimeStats(com.facebook.presto.common.RuntimeStats) QueryId(com.facebook.presto.spi.QueryId) QueryInfo(com.facebook.presto.execution.QueryInfo) StageGcStatistics(com.facebook.presto.spi.eventlistener.StageGcStatistics) MemoryPoolId(com.facebook.presto.spi.memory.MemoryPoolId) Test(org.testng.annotations.Test)

Aggregations

StageGcStatistics (com.facebook.presto.spi.eventlistener.StageGcStatistics)4 RuntimeStats (com.facebook.presto.common.RuntimeStats)3 BlockedReason (com.facebook.presto.operator.BlockedReason)2 OperatorStats (com.facebook.presto.operator.OperatorStats)2 DataSize (io.airlift.units.DataSize)2 Duration (io.airlift.units.Duration)2 HashSet (java.util.HashSet)2 DateTime (org.joda.time.DateTime)2 QueryInfo (com.facebook.presto.execution.QueryInfo)1 QueryStats (com.facebook.presto.execution.QueryStats)1 StageInfo.getAllStages (com.facebook.presto.execution.StageInfo.getAllStages)1 PipelineStats (com.facebook.presto.operator.PipelineStats)1 TableWriterOperator (com.facebook.presto.operator.TableWriterOperator)1 TaskStats (com.facebook.presto.operator.TaskStats)1 QueryId (com.facebook.presto.spi.QueryId)1 MemoryPoolId (com.facebook.presto.spi.memory.MemoryPoolId)1 PlanFragment (com.facebook.presto.sql.planner.PlanFragment)1 JsonCreator (com.fasterxml.jackson.annotation.JsonCreator)1 JsonProperty (com.fasterxml.jackson.annotation.JsonProperty)1 Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)1