Search in sources :

Example 1 with PipelineStatus

use of io.prestosql.operator.PipelineStatus in project hetu-core by openlookeng.

the class SqlTask method createTaskStatus.

private TaskStatus createTaskStatus(TaskHolder taskHolder) {
    // 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;
    int runningPartitionedDrivers = 0;
    DataSize physicalWrittenDataSize = new DataSize(0, BYTE);
    DataSize userMemoryReservation = new DataSize(0, BYTE);
    DataSize systemMemoryReservation = new DataSize(0, BYTE);
    DataSize revocableMemoryReservation = new DataSize(0, BYTE);
    // 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;
    Duration fullGcTime = new Duration(0, MILLISECONDS);
    Map<Long, SnapshotInfo> snapshotCaptureResult = ImmutableMap.of();
    Optional<RestoreResult> snapshotRestoreResult = Optional.empty();
    TaskInfo finalTaskInfo = taskHolder.getFinalTaskInfo();
    if (finalTaskInfo != null) {
        TaskStats taskStats = finalTaskInfo.getStats();
        queuedPartitionedDrivers = taskStats.getQueuedPartitionedDrivers();
        runningPartitionedDrivers = taskStats.getRunningPartitionedDrivers();
        physicalWrittenDataSize = taskStats.getPhysicalWrittenDataSize();
        userMemoryReservation = taskStats.getUserMemoryReservation();
        systemMemoryReservation = taskStats.getSystemMemoryReservation();
        revocableMemoryReservation = taskStats.getRevocableMemoryReservation();
        fullGcCount = taskStats.getFullGcCount();
        fullGcTime = taskStats.getFullGcTime();
        if (isSnapshotEnabled) {
            // Add snapshot result
            snapshotCaptureResult = finalTaskInfo.getTaskStatus().getSnapshotCaptureResult();
            snapshotRestoreResult = finalTaskInfo.getTaskStatus().getSnapshotRestoreResult();
        }
    } 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();
            runningPartitionedDrivers += pipelineStatus.getRunningPartitionedDrivers();
            physicalWrittenBytes += pipelineContext.getPhysicalWrittenDataSize();
        }
        physicalWrittenDataSize = succinctBytes(physicalWrittenBytes);
        userMemoryReservation = taskContext.getMemoryReservation();
        systemMemoryReservation = taskContext.getSystemMemoryReservation();
        revocableMemoryReservation = taskContext.getRevocableMemoryReservation();
        completedDriverGroups = taskContext.getCompletedDriverGroups();
        fullGcCount = taskContext.getFullGcCount();
        fullGcTime = taskContext.getFullGcTime();
        if (isSnapshotEnabled) {
            // Add snapshot result
            TaskSnapshotManager snapshotManager = taskHolder.taskExecution.getTaskContext().getSnapshotManager();
            snapshotCaptureResult = snapshotManager.getSnapshotCaptureResult();
            snapshotRestoreResult = Optional.ofNullable(snapshotManager.getSnapshotRestoreResult());
        }
    }
    return new TaskStatus(taskStateMachine.getTaskId(), confirmationInstanceId, versionNumber, state, location, nodeId, completedDriverGroups, failures, queuedPartitionedDrivers, runningPartitionedDrivers, isOutputBufferOverutilized(), physicalWrittenDataSize, userMemoryReservation, systemMemoryReservation, revocableMemoryReservation, fullGcCount, fullGcTime, snapshotCaptureResult, snapshotRestoreResult);
}
Also used : PipelineStatus(io.prestosql.operator.PipelineStatus) TaskContext(io.prestosql.operator.TaskContext) RestoreResult(io.prestosql.snapshot.RestoreResult) Duration(io.airlift.units.Duration) TaskStats(io.prestosql.operator.TaskStats) TaskSnapshotManager(io.prestosql.snapshot.TaskSnapshotManager) SnapshotInfo(io.prestosql.snapshot.SnapshotInfo) PipelineContext(io.prestosql.operator.PipelineContext) DataSize(io.airlift.units.DataSize) AtomicLong(java.util.concurrent.atomic.AtomicLong)

Aggregations

DataSize (io.airlift.units.DataSize)1 Duration (io.airlift.units.Duration)1 PipelineContext (io.prestosql.operator.PipelineContext)1 PipelineStatus (io.prestosql.operator.PipelineStatus)1 TaskContext (io.prestosql.operator.TaskContext)1 TaskStats (io.prestosql.operator.TaskStats)1 RestoreResult (io.prestosql.snapshot.RestoreResult)1 SnapshotInfo (io.prestosql.snapshot.SnapshotInfo)1 TaskSnapshotManager (io.prestosql.snapshot.TaskSnapshotManager)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1