CapacitySchedulerConfigValidator { public static void validateVCores(Configuration conf) { int minVcores = conf.getInt( YarnConfiguration.RM_SCHEDULER_MINIMUM_ALLOCATION_VCORES, YarnConfiguration.DEFAULT_RM_SCHEDULER_MINIMUM_ALLOCATION_VCORES); int maxVcores = conf.getInt( YarnConfiguration.RM_SCHEDULER_MAXIMUM_ALLOCATION_VCORES, YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_VCORES); if (minVcores <= 0 || minVcores > maxVcores) { throw new YarnRuntimeException("Invalid resource scheduler vcores" + " allocation configuration" + ", " + YarnConfiguration.RM_SCHEDULER_MINIMUM_ALLOCATION_VCORES + "=" + minVcores + ", " + YarnConfiguration.RM_SCHEDULER_MAXIMUM_ALLOCATION_VCORES + "=" + maxVcores + ", min and max should be greater than 0" + ", max should be no smaller than min."); } } private  CapacitySchedulerConfigValidator(); static boolean validateCSConfiguration(
          final Configuration oldConf, final Configuration newConf,
          final RMContext rmContext); static Set<String> validatePlacementRules(
          Collection<String> placementRuleStrs); static void validateMemoryAllocation(Configuration conf); static void validateVCores(Configuration conf); static void validateQueueHierarchy(
      CSQueueStore queues,
      CSQueueStore newQueues,
      CapacitySchedulerConfiguration newConf);  }
@Test (expected = YarnRuntimeException.class) public void testValidateVCoresInvalidMinVCore() { Map<String, String> configs = new HashMap(); configs.put(YarnConfiguration.RM_SCHEDULER_MINIMUM_ALLOCATION_VCORES, "0"); Configuration config = CapacitySchedulerConfigGeneratorForTest .createConfiguration(configs); CapacitySchedulerConfigValidator.validateVCores(config); fail(YarnConfiguration.RM_SCHEDULER_MINIMUM_ALLOCATION_VCORES + " should be > 0"); }
@Test (expected = YarnRuntimeException.class) public void testValidateVCoresHigherMinThanMaxVCore() { Map<String, String> configs = new HashMap(); configs.put(YarnConfiguration.RM_SCHEDULER_MINIMUM_ALLOCATION_VCORES, "4"); configs.put(YarnConfiguration.RM_SCHEDULER_MAXIMUM_ALLOCATION_VCORES, "1"); Configuration config = CapacitySchedulerConfigGeneratorForTest .createConfiguration(configs); CapacitySchedulerConfigValidator.validateVCores(config); fail(YarnConfiguration.RM_SCHEDULER_MINIMUM_ALLOCATION_VCORES + " should be > " + YarnConfiguration.RM_SCHEDULER_MAXIMUM_ALLOCATION_MB); }
@Test public void testValidateVCores() { Map<String, String> configs = new HashMap(); configs.put(YarnConfiguration.RM_SCHEDULER_MINIMUM_ALLOCATION_VCORES, "1"); configs.put(YarnConfiguration.RM_SCHEDULER_MAXIMUM_ALLOCATION_VCORES, "4"); Configuration config = CapacitySchedulerConfigGeneratorForTest .createConfiguration(configs); CapacitySchedulerConfigValidator.validateVCores(config); }