FairSchedulerConfiguration extends Configuration { public static ConfigurableResource parseResourceConfigValue(String value) throws AllocationConfigurationException { return parseResourceConfigValue(value, Long.MAX_VALUE); } FairSchedulerConfiguration();  FairSchedulerConfiguration(Configuration conf); Resource getMinimumAllocation(); Resource getMaximumAllocation(); Resource getIncrementAllocation(); float getReservationThresholdIncrementMultiple(); float getLocalityThresholdNode(); float getLocalityThresholdRack(); @Deprecated boolean isContinuousSchedulingEnabled(); @Deprecated int getContinuousSchedulingSleepMs(); @Deprecated long getLocalityDelayNodeMs(); @Deprecated long getLocalityDelayRackMs(); boolean getPreemptionEnabled(); boolean getAMPreemptionEnabled(String queueName); float getPreemptionUtilizationThreshold(); boolean getAssignMultiple(); boolean isMaxAssignDynamic(); int getMaxAssign(); boolean getSizeBasedWeight(); long getWaitTimeBeforeNextStarvationCheck(); int getWaitTimeBeforeKill(); boolean getUsePortForNodeName(); float getReservableNodes(); static ConfigurableResource parseResourceConfigValue(String value); static ConfigurableResource parseResourceConfigValue(String value,
      long missing); long getUpdateInterval(); static final Logger LOG; @Deprecated
  static final String RM_SCHEDULER_INCREMENT_ALLOCATION_MB; @Deprecated
  static final int DEFAULT_RM_SCHEDULER_INCREMENT_ALLOCATION_MB; @Deprecated
  static final String RM_SCHEDULER_INCREMENT_ALLOCATION_VCORES; @Deprecated
  static final int DEFAULT_RM_SCHEDULER_INCREMENT_ALLOCATION_VCORES; static final String RM_SCHEDULER_RESERVATION_THRESHOLD_INCREMENT_MULTIPLE; static final float DEFAULT_RM_SCHEDULER_RESERVATION_THRESHOLD_INCREMENT_MULTIPLE; static final String MIGRATION_MODE; static final String NO_TERMINAL_RULE_CHECK; static final String ALLOCATION_FILE; static final String ALLOW_UNDECLARED_POOLS; static final boolean DEFAULT_ALLOW_UNDECLARED_POOLS; static final String USER_AS_DEFAULT_QUEUE; static final boolean DEFAULT_USER_AS_DEFAULT_QUEUE; static final String LOCALITY_THRESHOLD_NODE; static final float DEFAULT_LOCALITY_THRESHOLD_NODE; static final String LOCALITY_THRESHOLD_RACK; static final float DEFAULT_LOCALITY_THRESHOLD_RACK; @Deprecated
  static final String CONTINUOUS_SCHEDULING_ENABLED; @Deprecated
  static final boolean DEFAULT_CONTINUOUS_SCHEDULING_ENABLED; @Deprecated
  static final String CONTINUOUS_SCHEDULING_SLEEP_MS; @Deprecated
  static final int DEFAULT_CONTINUOUS_SCHEDULING_SLEEP_MS; static final String PREEMPTION; static final boolean DEFAULT_PREEMPTION; static final String WAIT_TIME_BEFORE_KILL; static final int DEFAULT_WAIT_TIME_BEFORE_KILL; static final String WAIT_TIME_BEFORE_NEXT_STARVATION_CHECK_MS; static final long DEFAULT_WAIT_TIME_BEFORE_NEXT_STARVATION_CHECK_MS; static final String ASSIGN_MULTIPLE; static final boolean DEFAULT_ASSIGN_MULTIPLE; static final String SIZE_BASED_WEIGHT; static final boolean DEFAULT_SIZE_BASED_WEIGHT; static final String DYNAMIC_MAX_ASSIGN; static final String MAX_ASSIGN; static final int DEFAULT_MAX_ASSIGN; static final String UPDATE_INTERVAL_MS; static final int DEFAULT_UPDATE_INTERVAL_MS; static final String RESERVABLE_NODES; static final float RESERVABLE_NODES_DEFAULT; }
