use of io.trino.server.BasicQueryStats in project trino by trinodb.
the class QueryStateMachine method getBasicQueryInfo.
public BasicQueryInfo getBasicQueryInfo(Optional<BasicStageStats> rootStage) {
// Query state must be captured first in order to provide a
// correct view of the query. For example, building this
// information, the query could finish, and the task states would
// never be visible.
QueryState state = queryState.get();
ErrorCode errorCode = null;
if (state == FAILED) {
ExecutionFailureInfo failureCause = this.failureCause.get();
if (failureCause != null) {
errorCode = failureCause.getErrorCode();
}
}
BasicStageStats stageStats = rootStage.orElse(EMPTY_STAGE_STATS);
BasicQueryStats queryStats = new BasicQueryStats(queryStateTimer.getCreateTime(), getEndTime().orElse(null), queryStateTimer.getQueuedTime(), queryStateTimer.getElapsedTime(), queryStateTimer.getExecutionTime(), stageStats.getTotalDrivers(), stageStats.getQueuedDrivers(), stageStats.getRunningDrivers(), stageStats.getCompletedDrivers(), stageStats.getRawInputDataSize(), stageStats.getRawInputPositions(), stageStats.getPhysicalInputDataSize(), stageStats.getCumulativeUserMemory(), stageStats.getFailedCumulativeUserMemory(), stageStats.getUserMemoryReservation(), stageStats.getTotalMemoryReservation(), succinctBytes(getPeakUserMemoryInBytes()), succinctBytes(getPeakTotalMemoryInBytes()), stageStats.getTotalCpuTime(), stageStats.getFailedCpuTime(), stageStats.getTotalScheduledTime(), stageStats.getFailedScheduledTime(), stageStats.isFullyBlocked(), stageStats.getBlockedReasons(), stageStats.getProgressPercentage());
return new BasicQueryInfo(queryId, session.toSessionRepresentation(), Optional.of(resourceGroup), state, stageStats.isScheduled(), self, query, Optional.ofNullable(updateType.get()), preparedQuery, queryStats, errorCode == null ? null : errorCode.getType(), errorCode, queryType);
}
use of io.trino.server.BasicQueryStats in project trino by trinodb.
the class TestMemoryManager method isBlockedWaitingForMemory.
private static boolean isBlockedWaitingForMemory(BasicQueryInfo info) {
BasicQueryStats stats = info.getQueryStats();
boolean isWaitingForMemory = stats.getBlockedReasons().contains(WAITING_FOR_MEMORY);
if (!isWaitingForMemory) {
return false;
}
// queries are not marked as fully blocked if there are no running drivers
return stats.isFullyBlocked() || stats.getRunningDrivers() == 0;
}
Aggregations