YARN-9010. Fix the incorrect trailing slash deletion in constructor method of CGroupsHandlerImpl. (Zhankun Tang via wangda)
Change-Id: Iaecc66d57781cc10f19ead4647e47fc9556676da
This commit is contained in:
parent
0081b02e35
commit
bad12031f6
|
@ -87,9 +87,10 @@ class CGroupsHandlerImpl implements CGroupsHandler {
|
|||
CGroupsHandlerImpl(Configuration conf, PrivilegedOperationExecutor
|
||||
privilegedOperationExecutor, String mtab)
|
||||
throws ResourceHandlerException {
|
||||
// Remove leading and trialing slash(es)
|
||||
this.cGroupPrefix = conf.get(YarnConfiguration.
|
||||
NM_LINUX_CONTAINER_CGROUPS_HIERARCHY, "/hadoop-yarn")
|
||||
.replaceAll("^/", "").replaceAll("$/", "");
|
||||
.replaceAll("^/+", "").replaceAll("/+$", "");
|
||||
this.enableCGroupMount = conf.getBoolean(YarnConfiguration.
|
||||
NM_LINUX_CONTAINER_CGROUPS_MOUNT, false);
|
||||
this.cGroupMountPath = conf.get(YarnConfiguration.
|
||||
|
|
|
@ -598,4 +598,42 @@ public class TestCGroupsHandlerImpl {
|
|||
FileUtils.deleteQuietly(cpu);
|
||||
}
|
||||
}
|
||||
|
||||
// Remove leading and trailing slashes
|
||||
@Test
|
||||
public void testCgroupsHierarchySetting() throws ResourceHandlerException {
|
||||
YarnConfiguration conf = new YarnConfiguration();
|
||||
conf.set(YarnConfiguration.NM_LINUX_CONTAINER_CGROUPS_MOUNT_PATH, tmpPath);
|
||||
conf.set(YarnConfiguration.NM_LINUX_CONTAINER_CGROUPS_HIERARCHY,
|
||||
"/hadoop-yarn");
|
||||
CGroupsHandlerImpl cGroupsHandler = new CGroupsHandlerImpl(conf, null);
|
||||
String expectedRelativePath = "hadoop-yarn/c1";
|
||||
Assert.assertEquals(expectedRelativePath,
|
||||
cGroupsHandler.getRelativePathForCGroup("c1"));
|
||||
|
||||
conf.set(YarnConfiguration.NM_LINUX_CONTAINER_CGROUPS_HIERARCHY,
|
||||
"hadoop-yarn");
|
||||
cGroupsHandler = new CGroupsHandlerImpl(conf, null);
|
||||
Assert.assertEquals(expectedRelativePath,
|
||||
cGroupsHandler.getRelativePathForCGroup("c1"));
|
||||
|
||||
conf.set(YarnConfiguration.NM_LINUX_CONTAINER_CGROUPS_HIERARCHY,
|
||||
"hadoop-yarn/");
|
||||
cGroupsHandler = new CGroupsHandlerImpl(conf, null);
|
||||
Assert.assertEquals(expectedRelativePath,
|
||||
cGroupsHandler.getRelativePathForCGroup("c1"));
|
||||
|
||||
conf.set(YarnConfiguration.NM_LINUX_CONTAINER_CGROUPS_HIERARCHY,
|
||||
"//hadoop-yarn//");
|
||||
cGroupsHandler = new CGroupsHandlerImpl(conf, null);
|
||||
Assert.assertEquals(expectedRelativePath,
|
||||
cGroupsHandler.getRelativePathForCGroup("c1"));
|
||||
|
||||
expectedRelativePath = "hadoop-yarn/root/c1";
|
||||
conf.set(YarnConfiguration.NM_LINUX_CONTAINER_CGROUPS_HIERARCHY,
|
||||
"//hadoop-yarn/root//");
|
||||
cGroupsHandler = new CGroupsHandlerImpl(conf, null);
|
||||
Assert.assertEquals(expectedRelativePath,
|
||||
cGroupsHandler.getRelativePathForCGroup("c1"));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue