@Test public void testExplicitPropertyMappings() { Map<String, String> properties = new ImmutableMap.Builder<String, String>() .put("query.low-memory-killer.policy", "total-reservation-on-blocked-nodes") .put("query.low-memory-killer.delay", "20s") .put("query.max-memory", "2GB") .put("query.max-total-memory", "3GB") .build(); MemoryManagerConfig expected = new MemoryManagerConfig() .setLowMemoryKillerPolicy(TOTAL_RESERVATION_ON_BLOCKED_NODES) .setKillOnOutOfMemoryDelay(new Duration(20, SECONDS)) .setMaxQueryMemory(new DataSize(2, GIGABYTE)) .setMaxQueryTotalMemory(new DataSize(3, GIGABYTE)); assertFullMapping(properties, expected); } }
this.assignmentsRequestJsonCodec = requireNonNull(assignmentsRequestJsonCodec, "assignmentsRequestJsonCodec is null"); this.lowMemoryKiller = requireNonNull(lowMemoryKiller, "lowMemoryKiller is null"); this.maxQueryMemory = config.getMaxQueryMemory(); this.maxQueryTotalMemory = config.getMaxQueryTotalMemory(); this.coordinatorId = queryIdGenerator.getCoordinatorId(); this.enabled = serverConfig.isCoordinator(); this.killOnOutOfMemoryDelay = config.getKillOnOutOfMemoryDelay(); this.isLegacySystemPoolEnabled = nodeMemoryConfig.isLegacySystemPoolEnabled(); this.isWorkScheduledOnCoordinator = schedulerConfig.isIncludeCoordinator();
private void bindLowMemoryKiller(String name, Class<? extends LowMemoryKiller> clazz) { install(installModuleIf( MemoryManagerConfig.class, config -> name.equals(config.getLowMemoryKillerPolicy()), binder -> binder.bind(LowMemoryKiller.class).to(clazz).in(Scopes.SINGLETON))); }
@Test public void testExplicitPropertyMappings() { Map<String, String> properties = new ImmutableMap.Builder<String, String>() .put("query.low-memory-killer.enabled", "true") .put("query.low-memory-killer.delay", "20s") .put("query.max-memory", "2GB") .put("query.max-memory-per-node", "2GB") .build(); MemoryManagerConfig expected = new MemoryManagerConfig() .setKillOnOutOfMemory(true) .setKillOnOutOfMemoryDelay(new Duration(20, SECONDS)) .setMaxQueryMemory(new DataSize(2, GIGABYTE)) .setMaxQueryMemoryPerNode(new DataSize(2, GIGABYTE)); assertFullMapping(properties, expected); } }
@Test public void testTooManyGroupingElements() { Session session = testSessionBuilder(new SessionPropertyManager(new SystemSessionProperties( new QueryManagerConfig(), new TaskManagerConfig(), new MemoryManagerConfig(), new FeaturesConfig().setMaxGroupingSets(2048)))).build(); analyze(session, "SELECT a, b, c, d, e, f, g, h, i, j, k, SUM(l)" + "FROM (VALUES (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12))\n" + "t (a, b, c, d, e, f, g, h, i, j, k, l)\n" + "GROUP BY CUBE (a, b, c, d, e, f), CUBE (g, h, i, j, k)"); assertFails(session, TOO_MANY_GROUPING_SETS, "line 3:10: GROUP BY has 4096 grouping sets but can contain at most 2048", "SELECT a, b, c, d, e, f, g, h, i, j, k, l, SUM(m)" + "FROM (VALUES (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13))\n" + "t (a, b, c, d, e, f, g, h, i, j, k, l, m)\n" + "GROUP BY CUBE (a, b, c, d, e, f), CUBE (g, h, i, j, k, l)"); assertFails(session, TOO_MANY_GROUPING_SETS, format("line 3:10: GROUP BY has more than %s grouping sets but can contain at most 2048", Integer.MAX_VALUE), "SELECT a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, " + "q, r, s, t, u, v, x, w, y, z, aa, ab, ac, ad, ae, SUM(af)" + "FROM (VALUES (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, " + "17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32))\n" + "t (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, " + "q, r, s, t, u, v, x, w, y, z, aa, ab, ac, ad, ae, af)\n" + "GROUP BY CUBE (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, " + "q, r, s, t, u, v, x, w, y, z, aa, ab, ac, ad, ae)"); }
VARCHAR, DataSize.class, memoryManagerConfig.getMaxQueryMemory(), true, value -> DataSize.valueOf((String) value), VARCHAR, DataSize.class, memoryManagerConfig.getMaxQueryTotalMemory(), true, value -> DataSize.valueOf((String) value),
VARCHAR, DataSize.class, memoryManagerConfig.getMaxQueryMemory(), true, value -> DataSize.valueOf((String) value)),
@Inject public ClusterMemoryManager( @ForMemoryManager HttpClient httpClient, NodeManager nodeManager, LocationFactory locationFactory, MBeanExporter exporter, JsonCodec<MemoryInfo> memoryInfoCodec, JsonCodec<MemoryPoolAssignmentsRequest> assignmentsRequestJsonCodec, QueryIdGenerator queryIdGenerator, ServerConfig serverConfig, MemoryManagerConfig config) { requireNonNull(config, "config is null"); this.nodeManager = requireNonNull(nodeManager, "nodeManager is null"); this.locationFactory = requireNonNull(locationFactory, "locationFactory is null"); this.httpClient = requireNonNull(httpClient, "httpClient is null"); this.exporter = requireNonNull(exporter, "exporter is null"); this.memoryInfoCodec = requireNonNull(memoryInfoCodec, "memoryInfoCodec is null"); this.assignmentsRequestJsonCodec = requireNonNull(assignmentsRequestJsonCodec, "assignmentsRequestJsonCodec is null"); this.maxQueryMemory = config.getMaxQueryMemory(); this.coordinatorId = queryIdGenerator.getCoordinatorId(); this.enabled = serverConfig.isCoordinator(); this.killOnOutOfMemoryDelay = config.getKillOnOutOfMemoryDelay(); this.killOnOutOfMemory = config.isKillOnOutOfMemory(); }
@Inject public LocalMemoryManager(MemoryManagerConfig config, ReservedSystemMemoryConfig systemMemoryConfig) { requireNonNull(config, "config is null"); requireNonNull(systemMemoryConfig, "systemMemoryConfig is null"); long maxHeap = Runtime.getRuntime().maxMemory(); checkArgument(systemMemoryConfig.getReservedSystemMemory().toBytes() < maxHeap, "Reserved memory %s is greater than available heap %s", systemMemoryConfig.getReservedSystemMemory(), new DataSize(maxHeap, BYTE)); maxMemory = new DataSize(maxHeap - systemMemoryConfig.getReservedSystemMemory().toBytes(), BYTE); ImmutableMap.Builder<MemoryPoolId, MemoryPool> builder = ImmutableMap.builder(); checkArgument(config.getMaxQueryMemoryPerNode().toBytes() < maxMemory.toBytes(), format("%s set to %s, but only %s of useable heap available", QUERY_MAX_MEMORY_PER_NODE_CONFIG, config.getMaxQueryMemoryPerNode(), maxMemory)); builder.put(RESERVED_POOL, new MemoryPool(RESERVED_POOL, config.getMaxQueryMemoryPerNode())); DataSize generalPoolSize = new DataSize(Math.max(0, maxMemory.toBytes() - config.getMaxQueryMemoryPerNode().toBytes()), BYTE); builder.put(GENERAL_POOL, new MemoryPool(GENERAL_POOL, generalPoolSize)); builder.put(SYSTEM_POOL, new MemoryPool(SYSTEM_POOL, systemMemoryConfig.getReservedSystemMemory())); this.pools = builder.build(); }
@Test public void testDefaults() { assertRecordedDefaults(ConfigAssertions.recordDefaults(MemoryManagerConfig.class) .setKillOnOutOfMemory(false) .setKillOnOutOfMemoryDelay(new Duration(5, MINUTES)) .setMaxQueryMemory(new DataSize(20, GIGABYTE)) .setMaxQueryMemoryPerNode(new DataSize(1, GIGABYTE))); }
typeRegistry, blockEncodingManager, new SessionPropertyManager(new SystemSessionProperties(new QueryManagerConfig(), new TaskManagerConfig(), new MemoryManagerConfig(), featuresConfig)), new SchemaPropertyManager(), new TablePropertyManager(),
DataSize maxQueryMemoryPerNode = memoryManagerConfig.getMaxQueryMemoryPerNode();
@Test public void testDefaults() { assertRecordedDefaults(ConfigAssertions.recordDefaults(MemoryManagerConfig.class) .setLowMemoryKillerPolicy(NONE) .setKillOnOutOfMemoryDelay(new Duration(5, MINUTES)) .setMaxQueryMemory(new DataSize(20, GIGABYTE)) .setMaxQueryTotalMemory(new DataSize(40, GIGABYTE))); }
public TestSqlTaskManager() { localMemoryManager = new LocalMemoryManager(new MemoryManagerConfig(), new ReservedSystemMemoryConfig()); taskExecutor = new TaskExecutor(8, 16); taskExecutor.start(); }
public SqlTaskManager createSqlTaskManager(TaskManagerConfig config) { return new SqlTaskManager( createTestingPlanner(), new MockLocationFactory(), taskExecutor, new QueryMonitor(new ObjectMapperProvider().get(), new NullEventClient(), new NodeInfo("test"), new NodeVersion("testVersion")), new NodeInfo("test"), localMemoryManager, config, new MemoryManagerConfig()); }