YARN-2742. FairSchedulerConfiguration should allow extra spaces between value and unit. (Wei Yan via kasha)
(cherry picked from commit 782971ae7a
)
This commit is contained in:
parent
063bb0508b
commit
e88832dfb3
|
@ -26,6 +26,9 @@ Release 2.7.0 - UNRELEASED
|
||||||
YARN-2641. Decommission nodes on -refreshNodes instead of next
|
YARN-2641. Decommission nodes on -refreshNodes instead of next
|
||||||
NM-RM heartbeat. (Zhihai Xu via kasha)
|
NM-RM heartbeat. (Zhihai Xu via kasha)
|
||||||
|
|
||||||
|
YARN-2742. FairSchedulerConfiguration should allow extra spaces
|
||||||
|
between value and unit. (Wei Yan via kasha)
|
||||||
|
|
||||||
OPTIMIZATIONS
|
OPTIMIZATIONS
|
||||||
|
|
||||||
BUG FIXES
|
BUG FIXES
|
||||||
|
|
|
@ -241,6 +241,7 @@ public class FairSchedulerConfiguration extends Configuration {
|
||||||
public static Resource parseResourceConfigValue(String val)
|
public static Resource parseResourceConfigValue(String val)
|
||||||
throws AllocationConfigurationException {
|
throws AllocationConfigurationException {
|
||||||
try {
|
try {
|
||||||
|
val = val.toLowerCase();
|
||||||
int memory = findResource(val, "mb");
|
int memory = findResource(val, "mb");
|
||||||
int vcores = findResource(val, "vcores");
|
int vcores = findResource(val, "vcores");
|
||||||
return BuilderUtils.newResource(memory, vcores);
|
return BuilderUtils.newResource(memory, vcores);
|
||||||
|
@ -258,7 +259,7 @@ public class FairSchedulerConfiguration extends Configuration {
|
||||||
|
|
||||||
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+) ?" + units);
|
Pattern pattern = Pattern.compile("(\\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);
|
||||||
|
|
|
@ -39,6 +39,12 @@ public class TestFairSchedulerConfiguration {
|
||||||
parseResourceConfigValue("2vcores,1024mb"));
|
parseResourceConfigValue("2vcores,1024mb"));
|
||||||
assertEquals(BuilderUtils.newResource(1024, 2),
|
assertEquals(BuilderUtils.newResource(1024, 2),
|
||||||
parseResourceConfigValue("1024mb,2vcores"));
|
parseResourceConfigValue("1024mb,2vcores"));
|
||||||
|
assertEquals(BuilderUtils.newResource(1024, 2),
|
||||||
|
parseResourceConfigValue("1024 mb, 2 vcores"));
|
||||||
|
assertEquals(BuilderUtils.newResource(1024, 2),
|
||||||
|
parseResourceConfigValue("1024 Mb, 2 vCores"));
|
||||||
|
assertEquals(BuilderUtils.newResource(1024, 2),
|
||||||
|
parseResourceConfigValue(" 1024 mb, 2 vcores "));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = AllocationConfigurationException.class)
|
@Test(expected = AllocationConfigurationException.class)
|
||||||
|
|
Loading…
Reference in New Issue