diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/conf/YarnConfiguration.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/conf/YarnConfiguration.java
index 51731f3..9fa99a3 100644
--- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/conf/YarnConfiguration.java
+++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/conf/YarnConfiguration.java
@@ -535,7 +535,9 @@
* Adjustment to make to the container os scheduling priority.
* The valid values for this could vary depending on the platform.
* On Linux, higher values mean run the containers at a less
- * favorable priority than the NM.
+ * favorable priority than the NM.
+ * On Window the values are 32 (NORMAL), 64 (LOW), 128 (HIGH), 256 (REALTIME),
+ * 16384 (BELOWNORMAL) and 32768 (ABOVENORMAL).
* The value specified is an int.
*/
public static final String NM_CONTAINER_EXECUTOR_SCHED_PRIORITY =
diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/resources/yarn-default.xml hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/resources/yarn-default.xml
index c94b782..3af1b9a 100644
--- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/resources/yarn-default.xml
+++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/resources/yarn-default.xml
@@ -636,6 +636,14 @@
org.apache.hadoop.yarn.server.nodemanager.DefaultContainerExecutor
+
+
+ Adjustment to make to the container os scheduling priority. The valid values for this could vary depending on the platform.
+On Linux, higher values mean run the containers at a less favorable priority than the NM.
+On Window the values are 32 (NORMAL), 64 (LOW), 128 (HIGH), 256 (REALTIME), 16384 (BELOWNORMAL) and 32768 (ABOVENORMAL).
+The value specified is an int.
+ yarn.nodemanager.container-executor.os.sched.priority.adjustment
+
Number of threads container manager uses.
diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/ContainerExecutor.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/ContainerExecutor.java
index b76b17d..1cba905 100644
--- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/ContainerExecutor.java
+++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/ContainerExecutor.java
@@ -58,10 +58,19 @@
private ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
private final ReadLock readLock = lock.readLock();
private final WriteLock writeLock = lock.writeLock();
-
+
+ protected boolean containerSchedPriorityIsSet = false;
+ protected int containerSchedPriorityAdjustment = 0;
+
@Override
public void setConf(Configuration conf) {
this.conf = conf;
+ if (conf.get(YarnConfiguration.NM_CONTAINER_EXECUTOR_SCHED_PRIORITY) != null) {
+ containerSchedPriorityIsSet = true;
+ containerSchedPriorityAdjustment = conf
+ .getInt(YarnConfiguration.NM_CONTAINER_EXECUTOR_SCHED_PRIORITY,
+ YarnConfiguration.DEFAULT_NM_CONTAINER_EXECUTOR_SCHED_PRIORITY);
+ }
}
@Override
diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/LinuxContainerExecutor.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/LinuxContainerExecutor.java
index cbdcb13..97865fc 100644
--- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/LinuxContainerExecutor.java
+++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/LinuxContainerExecutor.java
@@ -54,8 +54,6 @@
private Pattern nonsecureLocalUserPattern;
private String containerExecutorExe;
private LCEResourcesHandler resourcesHandler;
- private boolean containerSchedPriorityIsSet = false;
- private int containerSchedPriorityAdjustment = 0;
@Override
@@ -68,12 +66,6 @@ public void setConf(Configuration conf) {
DefaultLCEResourcesHandler.class, LCEResourcesHandler.class), conf);
resourcesHandler.setConf(conf);
- if (conf.get(YarnConfiguration.NM_CONTAINER_EXECUTOR_SCHED_PRIORITY) != null) {
- containerSchedPriorityIsSet = true;
- containerSchedPriorityAdjustment = conf
- .getInt(YarnConfiguration.NM_CONTAINER_EXECUTOR_SCHED_PRIORITY,
- YarnConfiguration.DEFAULT_NM_CONTAINER_EXECUTOR_SCHED_PRIORITY);
- }
nonsecureLocalUser = conf.get(
YarnConfiguration.NM_NONSECURE_MODE_LOCAL_USER_KEY,
YarnConfiguration.DEFAULT_NM_NONSECURE_MODE_LOCAL_USER);
diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/WindowsSecureContainerExecutor.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/WindowsSecureContainerExecutor.java
index 40c79fc..0fb807d 100644
--- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/WindowsSecureContainerExecutor.java
+++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/WindowsSecureContainerExecutor.java
@@ -22,6 +22,7 @@
import java.io.PrintStream;
import java.net.InetSocketAddress;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -43,6 +44,24 @@
*
*/
public class WindowsSecureContainerExecutor extends DefaultContainerExecutor {
+
+ // These are the NT API priority levels
+ private final static int NORMAL_PRIORITY_CLASS = 0x00000020;
+ private final static int IDLE_PRIORITY_CLASS = 0x0000040;
+ private final static int HIGH_PRIORITY_CLASS = 0x00000080;
+ private final static int REALTIME_PRIORITY_CLASS = 0x00000100;
+ private final static int BELOW_NORMAL_PRIORITY_CLASS = 0x00004000;
+ private final static int ABOVE_NORMAL_PRIORITY_CLASS = 0x00008000;
+
+ //These are the start.exe command line priority levels
+ private final static String NORMAL_PRIORITY = "NORMAL";
+ private final static String IDLE_PRIORITY = "LOW";
+ private final static String HIGH_PRIORITY = "HIGH";
+ private final static String REALTIME_PRIORITY = "REALTIME";
+ private final static String ABOVENORMAL_PRIORITY = "ABOVENORMAL";
+ private final static String BELOWNORMAL_PRIORITY = "BELOWNORMAL";
+
+ private String startPriorityLevel = null;
private static final Log LOG = LogFactory
.getLog(WindowsSecureContainerExecutor.class);
@@ -66,13 +85,55 @@ protected void writeLocalWrapperScript(Path launchDst, Path pidFile, PrintStream
public void setConf(Configuration conf) {
super.setConf(conf);
nodeManagerGroup = conf.get(YarnConfiguration.NM_WINDOWS_SECURE_CONTAINER_GROUP);
+ if (containerSchedPriorityIsSet) {
+ switch(containerSchedPriorityAdjustment) {
+ case NORMAL_PRIORITY_CLASS:
+ startPriorityLevel = NORMAL_PRIORITY;
+ break;
+ case IDLE_PRIORITY_CLASS:
+ startPriorityLevel = IDLE_PRIORITY;
+ break;
+ case HIGH_PRIORITY_CLASS:
+ startPriorityLevel = HIGH_PRIORITY;
+ break;
+ case REALTIME_PRIORITY_CLASS:
+ startPriorityLevel = REALTIME_PRIORITY;
+ break;
+ case BELOW_NORMAL_PRIORITY_CLASS:
+ startPriorityLevel = BELOWNORMAL_PRIORITY;
+ break;
+ case ABOVE_NORMAL_PRIORITY_CLASS:
+ startPriorityLevel = ABOVENORMAL_PRIORITY;
+ break;
+ default:
+ LOG.warn(String.format("An invalid priority level %d was set for %s. Valid values are:" +
+ "%d (%s), %d (%s), %d (%s), %d (%s) and %d (%s)." +
+ "No priority adjustment will be used for container launch.",
+ containerSchedPriorityAdjustment, YarnConfiguration.NM_CONTAINER_EXECUTOR_SCHED_PRIORITY,
+ NORMAL_PRIORITY_CLASS, NORMAL_PRIORITY,
+ IDLE_PRIORITY_CLASS, IDLE_PRIORITY,
+ HIGH_PRIORITY_CLASS, HIGH_PRIORITY,
+ REALTIME_PRIORITY_CLASS, REALTIME_PRIORITY,
+ BELOW_NORMAL_PRIORITY_CLASS, BELOWNORMAL_PRIORITY,
+ ABOVE_NORMAL_PRIORITY_CLASS, ABOVENORMAL_PRIORITY));
+ containerSchedPriorityIsSet = false;
+ break;
+ }
+ if (containerSchedPriorityIsSet) {
+ LOG.info(String.format("Priority adjustment set to %d (%s)",
+ containerSchedPriorityAdjustment, startPriorityLevel));
+ }
+ }
}
@Override
protected String[] getRunCommand(String command, String groupId,
String userName, Path pidFile, Configuration conf) {
- return new String[] { Shell.WINUTILS, "task", "createAsUser", groupId, userName,
- pidFile.toString(), "cmd /c " + command };
+ List commands = new ArrayList();
+ addSchedPriorityCommand(commands);
+ commands.addAll(Arrays.asList(Shell.WINUTILS, "task", "createAsUser", groupId, userName,
+ pidFile.toString(), "cmd /c " + command));
+ return commands.toArray(new String[commands.size()]);
}
@Override
@@ -104,6 +165,23 @@ protected void setScriptExecutable(Path script, String owner) throws IOException
public void localizeClasspathJar(Path classpathJar, String owner) throws IOException {
lfs.setOwner(classpathJar, owner, nodeManagerGroup);
}
+
+ /*(nojavadoc)
+ * Adds the start /HIGH /wait in front of the command. This adjusts the priority.
+ * /WAIT will cause it stop until command executes
+ * /B to prevent it from opening a new console window, keep stdout/stderr current.
+ */
+ protected void addSchedPriorityCommand(List command) {
+ if (containerSchedPriorityIsSet) {
+ // start is an internal cmd.exe command
+ command.add("cmd.exe");
+ command.add("/C");
+ command.add("start");
+ command.add("/" + startPriorityLevel);
+ command.add("/WAIT");
+ command.add("/B");
+ }
+ }
@Override
public void startLocalizer(Path nmPrivateContainerTokens,
@@ -132,6 +210,8 @@ public void startLocalizer(Path nmPrivateContainerTokens,
LOG.info(String.format("cwdApp: %s", cwdApp));
command = new ArrayList();
+
+ addSchedPriorityCommand(command);
command.add(Shell.WINUTILS);
command.add("task");
@@ -169,6 +249,8 @@ public void startLocalizer(Path nmPrivateContainerTokens,
command.add(dir);
}
commandArray = command.toArray(new String[command.size()]);
+
+
shExec = new ShellCommandExecutor(
commandArray, cwdApp);