NodeManagerHardwareUtils { public static int getVCores(Configuration conf) { if (!isHardwareDetectionEnabled(conf)) { return getConfiguredVCores(conf); } ResourceCalculatorPlugin plugin = ResourceCalculatorPlugin.getResourceCalculatorPlugin(null, conf); if (plugin == null) { return getConfiguredVCores(conf); } return getVCoresInternal(plugin, 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 long getContainerMemoryMB(Configuration conf); static long getContainerMemoryMB(ResourceCalculatorPlugin plugin,
      Configuration conf); static Resource getNodeResources(Configuration configuration);  }
@Test public void testGetVCores() { ResourceCalculatorPlugin plugin = new TestResourceCalculatorPlugin(); YarnConfiguration conf = new YarnConfiguration(); conf.setFloat(YarnConfiguration.NM_PCORES_VCORES_MULTIPLIER, 1.25f); int ret = NodeManagerHardwareUtils.getVCores(plugin, conf); Assert.assertEquals(YarnConfiguration.DEFAULT_NM_VCORES, ret); conf.setBoolean(YarnConfiguration.NM_ENABLE_HARDWARE_CAPABILITY_DETECTION, true); ret = NodeManagerHardwareUtils.getVCores(plugin, conf); Assert.assertEquals(5, ret); conf.setBoolean(YarnConfiguration.NM_COUNT_LOGICAL_PROCESSORS_AS_CORES, true); ret = NodeManagerHardwareUtils.getVCores(plugin, conf); Assert.assertEquals(10, ret); conf.setInt(YarnConfiguration.NM_VCORES, 10); ret = NodeManagerHardwareUtils.getVCores(plugin, conf); Assert.assertEquals(10, ret); YarnConfiguration conf1 = new YarnConfiguration(); conf1.setBoolean(YarnConfiguration.NM_ENABLE_HARDWARE_CAPABILITY_DETECTION, false); conf.setInt(YarnConfiguration.NM_VCORES, 10); ret = NodeManagerHardwareUtils.getVCores(plugin, conf); Assert.assertEquals(10, ret); }