use of io.trino.TaskMemoryInfo in project trino by trinodb.
the class TotalReservationOnBlockedNodesLowMemoryKiller method chooseTasksToKill.
private Optional<KillTarget> chooseTasksToKill(List<MemoryInfo> nodes) {
ImmutableSet.Builder<TaskId> tasksToKillBuilder = ImmutableSet.builder();
for (MemoryInfo node : nodes) {
MemoryPoolInfo memoryPool = node.getPool();
if (memoryPool == null) {
continue;
}
if (memoryPool.getFreeBytes() + memoryPool.getReservedRevocableBytes() > 0) {
continue;
}
node.getTasksMemoryInfo().values().stream().max(comparing(TaskMemoryInfo::getMemoryReservation)).map(TaskMemoryInfo::getTaskId).ifPresent(tasksToKillBuilder::add);
}
Set<TaskId> tasksToKill = tasksToKillBuilder.build();
if (tasksToKill.isEmpty()) {
return Optional.empty();
}
return Optional.of(KillTarget.selectedTasks(tasksToKill));
}
use of io.trino.TaskMemoryInfo in project trino by trinodb.
the class LowMemoryKillerTestingUtils method tasksMemoryInfoForNode.
private static ListMultimap<QueryId, TaskMemoryInfo> tasksMemoryInfoForNode(String nodeIdentifier, Map<String, Map<String, Map<String, Long>>> tasks) {
ImmutableListMultimap.Builder<QueryId, TaskMemoryInfo> result = ImmutableListMultimap.builder();
for (Map.Entry<String, Map<String, Map<String, Long>>> queryNodesEntry : tasks.entrySet()) {
QueryId query = QueryId.valueOf(queryNodesEntry.getKey());
for (Map.Entry<String, Map<String, Long>> nodeTasksEntry : queryNodesEntry.getValue().entrySet()) {
if (!nodeIdentifier.equals(nodeTasksEntry.getKey())) {
continue;
}
for (Map.Entry<String, Long> taskReservationEntry : nodeTasksEntry.getValue().entrySet()) {
TaskId taskId = TaskId.valueOf(taskReservationEntry.getKey());
long taskReservation = taskReservationEntry.getValue();
result.put(query, new TaskMemoryInfo(taskId, taskReservation));
}
}
}
return result.build();
}
Aggregations