|
@@ -66,8 +66,7 @@ class CGroupsHandlerImpl implements CGroupsHandler {
|
|
|
|
|
|
private final String mtabFile;
|
|
|
private final String cGroupPrefix;
|
|
|
- private final boolean enableCGroupMount;
|
|
|
- private final String cGroupMountPath;
|
|
|
+ private final CGroupsMountConfig cGroupsMountConfig;
|
|
|
private final long deleteCGroupTimeout;
|
|
|
private final long deleteCGroupDelay;
|
|
|
private Map<CGroupController, String> controllerPaths;
|
|
@@ -91,10 +90,7 @@ class CGroupsHandlerImpl implements CGroupsHandler {
|
|
|
this.cGroupPrefix = conf.get(YarnConfiguration.
|
|
|
NM_LINUX_CONTAINER_CGROUPS_HIERARCHY, "/hadoop-yarn")
|
|
|
.replaceAll("^/+", "").replaceAll("/+$", "");
|
|
|
- this.enableCGroupMount = conf.getBoolean(YarnConfiguration.
|
|
|
- NM_LINUX_CONTAINER_CGROUPS_MOUNT, false);
|
|
|
- this.cGroupMountPath = conf.get(YarnConfiguration.
|
|
|
- NM_LINUX_CONTAINER_CGROUPS_MOUNT_PATH, null);
|
|
|
+ this.cGroupsMountConfig = new CGroupsMountConfig(conf);
|
|
|
this.deleteCGroupTimeout = conf.getLong(
|
|
|
YarnConfiguration.NM_LINUX_CONTAINER_CGROUPS_DELETE_TIMEOUT,
|
|
|
YarnConfiguration.DEFAULT_NM_LINUX_CONTAINER_CGROUPS_DELETE_TIMEOUT) +
|
|
@@ -150,9 +146,9 @@ class CGroupsHandlerImpl implements CGroupsHandler {
|
|
|
Map<String, Set<String>> newMtab = null;
|
|
|
Map<CGroupController, String> cPaths;
|
|
|
try {
|
|
|
- if (this.cGroupMountPath != null && !this.enableCGroupMount) {
|
|
|
+ if (this.cGroupsMountConfig.mountDisabledButMountPathDefined()) {
|
|
|
newMtab = ResourceHandlerModule.
|
|
|
- parseConfiguredCGroupPath(this.cGroupMountPath);
|
|
|
+ parseConfiguredCGroupPath(this.cGroupsMountConfig.getMountPath());
|
|
|
}
|
|
|
|
|
|
if (newMtab == null) {
|
|
@@ -282,14 +278,10 @@ class CGroupsHandlerImpl implements CGroupsHandler {
|
|
|
|
|
|
private void mountCGroupController(CGroupController controller)
|
|
|
throws ResourceHandlerException {
|
|
|
- if (cGroupMountPath == null) {
|
|
|
- throw new ResourceHandlerException(
|
|
|
- String.format("Cgroups mount path not specified in %s.",
|
|
|
- YarnConfiguration.NM_LINUX_CONTAINER_CGROUPS_MOUNT_PATH));
|
|
|
- }
|
|
|
String existingMountPath = getControllerPath(controller);
|
|
|
String requestedMountPath =
|
|
|
- new File(cGroupMountPath, controller.getName()).getAbsolutePath();
|
|
|
+ new File(cGroupsMountConfig.getMountPath(),
|
|
|
+ controller.getName()).getAbsolutePath();
|
|
|
|
|
|
if (existingMountPath == null ||
|
|
|
!requestedMountPath.equals(existingMountPath)) {
|
|
@@ -367,7 +359,8 @@ class CGroupsHandlerImpl implements CGroupsHandler {
|
|
|
@Override
|
|
|
public void initializeCGroupController(CGroupController controller) throws
|
|
|
ResourceHandlerException {
|
|
|
- if (enableCGroupMount) {
|
|
|
+ if (this.cGroupsMountConfig.isMountEnabled() &&
|
|
|
+ cGroupsMountConfig.ensureMountPathIsDefined()) {
|
|
|
// We have a controller that needs to be mounted
|
|
|
mountCGroupController(controller);
|
|
|
}
|
|
@@ -611,7 +604,7 @@ class CGroupsHandlerImpl implements CGroupsHandler {
|
|
|
|
|
|
@Override
|
|
|
public String getCGroupMountPath() {
|
|
|
- return cGroupMountPath;
|
|
|
+ return this.cGroupsMountConfig.getMountPath();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -619,8 +612,7 @@ class CGroupsHandlerImpl implements CGroupsHandler {
|
|
|
return CGroupsHandlerImpl.class.getName() + "{" +
|
|
|
"mtabFile='" + mtabFile + '\'' +
|
|
|
", cGroupPrefix='" + cGroupPrefix + '\'' +
|
|
|
- ", enableCGroupMount=" + enableCGroupMount +
|
|
|
- ", cGroupMountPath='" + cGroupMountPath + '\'' +
|
|
|
+ ", cGroupsMountConfig=" + cGroupsMountConfig +
|
|
|
", deleteCGroupTimeout=" + deleteCGroupTimeout +
|
|
|
", deleteCGroupDelay=" + deleteCGroupDelay +
|
|
|
'}';
|