Search in sources :

Example 1 with SqlTaskIoStats

use of com.facebook.presto.execution.SqlTaskIoStats in project presto by prestodb.

the class GcStatusMonitor method logTaskStats.

private static void logTaskStats(List<QueryId> queryIds, ListMultimap<QueryId, SqlTask> tasksByQueryId) {
    List<List<String>> rows = queryIds.stream().flatMap(queryId -> {
        List<SqlTask> sqlTasks = tasksByQueryId.get(queryId);
        Comparator<SqlTask> comparator = (first, second) -> {
            TaskStats aTaskStats = first.getTaskInfo().getStats();
            TaskStats bTaskStats = second.getTaskInfo().getStats();
            return Long.compare(aTaskStats.getUserMemoryReservationInBytes() + aTaskStats.getSystemMemoryReservationInBytes(), bTaskStats.getUserMemoryReservationInBytes() + bTaskStats.getSystemMemoryReservationInBytes());
        };
        return sqlTasks.stream().sorted(comparator.reversed()).map(task -> {
            TaskInfo taskInfo = task.getTaskInfo();
            SqlTaskIoStats taskIOStats = task.getIoStats();
            TaskStatus taskStatus = taskInfo.getTaskStatus();
            TaskStats taskStats = taskInfo.getStats();
            return ImmutableList.of(task.getQueryContext().getQueryId().toString(), task.getTaskId().toString(), taskStatus.getState().toString(), taskStats.getCreateTime().toString(), Long.toString(taskStats.getUserMemoryReservationInBytes()), Long.toString(taskStats.getSystemMemoryReservationInBytes()), Long.toString(taskIOStats.getInputDataSize().getTotalCount()), Long.toString(taskIOStats.getOutputDataSize().getTotalCount()), Long.toString(taskIOStats.getInputPositions().getTotalCount()), Long.toString(taskIOStats.getOutputPositions().getTotalCount()));
        });
    }).collect(toImmutableList());
    if (!rows.isEmpty()) {
        logInfoTable(ImmutableList.<List<String>>builder().add(ImmutableList.of("Query ID", "Task ID", "State", "Created Ts", "User Memory", "System Memory", "Input Bytes", "Output Bytes", "Input Row Count", "Output Row Count")).addAll(rows).build());
    }
}
Also used : TaskStats(com.facebook.presto.operator.TaskStats) NotificationListener(javax.management.NotificationListener) Logger(com.facebook.airlift.log.Logger) ListMultimap(com.google.common.collect.ListMultimap) TaskStatus(com.facebook.presto.execution.TaskStatus) Function(java.util.function.Function) Inject(javax.inject.Inject) PreDestroy(javax.annotation.PreDestroy) ImmutableListMultimap.toImmutableListMultimap(com.google.common.collect.ImmutableListMultimap.toImmutableListMultimap) SqlTaskManager(com.facebook.presto.execution.SqlTaskManager) ImmutableList(com.google.common.collect.ImmutableList) GarbageCollectorMXBean(java.lang.management.GarbageCollectorMXBean) Objects.requireNonNull(java.util.Objects.requireNonNull) SqlTask(com.facebook.presto.execution.SqlTask) GarbageCollectionNotificationInfo(com.facebook.airlift.stats.GarbageCollectionNotificationInfo) ManagementFactory(java.lang.management.ManagementFactory) SimpleEntry(java.util.AbstractMap.SimpleEntry) StringTableUtils.getTableStrings(com.facebook.presto.util.StringTableUtils.getTableStrings) SqlTaskIoStats(com.facebook.presto.execution.SqlTaskIoStats) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) CompositeData(javax.management.openmbean.CompositeData) ObjectName(javax.management.ObjectName) Notification(javax.management.Notification) List(java.util.List) JMException(javax.management.JMException) QueryId(com.facebook.presto.spi.QueryId) PostConstruct(javax.annotation.PostConstruct) Entry(java.util.Map.Entry) Comparator(java.util.Comparator) TaskInfo(com.facebook.presto.execution.TaskInfo) TaskInfo(com.facebook.presto.execution.TaskInfo) SqlTaskIoStats(com.facebook.presto.execution.SqlTaskIoStats) ImmutableList(com.google.common.collect.ImmutableList) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) List(java.util.List) TaskStats(com.facebook.presto.operator.TaskStats) TaskStatus(com.facebook.presto.execution.TaskStatus) Comparator(java.util.Comparator)

Aggregations

Logger (com.facebook.airlift.log.Logger)1 GarbageCollectionNotificationInfo (com.facebook.airlift.stats.GarbageCollectionNotificationInfo)1 SqlTask (com.facebook.presto.execution.SqlTask)1 SqlTaskIoStats (com.facebook.presto.execution.SqlTaskIoStats)1 SqlTaskManager (com.facebook.presto.execution.SqlTaskManager)1 TaskInfo (com.facebook.presto.execution.TaskInfo)1 TaskStatus (com.facebook.presto.execution.TaskStatus)1 TaskStats (com.facebook.presto.operator.TaskStats)1 QueryId (com.facebook.presto.spi.QueryId)1 StringTableUtils.getTableStrings (com.facebook.presto.util.StringTableUtils.getTableStrings)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)1 ImmutableListMultimap.toImmutableListMultimap (com.google.common.collect.ImmutableListMultimap.toImmutableListMultimap)1 ListMultimap (com.google.common.collect.ListMultimap)1 GarbageCollectorMXBean (java.lang.management.GarbageCollectorMXBean)1 ManagementFactory (java.lang.management.ManagementFactory)1 SimpleEntry (java.util.AbstractMap.SimpleEntry)1 Comparator (java.util.Comparator)1 List (java.util.List)1 Entry (java.util.Map.Entry)1