HADOOP-7179. Federation: Improve HDFS startup scripts. Contributed by Erik Steffl and Tanping Wang.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1099262 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Suresh Srinivas 2011-05-03 21:19:25 +00:00
parent 28a6a8301e
commit bef14d0918
3 changed files with 37 additions and 16 deletions

View File

@ -102,6 +102,9 @@ Trunk (unreleased changes)
HADOOP-7235. Refactor the tail command to conform to new FsCommand class. HADOOP-7235. Refactor the tail command to conform to new FsCommand class.
(Daryn Sharp via szetszwo) (Daryn Sharp via szetszwo)
HADOOP-7179. Federation: Improve HDFS startup scripts. (Erik Steffl
and Tanping Wang via suresh)
OPTIMIZATIONS OPTIMIZATIONS
BUG FIXES BUG FIXES

View File

@ -47,19 +47,40 @@ fi
# Allow alternate conf dir location. # Allow alternate conf dir location.
export HADOOP_CONF_DIR="${HADOOP_CONF_DIR:-$HADOOP_HOME/conf}" export HADOOP_CONF_DIR="${HADOOP_CONF_DIR:-$HADOOP_HOME/conf}"
#check to see it is specified whether to use the slaves or the # User can specify hostnames or a file where the hostnames are (not both)
# masters file 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 ] if [ $# -gt 1 ]
then then
if [ "--hosts" = "$1" ] if [ "--hosts" = "$1" ]
then then
shift shift
slavesfile=$1 export HADOOP_SLAVES="${HADOOP_CONF_DIR}/$$1"
shift
elif [ "--hostnames" = "$1" ]
then
shift
export HADOOP_SLAVE_NAMES=$1
shift shift
export HADOOP_SLAVES="${HADOOP_CONF_DIR}/$slavesfile"
fi fi
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 cygwin=false
case "`uname`" in case "`uname`" in
CYGWIN*) cygwin=true;; CYGWIN*) cygwin=true;;

View File

@ -40,24 +40,21 @@ bin=`cd "$bin"; pwd`
. "$bin"/hadoop-config.sh . "$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 if [ -f "${HADOOP_CONF_DIR}/hadoop-env.sh" ]; then
. "${HADOOP_CONF_DIR}/hadoop-env.sh" . "${HADOOP_CONF_DIR}/hadoop-env.sh"
fi fi
if [ "$HOSTLIST" = "" ]; then # Where to start the script, see hadoop-config.sh
if [ "$HADOOP_SLAVES" = "" ]; then # (it set up the variables based on command line options)
export HOSTLIST="${HADOOP_CONF_DIR}/slaves" if [ "$HADOOP_SLAVE_NAMES" != '' ] ; then
else SLAVE_NAMES=$HADOOP_SLAVE_NAMES
export HOSTLIST="${HADOOP_SLAVES}" else
fi SLAVE_FILE=${HADOOP_SLAVES:-${HADOOP_CONF_DIR}/slaves}
SLAVE_NAMES=$(cat "$SLAVE_FILE" | sed 's/#.*$//;/^$/d')
fi fi
for slave in `cat "$HOSTLIST"|sed "s/#.*$//;/^$/d"`; do # start the daemons
for slave in $SLAVE_NAMES ; do
ssh $HADOOP_SSH_OPTS $slave $"${@// /\\ }" \ ssh $HADOOP_SSH_OPTS $slave $"${@// /\\ }" \
2>&1 | sed "s/^/$slave: /" & 2>&1 | sed "s/^/$slave: /" &
if [ "$HADOOP_SLAVE_SLEEP" != "" ]; then if [ "$HADOOP_SLAVE_SLEEP" != "" ]; then