use of io.trino.operator.PipelineStatus in project trino by trinodb.
the class SqlTask method createTaskStatus.
private TaskStatus createTaskStatus(TaskHolder taskHolder) {
// Obtain task status version before building actual TaskStatus object.
// This way any task updates won't be lost since all updates happen
// before version number is increased.
long versionNumber = taskStatusVersion.get();
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;
DataSize physicalWrittenDataSize = DataSize.ofBytes(0);
DataSize userMemoryReservation = DataSize.ofBytes(0);
DataSize revocableMemoryReservation = DataSize.ofBytes(0);
// 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);
long dynamicFiltersVersion = INITIAL_DYNAMIC_FILTERS_VERSION;
if (taskHolder.getFinalTaskInfo() != null) {
TaskInfo taskInfo = taskHolder.getFinalTaskInfo();
TaskStats taskStats = taskInfo.getStats();
queuedPartitionedDrivers = taskStats.getQueuedPartitionedDrivers();
queuedPartitionedSplitsWeight = taskStats.getQueuedPartitionedSplitsWeight();
runningPartitionedDrivers = taskStats.getRunningPartitionedDrivers();
runningPartitionedSplitsWeight = taskStats.getRunningPartitionedSplitsWeight();
physicalWrittenDataSize = taskStats.getPhysicalWrittenDataSize();
userMemoryReservation = taskStats.getUserMemoryReservation();
revocableMemoryReservation = taskStats.getRevocableMemoryReservation();
fullGcCount = taskStats.getFullGcCount();
fullGcTime = taskStats.getFullGcTime();
} 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();
}
physicalWrittenDataSize = succinctBytes(physicalWrittenBytes);
userMemoryReservation = taskContext.getMemoryReservation();
revocableMemoryReservation = taskContext.getRevocableMemoryReservation();
completedDriverGroups = taskContext.getCompletedDriverGroups();
fullGcCount = taskContext.getFullGcCount();
fullGcTime = taskContext.getFullGcTime();
dynamicFiltersVersion = taskContext.getDynamicFiltersVersion();
}
return new TaskStatus(taskStateMachine.getTaskId(), taskInstanceId, versionNumber, state, location, nodeId, completedDriverGroups, failures, queuedPartitionedDrivers, runningPartitionedDrivers, isOutputBufferOverutilized(), physicalWrittenDataSize, userMemoryReservation, revocableMemoryReservation, fullGcCount, fullGcTime, dynamicFiltersVersion, queuedPartitionedSplitsWeight, runningPartitionedSplitsWeight);
}
Aggregations