use of io.trino.spi.memory.MemoryPoolInfo in project trino by trinodb.
the class LowMemoryKillerTestingUtils method toNodeMemoryInfoList.
static List<MemoryInfo> toNodeMemoryInfoList(long memoryPoolMaxBytes, Map<String, Map<String, Long>> queries, Map<String, Map<String, Map<String, Long>>> tasks) {
Map<InternalNode, NodeReservation> nodeReservations = new HashMap<>();
for (Map.Entry<String, Map<String, Long>> entry : queries.entrySet()) {
QueryId queryId = new QueryId(entry.getKey());
Map<String, Long> reservationByNode = entry.getValue();
for (Map.Entry<String, Long> nodeEntry : reservationByNode.entrySet()) {
InternalNode node = new InternalNode(nodeEntry.getKey(), URI.create("http://localhost"), new NodeVersion("version"), false);
long bytes = nodeEntry.getValue();
if (bytes == 0) {
continue;
}
nodeReservations.computeIfAbsent(node, ignored -> new NodeReservation()).add(queryId, bytes);
}
}
ImmutableList.Builder<MemoryInfo> result = ImmutableList.builder();
for (Map.Entry<InternalNode, NodeReservation> entry : nodeReservations.entrySet()) {
NodeReservation nodeReservation = entry.getValue();
MemoryPoolInfo memoryPoolInfo = new MemoryPoolInfo(memoryPoolMaxBytes, nodeReservation.getTotalReservedBytes(), 0, nodeReservation.getReservationByQuery(), ImmutableMap.of(), ImmutableMap.of());
result.add(new MemoryInfo(7, memoryPoolInfo, tasksMemoryInfoForNode(entry.getKey().getNodeIdentifier(), tasks)));
}
return result.build();
}
use of io.trino.spi.memory.MemoryPoolInfo in project trino by trinodb.
the class ClusterMemoryManager method formatKillScenario.
private String formatKillScenario(List<MemoryInfo> nodes) {
StringBuilder stringBuilder = new StringBuilder();
for (MemoryInfo nodeMemoryInfo : nodes) {
MemoryPoolInfo memoryPoolInfo = nodeMemoryInfo.getPool();
stringBuilder.append("Query Kill Scenario: ");
stringBuilder.append("MaxBytes ").append(memoryPoolInfo.getMaxBytes()).append(' ');
stringBuilder.append("FreeBytes ").append(memoryPoolInfo.getFreeBytes() + memoryPoolInfo.getReservedRevocableBytes()).append(' ');
stringBuilder.append("Queries ");
Joiner.on(",").withKeyValueSeparator("=").appendTo(stringBuilder, memoryPoolInfo.getQueryMemoryReservations());
stringBuilder.append("Tasks ");
Joiner.on(",").withKeyValueSeparator("=").appendTo(stringBuilder, nodeMemoryInfo.getTasksMemoryInfo().asMap());
stringBuilder.append('\n');
}
return stringBuilder.toString();
}
use of io.trino.spi.memory.MemoryPoolInfo in project trino by trinodb.
the class TestFileResourceGroupConfigurationManager method testDocsExample.
@Test
public void testDocsExample() {
// arbitrary uneven value for testing
long memoryPoolSize = 31415926535900L;
FileResourceGroupConfigurationManager manager = new FileResourceGroupConfigurationManager((listener) -> listener.accept(new MemoryPoolInfo(memoryPoolSize, 0, 0, ImmutableMap.of(), ImmutableMap.of(), ImmutableMap.of())), new FileResourceGroupConfig().setConfigFile("../../docs/src/main/sphinx/admin/resource-groups-example.json"));
SelectionContext<ResourceGroupIdTemplate> selectionContext = match(manager, new SelectionCriteria(true, "Alice", ImmutableSet.of(), Optional.of("jdbc#powerfulbi"), ImmutableSet.of("hipri"), EMPTY_RESOURCE_ESTIMATES, Optional.of("select")));
assertEquals(selectionContext.getResourceGroupId().toString(), "global.adhoc.bi-powerfulbi.Alice");
TestingResourceGroup resourceGroup = new TestingResourceGroup(selectionContext.getResourceGroupId());
manager.configure(resourceGroup, selectionContext);
assertEquals(resourceGroup.getHardConcurrencyLimit(), 3);
assertEquals(resourceGroup.getMaxQueuedQueries(), 10);
assertEquals(resourceGroup.getSoftMemoryLimitBytes(), memoryPoolSize / 10);
}
Aggregations