NodeManagerHardwareUtils { public static int getContainerMemoryMB(Configuration conf) { return NodeManagerHardwareUtils.getContainerMemoryMB( ResourceCalculatorPlugin.getResourceCalculatorPlugin(null, conf), conf); }  static int getNodeCPUs(Configuration conf); static int getNodeCPUs(ResourceCalculatorPlugin plugin,
      Configuration conf); static float getContainersCPUs(Configuration conf); static float getContainersCPUs(ResourceCalculatorPlugin plugin,
      Configuration conf); static int getNodeCpuPercentage(Configuration conf); static int getVCores(Configuration conf); static int getVCores(ResourceCalculatorPlugin plugin,
      Configuration conf); static int getContainerMemoryMB(Configuration conf); static int getContainerMemoryMB(ResourceCalculatorPlugin plugin,
      Configuration conf);  }
@Test public void testGetContainerMemoryMB() throws Exception { ResourceCalculatorPlugin plugin = new TestResourceCalculatorPlugin(); long physicalMemMB = plugin.getPhysicalMemorySize() / (1024 * 1024); YarnConfiguration conf = new YarnConfiguration(); conf.setBoolean(YarnConfiguration.NM_ENABLE_HARDWARE_CAPABILITY_DETECTION, true); int mem = NodeManagerHardwareUtils.getContainerMemoryMB(null, conf); Assert.assertEquals(YarnConfiguration.DEFAULT_NM_PMEM_MB, mem); mem = NodeManagerHardwareUtils.getContainerMemoryMB(plugin, conf); int hadoopHeapSizeMB = (int) (Runtime.getRuntime().maxMemory() / (1024 * 1024)); int calculatedMemMB = (int) (0.8 * (physicalMemMB - (2 * hadoopHeapSizeMB))); Assert.assertEquals(calculatedMemMB, mem); conf.setInt(YarnConfiguration.NM_PMEM_MB, 1024); mem = NodeManagerHardwareUtils.getContainerMemoryMB(conf); Assert.assertEquals(1024, mem); conf = new YarnConfiguration(); conf.setBoolean(YarnConfiguration.NM_ENABLE_HARDWARE_CAPABILITY_DETECTION, false); mem = NodeManagerHardwareUtils.getContainerMemoryMB(conf); Assert.assertEquals(YarnConfiguration.DEFAULT_NM_PMEM_MB, mem); conf.setInt(YarnConfiguration.NM_PMEM_MB, 10 * 1024); mem = NodeManagerHardwareUtils.getContainerMemoryMB(conf); Assert.assertEquals(10 * 1024, mem); }