Search in sources :

Example 1 with PipelineStatus

use of com.facebook.presto.operator.PipelineStatus in project presto by prestodb.

the class SqlTask method createTaskStatus.

private TaskStatus createTaskStatus(TaskHolder taskHolder) {
    long taskStatusAgeInMilis = System.currentTimeMillis() - creationTimeInMillis;
    // Always return a new TaskInfo with a larger version number;
    // otherwise a client will not accept the update
    long versionNumber = nextTaskInfoVersion.getAndIncrement();
    TaskState state = taskStateMachine.getState();
    List<ExecutionFailureInfo> failures = ImmutableList.of();
    if (state == FAILED) {
        failures = toFailures(taskStateMachine.getFailureCauses());
    }
    int queuedPartitionedDrivers = 0;
    long queuedPartitionedSplitsWeight = 0L;
    int runningPartitionedDrivers = 0;
    long runningPartitionedSplitsWeight = 0L;
    long physicalWrittenDataSizeInBytes = 0L;
    long userMemoryReservationInBytes = 0L;
    long systemMemoryReservationInBytes = 0L;
    // TODO: add a mechanism to avoid sending the whole completedDriverGroups set over the wire for every task status reply
    Set<Lifespan> completedDriverGroups = ImmutableSet.of();
    long fullGcCount = 0;
    long fullGcTimeInMillis = 0L;
    long totalCpuTimeInNanos = 0L;
    if (taskHolder.getFinalTaskInfo() != null) {
        TaskStats taskStats = taskHolder.getFinalTaskInfo().getStats();
        queuedPartitionedDrivers = taskStats.getQueuedPartitionedDrivers();
        queuedPartitionedSplitsWeight = taskStats.getQueuedPartitionedSplitsWeight();
        runningPartitionedDrivers = taskStats.getRunningPartitionedDrivers();
        runningPartitionedSplitsWeight = taskStats.getRunningPartitionedSplitsWeight();
        physicalWrittenDataSizeInBytes = taskStats.getPhysicalWrittenDataSizeInBytes();
        userMemoryReservationInBytes = taskStats.getUserMemoryReservationInBytes();
        systemMemoryReservationInBytes = taskStats.getSystemMemoryReservationInBytes();
        fullGcCount = taskStats.getFullGcCount();
        fullGcTimeInMillis = taskStats.getFullGcTimeInMillis();
        totalCpuTimeInNanos = taskStats.getTotalCpuTimeInNanos();
    } else if (taskHolder.getTaskExecution() != null) {
        long physicalWrittenBytes = 0;
        TaskContext taskContext = taskHolder.getTaskExecution().getTaskContext();
        for (PipelineContext pipelineContext : taskContext.getPipelineContexts()) {
            PipelineStatus pipelineStatus = pipelineContext.getPipelineStatus();
            queuedPartitionedDrivers += pipelineStatus.getQueuedPartitionedDrivers();
            queuedPartitionedSplitsWeight += pipelineStatus.getQueuedPartitionedSplitsWeight();
            runningPartitionedDrivers += pipelineStatus.getRunningPartitionedDrivers();
            runningPartitionedSplitsWeight += pipelineStatus.getRunningPartitionedSplitsWeight();
            physicalWrittenBytes += pipelineContext.getPhysicalWrittenDataSize();
            totalCpuTimeInNanos += pipelineContext.getPipelineStats().getTotalCpuTimeInNanos();
        }
        physicalWrittenDataSizeInBytes = physicalWrittenBytes;
        userMemoryReservationInBytes = taskContext.getMemoryReservation().toBytes();
        systemMemoryReservationInBytes = taskContext.getSystemMemoryReservation().toBytes();
        completedDriverGroups = taskContext.getCompletedDriverGroups();
        fullGcCount = taskContext.getFullGcCount();
        fullGcTimeInMillis = taskContext.getFullGcTime().toMillis();
    }
    return new TaskStatus(taskInstanceId.getUuidLeastSignificantBits(), taskInstanceId.getUuidMostSignificantBits(), versionNumber, state, location, completedDriverGroups, failures, queuedPartitionedDrivers, runningPartitionedDrivers, outputBuffer.getUtilization(), isOutputBufferOverutilized(), physicalWrittenDataSizeInBytes, userMemoryReservationInBytes, systemMemoryReservationInBytes, queryContext.getPeakNodeTotalMemory(), fullGcCount, fullGcTimeInMillis, totalCpuTimeInNanos, taskStatusAgeInMilis, queuedPartitionedSplitsWeight, runningPartitionedSplitsWeight);
}
Also used : PipelineStatus(com.facebook.presto.operator.PipelineStatus) TaskContext(com.facebook.presto.operator.TaskContext) PipelineContext(com.facebook.presto.operator.PipelineContext) TaskStats(com.facebook.presto.operator.TaskStats)

Aggregations

PipelineContext (com.facebook.presto.operator.PipelineContext)1 PipelineStatus (com.facebook.presto.operator.PipelineStatus)1 TaskContext (com.facebook.presto.operator.TaskContext)1 TaskStats (com.facebook.presto.operator.TaskStats)1