diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index 79df1ce3e62..024255cd90a 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -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 diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FairSchedulerConfiguration.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FairSchedulerConfiguration.java index 74af70fb9e2..5dfee954449 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FairSchedulerConfiguration.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FairSchedulerConfiguration.java @@ -283,7 +283,7 @@ public class FairSchedulerConfiguration extends Configuration { 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); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestFairSchedulerConfiguration.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestFairSchedulerConfiguration.java index 82b50a6c74d..8e7b6665563 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestFairSchedulerConfiguration.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestFairSchedulerConfiguration.java @@ -45,6 +45,10 @@ public class TestFairSchedulerConfiguration { 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)