@Test public void testExplicitPropertyMappings() { Map<String, String> properties = new ImmutableMap.Builder<String, String>() .put("query.max-memory-per-node", "1GB") .put("query.max-total-memory-per-node", "3GB") .put("memory.heap-headroom-per-node", "1GB") .put("deprecated.legacy-system-pool-enabled", "true") .put("experimental.reserved-pool-enabled", "false") .build(); NodeMemoryConfig expected = new NodeMemoryConfig() .setLegacySystemPoolEnabled(true) .setMaxQueryMemoryPerNode(new DataSize(1, GIGABYTE)) .setMaxQueryTotalMemoryPerNode(new DataSize(3, GIGABYTE)) .setHeapHeadroom(new DataSize(1, GIGABYTE)) .setReservedPoolEnabled(false); assertFullMapping(properties, expected); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testInvalidValues() { NodeMemoryConfig config = new NodeMemoryConfig(); config.setMaxQueryTotalMemoryPerNode(new DataSize(1, GIGABYTE)); config.setHeapHeadroom(new DataSize(3.1, GIGABYTE)); // In this case we have 4GB - 1GB = 3GB available memory for the general pool // and the heap headroom and the config is more than that. validateHeapHeadroom(config, new DataSize(4, GIGABYTE).toBytes()); } }
@Test public void testDefaults() { ConfigAssertions.assertRecordedDefaults(ConfigAssertions.recordDefaults(NodeMemoryConfig.class) .setLegacySystemPoolEnabled(false) .setMaxQueryMemoryPerNode(new DataSize(AVAILABLE_HEAP_MEMORY * 0.1, BYTE)) .setMaxQueryTotalMemoryPerNode(new DataSize(AVAILABLE_HEAP_MEMORY * 0.3, BYTE)) .setHeapHeadroom(new DataSize(AVAILABLE_HEAP_MEMORY * 0.3, BYTE)) .setReservedPoolEnabled(true)); }