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

This commit is contained in:
Zhihai Xu 2015-10-22 12:27:48 -07:00
parent 47641fcbc9
commit 960201b79b
3 changed files with 7 additions and 1 deletions

View File

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

View File

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

View File

@ -45,6 +45,10 @@ public void testParseResourceConfigValue() throws Exception {
parseResourceConfigValue("1024 Mb, 2 vCores"));
assertEquals(BuilderUtils.newResource(1024, 2),
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)