YARN-4256. YARN fair scheduler vcores with decimal values. Contributed by Jun Gong

(cherry picked from commit 960201b79b)
This commit is contained in:
Zhihai Xu 2015-10-22 12:27:48 -07:00
parent 10398daadf
commit 9fe7ccc61c
3 changed files with 7 additions and 1 deletions

View File

@ -923,6 +923,8 @@ Release 2.8.0 - UNRELEASED
YARN-4270. Limit application resource reservation on nodes for non-node/rack YARN-4270. Limit application resource reservation on nodes for non-node/rack
specific requests (asuresh) specific requests (asuresh)
YARN-4256. YARN fair scheduler vcores with decimal values. (Jun Gong via zxu)
Release 2.7.2 - UNRELEASED Release 2.7.2 - UNRELEASED
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -283,7 +283,7 @@ public long getUpdateInterval() {
private static int findResource(String val, String units) private static int findResource(String val, String units)
throws AllocationConfigurationException { throws AllocationConfigurationException {
Pattern pattern = Pattern.compile("(\\d+)\\s*" + units); Pattern pattern = Pattern.compile("(\\d+)(\\.\\d*)?\\s*" + units);
Matcher matcher = pattern.matcher(val); Matcher matcher = pattern.matcher(val);
if (!matcher.find()) { if (!matcher.find()) {
throw new AllocationConfigurationException("Missing resource: " + units); throw new AllocationConfigurationException("Missing resource: " + units);

View File

@ -45,6 +45,10 @@ public void testParseResourceConfigValue() throws Exception {
parseResourceConfigValue("1024 Mb, 2 vCores")); parseResourceConfigValue("1024 Mb, 2 vCores"));
assertEquals(BuilderUtils.newResource(1024, 2), assertEquals(BuilderUtils.newResource(1024, 2),
parseResourceConfigValue(" 1024 mb, 2 vcores ")); parseResourceConfigValue(" 1024 mb, 2 vcores "));
assertEquals(BuilderUtils.newResource(1024, 2),
parseResourceConfigValue(" 1024.3 mb, 2.35 vcores "));
assertEquals(BuilderUtils.newResource(1024, 2),
parseResourceConfigValue(" 1024. mb, 2. vcores "));
} }
@Test(expected = AllocationConfigurationException.class) @Test(expected = AllocationConfigurationException.class)