YARN-2752. Made ContainerExecutor append "nice -n" arg only when priority adjustment flag is set. Contributed by Xuan Gong.

This commit is contained in:
Zhijie Shen 2014-11-04 15:50:10 -08:00
parent 4ca67c09fc
commit e06c23a6c9
3 changed files with 23 additions and 13 deletions

View File

@ -826,6 +826,9 @@ Release 2.6.0 - UNRELEASED
of races between the launch and the stop-container call and when root
processes crash. (Billie Rinaldi via vinodkv)
YARN-2752. Made ContainerExecutor append "nice -n" arg only when priority
adjustment flag is set. (Xuan Gong via zjshen)
Release 2.5.1 - 2014-09-05
INCOMPATIBLE CHANGES

View File

@ -283,12 +283,16 @@ public abstract class ContainerExecutor implements Configurable {
*/
protected String[] getRunCommand(String command, String groupId,
String userName, Path pidFile, Configuration conf) {
boolean containerSchedPriorityIsSet = false;
int containerSchedPriorityAdjustment =
YarnConfiguration.DEFAULT_NM_CONTAINER_EXECUTOR_SCHED_PRIORITY;
if (conf.get(YarnConfiguration.NM_CONTAINER_EXECUTOR_SCHED_PRIORITY) !=
null) {
containerSchedPriorityIsSet = true;
containerSchedPriorityAdjustment = conf
.getInt(YarnConfiguration.NM_CONTAINER_EXECUTOR_SCHED_PRIORITY, 0);
.getInt(YarnConfiguration.NM_CONTAINER_EXECUTOR_SCHED_PRIORITY,
YarnConfiguration.DEFAULT_NM_CONTAINER_EXECUTOR_SCHED_PRIORITY);
}
if (Shell.WINDOWS) {
@ -296,11 +300,14 @@ public abstract class ContainerExecutor implements Configurable {
"cmd /c " + command };
} else {
List<String> retCommand = new ArrayList<String>();
if (containerSchedPriorityIsSet) {
retCommand.addAll(Arrays.asList("nice", "-n",
Integer.toString(containerSchedPriorityAdjustment)));
}
retCommand.addAll(Arrays.asList("bash", command));
return retCommand.toArray(new String[retCommand.size()]);
}
}
/**

View File

@ -34,7 +34,7 @@ public class TestContainerExecutor {
public void testRunCommandNoPriority() throws Exception {
Configuration conf = new Configuration();
String[] command = containerExecutor.getRunCommand("echo", "group1", "user", null, conf);
assertTrue("first command should be the run command for the platform " + command[0],
assertTrue("first command should be the run command for the platform",
command[0].equals(Shell.WINUTILS) || command[0].equals("bash"));
}