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);
}
Aggregations