wangyang0918 commented on a change in pull request #10616: [FLINK-15288]
Starting jobmanager pod should respect containerized.heap-cutoff
URL: https://github.com/apache/flink/pull/10616#discussion_r361398836
##########
File path:
flink-runtime/src/test/java/org/apache/flink/runtime/clusterframework/BootstrapToolsTest.java
##########
@@ -423,4 +425,60 @@ public void testGetDynamicProperties() {
String dynamicProperties =
BootstrapTools.getDynamicProperties(baseConfig, targetConfig);
assertEquals("-Dkey.b=b2 -Dkey.c=c", dynamicProperties);
}
+
+ /**
+ * Remove 15% of the heap, at least 384MB.
+ *
+ */
+ @Test
+ public void testHeapCutoff() {
+ Configuration conf = new Configuration();
+
conf.setFloat(ResourceManagerOptions.CONTAINERIZED_HEAP_CUTOFF_RATIO, 0.15F);
+
conf.setInteger(ResourceManagerOptions.CONTAINERIZED_HEAP_CUTOFF_MIN, 384);
+
+ Assert.assertEquals(616, BootstrapTools.calculateHeapSize(1000,
conf));
+ Assert.assertEquals(8500,
BootstrapTools.calculateHeapSize(10000, conf));
+
+ // test different configuration
+ Assert.assertEquals(3400,
BootstrapTools.calculateHeapSize(4000, conf));
+
+
conf.setString(ResourceManagerOptions.CONTAINERIZED_HEAP_CUTOFF_MIN.key(),
"1000");
+
conf.setString(ResourceManagerOptions.CONTAINERIZED_HEAP_CUTOFF_RATIO.key(),
"0.1");
+ Assert.assertEquals(3000,
BootstrapTools.calculateHeapSize(4000, conf));
+
+
conf.setString(ResourceManagerOptions.CONTAINERIZED_HEAP_CUTOFF_RATIO.key(),
"0.5");
+ Assert.assertEquals(2000,
BootstrapTools.calculateHeapSize(4000, conf));
+
+
conf.setString(ResourceManagerOptions.CONTAINERIZED_HEAP_CUTOFF_RATIO.key(),
"1");
+ Assert.assertEquals(0, BootstrapTools.calculateHeapSize(4000,
conf));
+
+ // test also deprecated keys
+ conf = new Configuration();
+ conf.setDouble(ConfigConstants.YARN_HEAP_CUTOFF_RATIO, 0.15);
+ conf.setInteger(ConfigConstants.YARN_HEAP_CUTOFF_MIN, 384);
+
+ Assert.assertEquals(616, BootstrapTools.calculateHeapSize(1000,
conf));
+ Assert.assertEquals(8500,
BootstrapTools.calculateHeapSize(10000, conf));
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void illegalArgument() {
+ final Configuration conf = new Configuration();
+
conf.setString(ResourceManagerOptions.CONTAINERIZED_HEAP_CUTOFF_RATIO.key(),
"1.1");
+ Assert.assertEquals(0, BootstrapTools.calculateHeapSize(4000,
conf));
Review comment:
I will fix it.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services