merge YARN-391 from trunk. Formatting fixes for LCEResourceHandler classes. Contributed by Steve Loughran.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1445883 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d53d4cbca3
commit
19e5586651
|
@ -21,6 +21,9 @@ Release 2.0.4-beta - UNRELEASED
|
||||||
YARN-377. Use the new StringUtils methods added by HADOOP-9252 and fix
|
YARN-377. Use the new StringUtils methods added by HADOOP-9252 and fix
|
||||||
TestContainersMonitor. (Chris Nauroth via szetszwo)
|
TestContainersMonitor. (Chris Nauroth via szetszwo)
|
||||||
|
|
||||||
|
YARN-391. Formatting fixes for LCEResourceHandler classes.
|
||||||
|
(Steve Loughran via sseth)
|
||||||
|
|
||||||
Release 2.0.3-alpha - 2013-02-06
|
Release 2.0.3-alpha - 2013-02-06
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
|
|
@ -80,17 +80,17 @@ public class CgroupsLCEResourcesHandler implements LCEResourcesHandler {
|
||||||
NM_LINUX_CONTAINER_CGROUPS_MOUNT, false);
|
NM_LINUX_CONTAINER_CGROUPS_MOUNT, false);
|
||||||
this.cgroupMountPath = conf.get(YarnConfiguration.
|
this.cgroupMountPath = conf.get(YarnConfiguration.
|
||||||
NM_LINUX_CONTAINER_CGROUPS_MOUNT_PATH, null);
|
NM_LINUX_CONTAINER_CGROUPS_MOUNT_PATH, null);
|
||||||
|
|
||||||
// remove extra /'s at end or start of cgroupPrefix
|
// remove extra /'s at end or start of cgroupPrefix
|
||||||
if (cgroupPrefix.charAt(0) == '/') {
|
if (cgroupPrefix.charAt(0) == '/') {
|
||||||
cgroupPrefix = cgroupPrefix.substring(1);
|
cgroupPrefix = cgroupPrefix.substring(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int len = cgroupPrefix.length();
|
int len = cgroupPrefix.length();
|
||||||
if (cgroupPrefix.charAt(len - 1) == '/') {
|
if (cgroupPrefix.charAt(len - 1) == '/') {
|
||||||
cgroupPrefix = cgroupPrefix.substring(0, len - 1);
|
cgroupPrefix = cgroupPrefix.substring(0, len - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// mount cgroups if requested
|
// mount cgroups if requested
|
||||||
if (cgroupMount && cgroupMountPath != null) {
|
if (cgroupMount && cgroupMountPath != null) {
|
||||||
ArrayList<String> cgroupKVs = new ArrayList<String>();
|
ArrayList<String> cgroupKVs = new ArrayList<String>();
|
||||||
|
@ -98,14 +98,14 @@ public class CgroupsLCEResourcesHandler implements LCEResourcesHandler {
|
||||||
CONTROLLER_CPU);
|
CONTROLLER_CPU);
|
||||||
lce.mountCgroups(cgroupKVs, cgroupPrefix);
|
lce.mountCgroups(cgroupKVs, cgroupPrefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
initializeControllerPaths();
|
initializeControllerPaths();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
boolean isCpuWeightEnabled() {
|
boolean isCpuWeightEnabled() {
|
||||||
return this.cpuWeightEnabled;
|
return this.cpuWeightEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Next four functions are for an individual cgroup.
|
* Next four functions are for an individual cgroup.
|
||||||
|
@ -155,7 +155,7 @@ public class CgroupsLCEResourcesHandler implements LCEResourcesHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deleteCgroup(String controller, String groupName) {
|
private void deleteCgroup(String controller, String groupName) {
|
||||||
String path = pathForCgroup(controller, groupName);
|
String path = pathForCgroup(controller, groupName);
|
||||||
|
@ -165,7 +165,7 @@ public class CgroupsLCEResourcesHandler implements LCEResourcesHandler {
|
||||||
if (! new File(path).delete()) {
|
if (! new File(path).delete()) {
|
||||||
LOG.warn("Unable to delete cgroup at: " + path);
|
LOG.warn("Unable to delete cgroup at: " + path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Next three functions operate on all the resources we are enforcing.
|
* Next three functions operate on all the resources we are enforcing.
|
||||||
|
@ -178,7 +178,7 @@ public class CgroupsLCEResourcesHandler implements LCEResourcesHandler {
|
||||||
private void setupLimits(ContainerId containerId,
|
private void setupLimits(ContainerId containerId,
|
||||||
Resource containerResource) throws IOException {
|
Resource containerResource) throws IOException {
|
||||||
String containerName = containerId.toString();
|
String containerName = containerId.toString();
|
||||||
|
|
||||||
if (isCpuWeightEnabled()) {
|
if (isCpuWeightEnabled()) {
|
||||||
createCgroup(CONTROLLER_CPU, containerName);
|
createCgroup(CONTROLLER_CPU, containerName);
|
||||||
updateCgroup(CONTROLLER_CPU, containerName, "shares",
|
updateCgroup(CONTROLLER_CPU, containerName, "shares",
|
||||||
|
@ -202,7 +202,7 @@ public class CgroupsLCEResourcesHandler implements LCEResourcesHandler {
|
||||||
|
|
||||||
if (isCpuWeightEnabled()) {
|
if (isCpuWeightEnabled()) {
|
||||||
deleteCgroup(CONTROLLER_CPU, containerName);
|
deleteCgroup(CONTROLLER_CPU, containerName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -222,7 +222,7 @@ public class CgroupsLCEResourcesHandler implements LCEResourcesHandler {
|
||||||
String containerName = containerId.toString();
|
String containerName = containerId.toString();
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder("cgroups=");
|
StringBuilder sb = new StringBuilder("cgroups=");
|
||||||
|
|
||||||
if (isCpuWeightEnabled()) {
|
if (isCpuWeightEnabled()) {
|
||||||
sb.append(pathForCgroup(CONTROLLER_CPU, containerName) + "/cgroup.procs");
|
sb.append(pathForCgroup(CONTROLLER_CPU, containerName) + "/cgroup.procs");
|
||||||
sb.append(",");
|
sb.append(",");
|
||||||
|
@ -231,7 +231,7 @@ public class CgroupsLCEResourcesHandler implements LCEResourcesHandler {
|
||||||
if (sb.charAt(sb.length() - 1) == ',') {
|
if (sb.charAt(sb.length() - 1) == ',') {
|
||||||
sb.deleteCharAt(sb.length() - 1);
|
sb.deleteCharAt(sb.length() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -255,8 +255,8 @@ public class CgroupsLCEResourcesHandler implements LCEResourcesHandler {
|
||||||
BufferedReader in = null;
|
BufferedReader in = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
in = new BufferedReader(new FileReader(new File(MTAB_FILE)));
|
in = new BufferedReader(new FileReader(new File(MTAB_FILE)));
|
||||||
|
|
||||||
for (String str = in.readLine(); str != null;
|
for (String str = in.readLine(); str != null;
|
||||||
str = in.readLine()) {
|
str = in.readLine()) {
|
||||||
Matcher m = MTAB_FILE_FORMAT.matcher(str);
|
Matcher m = MTAB_FILE_FORMAT.matcher(str);
|
||||||
|
@ -316,6 +316,6 @@ public class CgroupsLCEResourcesHandler implements LCEResourcesHandler {
|
||||||
} else {
|
} else {
|
||||||
throw new IOException("Not able to enforce cpu weights; cannot find "
|
throw new IOException("Not able to enforce cpu weights; cannot find "
|
||||||
+ "cgroup for cpu controller in " + MTAB_FILE);
|
+ "cgroup for cpu controller in " + MTAB_FILE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class DefaultLCEResourcesHandler implements LCEResourcesHandler {
|
||||||
private Configuration conf;
|
private Configuration conf;
|
||||||
|
|
||||||
public DefaultLCEResourcesHandler() {
|
public DefaultLCEResourcesHandler() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setConf(Configuration conf) {
|
public void setConf(Configuration conf) {
|
||||||
this.conf = conf;
|
this.conf = conf;
|
||||||
|
@ -42,7 +42,7 @@ public class DefaultLCEResourcesHandler implements LCEResourcesHandler {
|
||||||
@Override
|
@Override
|
||||||
public Configuration getConf() {
|
public Configuration getConf() {
|
||||||
return conf;
|
return conf;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init(LinuxContainerExecutor lce) {
|
public void init(LinuxContainerExecutor lce) {
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue