You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by om...@apache.org on 2011/03/08 05:40:54 UTC
svn commit: r1079160 - in /hadoop/common/branches/yahoo-merge/bin:
hadoop-config.sh slaves.sh
Author: omalley
Date: Tue Mar 8 04:40:54 2011
New Revision: 1079160
URL: http://svn.apache.org/viewvc?rev=1079160&view=rev
Log:
commit f3e08790aea4752f9f32f77feb17c31029eb9131
Author: Erik Steffl <st...@yahoo-inc.com>
Date: Wed Jan 19 16:14:54 2011 -0800
. Add ability to specify hostnames where the daemons are run on commandline.
+++ b/YAHOO-CHANGES.txt
+ . Add ability to specify hostnames where the daemon
+ run on command line (Erik Steffl)
+
Modified:
hadoop/common/branches/yahoo-merge/bin/hadoop-config.sh
hadoop/common/branches/yahoo-merge/bin/slaves.sh
Modified: hadoop/common/branches/yahoo-merge/bin/hadoop-config.sh
URL: http://svn.apache.org/viewvc/hadoop/common/branches/yahoo-merge/bin/hadoop-config.sh?rev=1079160&r1=1079159&r2=1079160&view=diff
==============================================================================
--- hadoop/common/branches/yahoo-merge/bin/hadoop-config.sh (original)
+++ hadoop/common/branches/yahoo-merge/bin/hadoop-config.sh Tue Mar 8 04:40:54 2011
@@ -58,19 +58,40 @@ fi
# Allow alternate conf dir location.
export HADOOP_CONF_DIR="${HADOOP_CONF_DIR:-$HADOOP_HOME/conf}"
-#check to see it is specified whether to use the slaves or the
-# masters file
+# User can specify hostnames or a file where the hostnames are (not both)
+if [[ ( "$HADOOP_SLAVES" != '' ) && ( "$HADOOP_SLAVE_NAMES" != '' ) ]] ; then
+ echo \
+ "Error: Please specify one variable HADOOP_SLAVES or " \
+ "HADOOP_SLAVE_NAME and not both."
+ exit 1
+fi
+
+# Process command line options that specify hosts or file with host
+# list
if [ $# -gt 1 ]
then
if [ "--hosts" = "$1" ]
then
shift
- slavesfile=$1
+ export HADOOP_SLAVES="${HADOOP_CONF_DIR}/$$1"
+ shift
+ elif [ "--hostnames" = "$1" ]
+ then
+ shift
+ export HADOOP_SLAVE_NAMES=$1
shift
- export HADOOP_SLAVES="${HADOOP_CONF_DIR}/$slavesfile"
fi
fi
+# User can specify hostnames or a file where the hostnames are (not both)
+# (same check as above but now we know it's command line options that cause
+# the problem)
+if [[ ( "$HADOOP_SLAVES" != '' ) && ( "$HADOOP_SLAVE_NAMES" != '' ) ]] ; then
+ echo \
+ "Error: Please specify one of --hosts or --hostnames options and not both."
+ exit 1
+fi
+
cygwin=false
case "`uname`" in
CYGWIN*) cygwin=true;;
Modified: hadoop/common/branches/yahoo-merge/bin/slaves.sh
URL: http://svn.apache.org/viewvc/hadoop/common/branches/yahoo-merge/bin/slaves.sh?rev=1079160&r1=1079159&r2=1079160&view=diff
==============================================================================
--- hadoop/common/branches/yahoo-merge/bin/slaves.sh (original)
+++ hadoop/common/branches/yahoo-merge/bin/slaves.sh Tue Mar 8 04:40:54 2011
@@ -40,24 +40,21 @@ bin=`cd "$bin"; pwd`
. "$bin"/hadoop-config.sh
-# If the slaves file is specified in the command line,
-# then it takes precedence over the definition in
-# hadoop-env.sh. Save it here.
-HOSTLIST=$HADOOP_SLAVES
-
if [ -f "${HADOOP_CONF_DIR}/hadoop-env.sh" ]; then
. "${HADOOP_CONF_DIR}/hadoop-env.sh"
fi
-if [ "$HOSTLIST" = "" ]; then
- if [ "$HADOOP_SLAVES" = "" ]; then
- export HOSTLIST="${HADOOP_CONF_DIR}/slaves"
- else
- export HOSTLIST="${HADOOP_SLAVES}"
- fi
+# Where to start the script, see hadoop-config.sh
+# (it set up the variables based on command line options)
+if [ "$HADOOP_SLAVE_NAMES" != '' ] ; then
+ SLAVE_NAMES=$HADOOP_SLAVE_NAMES
+else
+ SLAVE_FILE=${HADOOP_SLAVES:-${HADOOP_CONF_DIR}/slaves}
+ SLAVE_NAMES=$(cat "$SLAVE_FILE" | sed 's/#.*$//;/^$/d')
fi
-for slave in `cat "$HOSTLIST"|sed "s/#.*$//;/^$/d"`; do
+# start the daemons
+for slave in $SLAVE_NAMES ; do
ssh $HADOOP_SSH_OPTS $slave $"${@// /\\ }" \
2>&1 | sed "s/^/$slave: /" &
if [ "$HADOOP_SLAVE_SLEEP" != "" ]; then