Просмотр исходного кода

HADOOP-468. Add HADOOP_NICENESS environment variable to set the scheduling priority for daemons. Contributed by Vetle Roeim.

git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk@434077 13f79535-47bb-0310-9956-ffa450edef68
Doug Cutting 18 лет назад
Родитель
Сommit
502b4b4596
3 измененных файлов с 13 добавлено и 1 удалено
  1. 3 0
      CHANGES.txt
  2. 7 1
      bin/hadoop-daemon.sh
  3. 3 0
      conf/hadoop-env.sh.template

+ 3 - 0
CHANGES.txt

@@ -65,6 +65,9 @@ Trunk (unreleased changes)
     /bin/sh scripts since HADOOP-352.
     (Jean-Baptiste Quenot via cutting)
 
+16. HADOOP-468.  Add HADOOP_NICENESS environment variable to set
+    scheduling priority for daemons.  (Vetle Roeim via cutting)
+
 
 Release 0.5.0 - 2006-08-04
 

+ 7 - 1
bin/hadoop-daemon.sh

@@ -9,6 +9,7 @@
 #   HADOOP_MASTER    host:path where hadoop code should be rsync'd from
 #   HADOOP_PID_DIR   The pid files are stored. /tmp by default.
 #   HADOOP_IDENT_STRING   A string representing this instance of hadoop. $USER by default
+#   HADOOP_NICENESS The scheduling priority for daemons. Defaults to 0.
 ##
 
 usage="Usage: hadoop-daemon.sh [--config <conf-dir>] (start|stop) <hadoop-command> <args...>"
@@ -54,6 +55,11 @@ export HADOOP_ROOT_LOGGER="INFO,DRFA"
 log=$HADOOP_LOG_DIR/hadoop-$HADOOP_IDENT_STRING-$command-`hostname`.out
 pid=$HADOOP_PID_DIR/hadoop-$HADOOP_IDENT_STRING-$command.pid
 
+# Set default scheduling priority
+if [ "$HADOOP_NICENESS" == "" ]; then
+    export HADOOP_NICENESS=0
+fi
+
 case $startStop in
 
   (start)
@@ -71,7 +77,7 @@ case $startStop in
     fi
 
     echo starting $command, logging to $log
-    nohup "$HADOOP_HOME"/bin/hadoop --config $HADOOP_CONF_DIR $command "$@" > "$log" 2>&1 < /dev/null &
+    nohup nice -n $HADOOP_NICENESS "$HADOOP_HOME"/bin/hadoop --config $HADOOP_CONF_DIR $command "$@" > "$log" 2>&1 < /dev/null &
     echo $! > $pid
     sleep 1; head "$log"
     ;;

+ 3 - 0
conf/hadoop-env.sh.template

@@ -36,3 +36,6 @@
 
 # A string representing this instance of hadoop. $USER by default.
 # export HADOOP_IDENT_STRING=$USER
+
+# The scheduling priority for daemon processes.  See 'man nice'.
+# export HADOOP_NICENESS=10