@Test public void testParseResourceConfigValue() throws Exception { Resource expected = BuilderUtils.newResource(5 * 1024, 2); Resource clusterResource = BuilderUtils.newResource(10 * 1024, 4); assertEquals(expected, parseResourceConfigValue("5120 mb 2 vcores").getResource()); assertEquals(expected, parseResourceConfigValue("2 vcores, 5120 mb").getResource()); assertEquals(expected, parseResourceConfigValue("5120 mb, 2 vcores").getResource()); assertEquals(expected, parseResourceConfigValue("2vcores,5120mb").getResource()); assertEquals(expected, parseResourceConfigValue("5120mb,2vcores").getResource()); assertEquals(expected, parseResourceConfigValue("5120mb mb, 2 vcores").getResource()); assertEquals(expected, parseResourceConfigValue("5120 Mb, 2 vCores").getResource()); assertEquals(expected, parseResourceConfigValue(" 5120 mb, 2 vcores ").getResource()); assertEquals(expected, parseResourceConfigValue(" 5120.3 mb, 2.35 vcores ").getResource()); assertEquals(expected, parseResourceConfigValue(" 5120. mb, 2. vcores ").getResource()); assertEquals(expected, parseResourceConfigValue("50% memory, 50% cpu"). getResource(clusterResource)); assertEquals(expected, parseResourceConfigValue("50% Memory, 50% CpU"). getResource(clusterResource)); assertEquals(BuilderUtils.newResource(5 * 1024, 4), parseResourceConfigValue("50% memory, 100% cpu"). getResource(clusterResource)); assertEquals(BuilderUtils.newResource(5 * 1024, 4), parseResourceConfigValue(" 100% cpu, 50% memory"). getResource(clusterResource)); assertEquals(BuilderUtils.newResource(5 * 1024, 0), parseResourceConfigValue("50% memory, 0% cpu"). getResource(clusterResource)); assertEquals(expected, parseResourceConfigValue("50 % memory, 50 % cpu"). getResource(clusterResource)); assertEquals(expected, parseResourceConfigValue("50%memory,50%cpu"). getResource(clusterResource)); assertEquals(expected, parseResourceConfigValue(" 50 % memory, 50 % cpu "). getResource(clusterResource)); assertEquals(expected, parseResourceConfigValue("50.% memory, 50.% cpu"). getResource(clusterResource)); assertEquals(BuilderUtils.newResource((int)(1024 * 10 * 0.109), 2), parseResourceConfigValue("10.9% memory, 50.6% cpu"). getResource(clusterResource)); assertEquals(expected, parseResourceConfigValue("50%").getResource(clusterResource)); Configuration conf = new Configuration(); conf.set(YarnConfiguration.RESOURCE_TYPES, "test1"); ResourceUtils.resetResourceTypes(conf); clusterResource = BuilderUtils.newResource(10 * 1024, 4); expected = BuilderUtils.newResource(5 * 1024, 2); expected.setResourceValue("test1", Long.MAX_VALUE); assertEquals(expected, parseResourceConfigValue("vcores=2, memory-mb=5120").getResource()); assertEquals(expected, parseResourceConfigValue("memory-mb=5120, vcores=2").getResource()); assertEquals(expected, parseResourceConfigValue("vcores=2,memory-mb=5120").getResource()); assertEquals(expected, parseResourceConfigValue(" vcores = 2 , " + "memory-mb = 5120 ").getResource()); expected.setResourceValue("test1", 0L); assertEquals(expected, parseResourceConfigValue("vcores=2, memory-mb=5120", 0L).getResource()); assertEquals(expected, parseResourceConfigValue("memory-mb=5120, vcores=2", 0L).getResource()); assertEquals(expected, parseResourceConfigValue("vcores=2,memory-mb=5120", 0L).getResource()); assertEquals(expected, parseResourceConfigValue(" vcores = 2 , memory-mb = 5120 ", 0L).getResource()); clusterResource.setResourceValue("test1", 8L); expected.setResourceValue("test1", 4L); assertEquals(expected, parseResourceConfigValue("50%").getResource(clusterResource)); assertEquals(expected, parseResourceConfigValue("vcores=2, memory-mb=5120, " + "test1=4").getResource()); assertEquals(expected, parseResourceConfigValue("test1=4, vcores=2, " + "memory-mb=5120").getResource()); assertEquals(expected, parseResourceConfigValue("memory-mb=5120, test1=4, " + "vcores=2").getResource()); assertEquals(expected, parseResourceConfigValue("vcores=2,memory-mb=5120," + "test1=4").getResource()); assertEquals(expected, parseResourceConfigValue(" vcores = 2 , memory-mb = 5120 , " + "test1 = 4 ").getResource()); expected = BuilderUtils.newResource(4 * 1024, 3); expected.setResourceValue("test1", 8L); assertEquals(expected, parseResourceConfigValue("vcores=75%, " + "memory-mb=40%").getResource(clusterResource)); assertEquals(expected, parseResourceConfigValue("memory-mb=40%, " + "vcores=75%").getResource(clusterResource)); assertEquals(expected, parseResourceConfigValue("vcores=75%," + "memory-mb=40%").getResource(clusterResource)); assertEquals(expected, parseResourceConfigValue(" vcores = 75 % , " + "memory-mb = 40 % ").getResource(clusterResource)); expected.setResourceValue("test1", 4L); assertEquals(expected, parseResourceConfigValue("vcores=75%, memory-mb=40%, " + "test1=50%").getResource(clusterResource)); assertEquals(expected, parseResourceConfigValue("test1=50%, vcores=75%, " + "memory-mb=40%").getResource(clusterResource)); assertEquals(expected, parseResourceConfigValue("memory-mb=40%, test1=50%, " + "vcores=75%").getResource(clusterResource)); assertEquals(expected, parseResourceConfigValue("vcores=75%,memory-mb=40%," + "test1=50%").getResource(clusterResource)); assertEquals(expected, parseResourceConfigValue(" vcores = 75 % , memory-mb = 40 % , " + "test1 = 50 % ").getResource(clusterResource)); }
@Test public void testNoUnits() throws Exception { String value = "1024"; expectUnparsableResource(value); parseResourceConfigValue(value); }
@Test public void testOnlyMemory() throws Exception { String value = "1024mb"; expectUnparsableResource(value); parseResourceConfigValue(value); }
@Test public void testOnlyCPU() throws Exception { String value = "1024vcores"; expectUnparsableResource(value); parseResourceConfigValue(value); }
@Test public void testGibberish() throws Exception { String value = "1o24vc0res"; expectUnparsableResource(value); parseResourceConfigValue(value); }
@Test public void testNoUnitsPercentage() throws Exception { expectMissingResource("cpu"); parseResourceConfigValue("95%, 50% memory"); }
@Test public void testInvalidNumPercentage() throws Exception { expectInvalidResourcePercentage("cpu"); parseResourceConfigValue("95A% cpu, 50% memory"); }
@Test public void testCpuPercentageMemoryAbsolute() throws Exception { expectMissingResource("memory"); parseResourceConfigValue("50% cpu, 1024 mb"); }
@Test public void testMemoryPercentageCpuAbsolute() throws Exception { expectMissingResource("cpu"); parseResourceConfigValue("50% memory, 2 vcores"); }
@Test public void testDuplicateVcoresDefinitionAbsolute() throws Exception { expectInvalidResource("vcores"); parseResourceConfigValue("1024 mb, 2 4 vcores"); }
@Test public void testDuplicateMemoryDefinitionAbsolute() throws Exception { expectInvalidResource("memory"); parseResourceConfigValue("2048 1024 mb, 2 vcores"); }
@Test public void testDuplicateVcoresDefinitionPercentage() throws Exception { expectInvalidResourcePercentage("cpu"); parseResourceConfigValue("50% memory, 50% 100%cpu"); }
@Test public void testDuplicateMemoryDefinitionPercentage() throws Exception { expectInvalidResourcePercentage("memory"); parseResourceConfigValue("50% 80% memory, 100%cpu"); }
@Test public void testParseNewStyleDuplicateMemoryDefinitionPercentage() throws Exception { expectInvalidResourcePercentageNewStyle("40% 80%"); parseResourceConfigValue("vcores = 75%, memory-mb = 40% 80%"); }
@Test public void testParseNewStyleDuplicateVcoresDefinitionPercentage() throws Exception { expectInvalidResourcePercentageNewStyle("75% 65%"); parseResourceConfigValue("vcores = 75% 65%, memory-mb = 40%"); }
@Test public void testMemoryPercentageNegativeValue() throws Exception { expectNegativePercentageOldStyle(); parseResourceConfigValue("-10% memory, 50% cpu"); }
@Test public void testCpuPercentageNegativeValue() throws Exception { expectNegativePercentageOldStyle(); parseResourceConfigValue("10% memory, -10% cpu"); }
@Test public void testMemoryAndCpuPercentageNegativeValue() throws Exception { expectNegativePercentageOldStyle(); parseResourceConfigValue("-20% memory, -10% cpu"); }
@Test public void testCpuPercentageMemoryAbsoluteCpuNegative() throws Exception { expectMissingResource("memory"); parseResourceConfigValue("-50% cpu, 1024 mb"); }
@Test public void testCpuPercentageMemoryAbsoluteMemoryNegative() throws Exception { expectMissingResource("memory"); parseResourceConfigValue("50% cpu, -1024 mb"); }
@Test public void testMemoryPercentageCpuAbsoluteCpuNegative() throws Exception { expectMissingResource("cpu"); parseResourceConfigValue("50% memory, -2 vcores"); }
@Test public void testMemoryPercentageCpuAbsoluteMemoryNegative() throws Exception { expectNegativePercentageOldStyle(); parseResourceConfigValue("-50% memory, 2 vcores"); }
@Test public void testAbsoluteVcoresNegative() throws Exception { expectNegativeValueOfResource("vcores"); parseResourceConfigValue("-2 vcores,5120 mb"); }
@Test public void testAbsoluteMemoryNegative() throws Exception { expectNegativeValueOfResource("memory"); parseResourceConfigValue("2 vcores,-5120 mb"); }
@Test public void testAbsoluteVcoresNegativeWithSpaces() throws Exception { expectNegativeValueOfResource("vcores"); parseResourceConfigValue("-2 vcores, 5120 mb"); }
@Test public void testAbsoluteMemoryNegativeWithSpaces() throws Exception { expectNegativeValueOfResource("memory"); parseResourceConfigValue("2 vcores, -5120 mb"); }
@Test public void testAbsoluteVcoresNegativeWithMoreSpaces() throws Exception { expectNegativeValueOfResource("vcores"); parseResourceConfigValue("5120mb mb, -2 vcores"); }
@Test public void testAbsoluteMemoryNegativeWithMoreSpaces() throws Exception { expectNegativeValueOfResource("memory"); parseResourceConfigValue("-5120mb mb, 2 vcores"); }
@Test public void testAbsoluteVcoresNegativeFractional() throws Exception { expectNegativeValueOfResource("vcores"); parseResourceConfigValue(" 5120.3 mb, -2.35 vcores "); }
@Test public void testAbsoluteMemoryNegativeFractional() throws Exception { expectNegativeValueOfResource("memory"); parseResourceConfigValue(" -5120.3 mb, 2.35 vcores "); }
@Test public void testOldStyleResourcesSeparatedBySpaces() throws Exception { parseResourceConfigValue("2 vcores, 5120 mb"); }
@Test public void testOldStyleResourcesSeparatedBySpacesInvalid() throws Exception { String value = "2 vcores 5120 mb 555 mb"; expectUnparsableResource(value); parseResourceConfigValue(value); }
@Test public void testOldStyleResourcesSeparatedBySpacesInvalidUppercaseUnits() throws Exception { String value = "2 vcores 5120 MB 555 GB"; expectUnparsableResource(value); parseResourceConfigValue(value); }
@Test public void testParseNewStyleResourceMemoryNegative() throws Exception { expectNegativeValueOfResource("memory"); parseResourceConfigValue("memory-mb=-5120,vcores=2"); }
@Test public void testParseNewStyleResourceVcoresNegative() throws Exception { expectNegativeValueOfResource("vcores"); parseResourceConfigValue("memory-mb=5120,vcores=-2"); }
@Test public void testParseNewStyleResourceMemoryNegativeWithSpaces() throws Exception { expectNegativeValueOfResource("memory"); parseResourceConfigValue("memory-mb=-5120, vcores=2"); }
@Test public void testParseNewStyleResourceVcoresNegativeWithSpaces() throws Exception { expectNegativeValueOfResource("vcores"); parseResourceConfigValue("memory-mb=5120, vcores=-2"); }
@Test public void testParseNewStyleResourceMemoryNegativeWithMoreSpaces() throws Exception { expectNegativeValueOfResource("memory"); parseResourceConfigValue(" vcores = 2 , memory-mb = -5120 "); }
@Test public void testParseNewStyleResourceVcoresNegativeWithMoreSpaces() throws Exception { expectNegativeValueOfResource("vcores"); parseResourceConfigValue(" vcores = -2 , memory-mb = 5120 "); }
@Test public void testParseNewStyleResourceWithCustomResourceMemoryNegative() throws Exception { expectNegativeValueOfResource("memory"); parseResourceConfigValue("vcores=2,memory-mb=-5120,test1=4"); }
@Test public void testParseNewStyleResourceWithCustomResourceVcoresNegative() throws Exception { expectNegativeValueOfResource("vcores"); parseResourceConfigValue("vcores=-2,memory-mb=-5120,test1=4"); }
@Test public void testParseNewStyleResourceWithCustomResourceNegative() throws Exception { expectNegativeValueOfResource("test1"); parseResourceConfigValue("vcores=2,memory-mb=5120,test1=-4"); }
@Test public void testParseNewStyleResourceWithCustomResourceNegativeWithSpaces() throws Exception { expectNegativeValueOfResource("test1"); parseResourceConfigValue(" vcores = 2 , memory-mb = 5120 , test1 = -4 "); }
@Test public void testParseNewStyleResourceWithPercentagesVcoresNegative() throws Exception { expectNegativePercentageNewStyle(); parseResourceConfigValue("vcores=-75%,memory-mb=40%"); }
@Test public void testParseNewStyleResourceWithPercentagesMemoryNegative() throws Exception { expectNegativePercentageNewStyle(); parseResourceConfigValue("vcores=75%,memory-mb=-40%"); }
@Test public void testParseNewStyleResourceWithPercentagesVcoresNegativeWithSpaces() throws Exception { expectNegativePercentageNewStyle(); parseResourceConfigValue("vcores=-75%, memory-mb=40%"); }
@Test public void testParseNewStyleResourceWithPercentagesMemoryNegativeWithSpaces() throws Exception { expectNegativePercentageNewStyle(); parseResourceConfigValue("vcores=75%, memory-mb=-40%"); }
@Test public void testParseNewStyleResourceWithPercentagesVcoresNegativeWithMoreSpaces() throws Exception { expectNegativePercentageNewStyle(); parseResourceConfigValue("vcores = -75%, memory-mb = 40%"); }
@Test public void testParseNewStyleResourceWithPercentagesMemoryNegativeWithMoreSpaces() throws Exception { expectNegativePercentageNewStyle(); parseResourceConfigValue("vcores = 75%, memory-mb = -40%"); }
@Test public void testParseNewStyleResourceWithPercentagesCustomResourceNegativeWithSpaces() throws Exception { expectNegativeValueOfResource("test1"); parseResourceConfigValue(" vcores = 2 , memory-mb = 5120 , test1 = -4 "); }