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 aw...@apache.org on 2014/08/19 14:11:18 UTC
svn commit: r1618847 [1/2] - in
/hadoop/common/trunk/hadoop-common-project/hadoop-common: ./ src/main/bin/
src/main/conf/
Author: aw
Date: Tue Aug 19 12:11:17 2014
New Revision: 1618847
URL: http://svn.apache.org/r1618847
Log:
HADOOP-9902. Shell script rewrite (aw)
Added:
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/bin/hadoop-functions.sh
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/bin/hadoop-layout.sh.example
Modified:
hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/bin/hadoop
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/bin/hadoop-config.sh
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/bin/hadoop-daemon.sh
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/bin/hadoop-daemons.sh
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/bin/rcc
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/bin/slaves.sh
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/bin/start-all.sh
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/bin/stop-all.sh
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/conf/hadoop-env.sh
Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt?rev=1618847&r1=1618846&r2=1618847&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt (original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt Tue Aug 19 12:11:17 2014
@@ -9,6 +9,8 @@ Trunk (Unreleased)
HADOOP-10474 Move o.a.h.record to hadoop-streaming. (wheat9)
+ HADOOP-9902. Shell script rewrite (aw)
+
NEW FEATURES
HADOOP-10433. Key Management Server based on KeyProvider API. (tucu)
Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/bin/hadoop
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/bin/hadoop?rev=1618847&r1=1618846&r2=1618847&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/bin/hadoop (original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/bin/hadoop Tue Aug 19 12:11:17 2014
@@ -15,130 +15,164 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-# This script runs the hadoop core commands.
-
-bin=`which $0`
-bin=`dirname ${bin}`
-bin=`cd "$bin" > /dev/null; pwd`
-
-DEFAULT_LIBEXEC_DIR="$bin"/../libexec
-HADOOP_LIBEXEC_DIR=${HADOOP_LIBEXEC_DIR:-$DEFAULT_LIBEXEC_DIR}
-. $HADOOP_LIBEXEC_DIR/hadoop-config.sh
-
-function print_usage(){
+function hadoop_usage()
+{
echo "Usage: hadoop [--config confdir] COMMAND"
echo " where COMMAND is one of:"
- echo " fs run a generic filesystem user client"
- echo " version print the version"
- echo " jar <jar> run a jar file"
- echo " checknative [-a|-h] check native hadoop and compression libraries availability"
- echo " distcp <srcurl> <desturl> copy file or directories recursively"
- echo " archive -archiveName NAME -p <parent path> <src>* <dest> create a hadoop archive"
+ echo " archive -archiveName NAME -p <parent path> <src>* <dest>"
+ echo " create a Hadoop archive"
+ echo " checknative [-a|-h] check native Hadoop and compression "
+ echo " libraries availability"
echo " classpath prints the class path needed to get the"
+ echo " Hadoop jar and the required libraries"
echo " credential interact with credential providers"
- echo " Hadoop jar and the required libraries"
echo " daemonlog get/set the log level for each daemon"
+ echo " distch path:owner:group:permisson"
+ echo " distributed metadata changer"
+ echo " distcp <srcurl> <desturl> "
+ echo " copy file or directories recursively"
+ echo " fs run a generic filesystem user client"
+ echo " jar <jar> run a jar file"
+ echo " jnipath prints the java.library.path"
+ echo " key manage keys via the KeyProvider"
+ echo " version print the version"
echo " or"
echo " CLASSNAME run the class named CLASSNAME"
echo ""
echo "Most commands print help when invoked w/o parameters."
}
+
+# This script runs the hadoop core commands.
+
+# let's locate libexec...
+if [[ -n "${HADOOP_PREFIX}" ]]; then
+ DEFAULT_LIBEXEC_DIR="${HADOOP_PREFIX}/libexec"
+else
+ this="${BASH_SOURCE-$0}"
+ bin=$(cd -P -- "$(dirname -- "${this}")" >/dev/null && pwd -P)
+ DEFAULT_LIBEXEC_DIR="${bin}/../libexec"
+fi
+
+HADOOP_LIBEXEC_DIR="${HADOOP_LIBEXEC_DIR:-$DEFAULT_LIBEXEC_DIR}"
+# shellcheck disable=SC2034
+HADOOP_NEW_CONFIG=true
+if [[ -f "${HADOOP_LIBEXEC_DIR}/hadoop-config.sh" ]]; then
+ . "${HADOOP_LIBEXEC_DIR}/hadoop-config.sh"
+else
+ echo "ERROR: Cannot execute ${HADOOP_LIBEXEC_DIR}/hadoop-config.sh." 2>&1
+ exit 1
+fi
+
if [ $# = 0 ]; then
- print_usage
- exit
+ hadoop_exit_with_usage 1
fi
COMMAND=$1
-case $COMMAND in
- # usage flags
- --help|-help|-h)
- print_usage
- exit
- ;;
-
- #hdfs commands
- namenode|secondarynamenode|datanode|dfs|dfsadmin|fsck|balancer|fetchdt|oiv|dfsgroups|portmap|nfs3)
- echo "DEPRECATED: Use of this script to execute hdfs command is deprecated." 1>&2
- echo "Instead use the hdfs command for it." 1>&2
- echo "" 1>&2
- #try to locate hdfs and if present, delegate to it.
- shift
- if [ -f "${HADOOP_HDFS_HOME}"/bin/hdfs ]; then
- exec "${HADOOP_HDFS_HOME}"/bin/hdfs ${COMMAND/dfsgroups/groups} "$@"
- elif [ -f "${HADOOP_PREFIX}"/bin/hdfs ]; then
- exec "${HADOOP_PREFIX}"/bin/hdfs ${COMMAND/dfsgroups/groups} "$@"
+shift
+
+case ${COMMAND} in
+ balancer|datanode|dfs|dfsadmin|dfsgroups| \
+ namenode|secondarynamenode|fsck|fetchdt|oiv| \
+ portmap|nfs3)
+ hadoop_error "WARNING: Use of this script to execute ${COMMAND} is deprecated."
+ COMMAND=${COMMAND/dfsgroups/groups}
+ hadoop_error "WARNING: Attempting to execute replacement \"hdfs ${COMMAND}\" instead."
+ hadoop_error ""
+ #try to locate hdfs and if present, delegate to it.
+ if [[ -f "${HADOOP_HDFS_HOME}/bin/hdfs" ]]; then
+ # shellcheck disable=SC2086
+ exec "${HADOOP_HDFS_HOME}/bin/hdfs" \
+ --config "${HADOOP_CONF_DIR}" "${COMMAND}" "$@"
+ elif [[ -f "${HADOOP_PREFIX}/bin/hdfs" ]]; then
+ # shellcheck disable=SC2086
+ exec "${HADOOP_PREFIX}/bin/hdfs" \
+ --config "${HADOOP_CONF_DIR}" "${COMMAND}" "$@"
else
- echo "HADOOP_HDFS_HOME not found!"
+ hadoop_error "HADOOP_HDFS_HOME not found!"
exit 1
fi
- ;;
-
+ ;;
+
#mapred commands for backwards compatibility
pipes|job|queue|mrgroups|mradmin|jobtracker|tasktracker)
- echo "DEPRECATED: Use of this script to execute mapred command is deprecated." 1>&2
- echo "Instead use the mapred command for it." 1>&2
- echo "" 1>&2
+ hadoop_error "WARNING: Use of this script to execute ${COMMAND} is deprecated."
+ COMMAND=${COMMAND/mrgroups/groups}
+ hadoop_error "WARNING: Attempting to execute replacement \"mapred ${COMMAND}\" instead."
+ hadoop_error ""
#try to locate mapred and if present, delegate to it.
- shift
- if [ -f "${HADOOP_MAPRED_HOME}"/bin/mapred ]; then
- exec "${HADOOP_MAPRED_HOME}"/bin/mapred ${COMMAND/mrgroups/groups} "$@"
- elif [ -f "${HADOOP_PREFIX}"/bin/mapred ]; then
- exec "${HADOOP_PREFIX}"/bin/mapred ${COMMAND/mrgroups/groups} "$@"
+ if [[ -f "${HADOOP_MAPRED_HOME}/bin/mapred" ]]; then
+ exec "${HADOOP_MAPRED_HOME}/bin/mapred" \
+ --config "${HADOOP_CONF_DIR}" "${COMMAND}" "$@"
+ elif [[ -f "${HADOOP_PREFIX}/bin/mapred" ]]; then
+ exec "${HADOOP_PREFIX}/bin/mapred" \
+ --config "${HADOOP_CONF_DIR}" "${COMMAND}" "$@"
else
- echo "HADOOP_MAPRED_HOME not found!"
+ hadoop_error "HADOOP_MAPRED_HOME not found!"
exit 1
fi
- ;;
-
- #core commands
- *)
- # the core commands
- if [ "$COMMAND" = "fs" ] ; then
- CLASS=org.apache.hadoop.fs.FsShell
- elif [ "$COMMAND" = "version" ] ; then
- CLASS=org.apache.hadoop.util.VersionInfo
- elif [ "$COMMAND" = "jar" ] ; then
- CLASS=org.apache.hadoop.util.RunJar
- elif [ "$COMMAND" = "key" ] ; then
- CLASS=org.apache.hadoop.crypto.key.KeyShell
- elif [ "$COMMAND" = "checknative" ] ; then
- CLASS=org.apache.hadoop.util.NativeLibraryChecker
- elif [ "$COMMAND" = "distcp" ] ; then
- CLASS=org.apache.hadoop.tools.DistCp
- CLASSPATH=${CLASSPATH}:${TOOL_PATH}
- elif [ "$COMMAND" = "daemonlog" ] ; then
- CLASS=org.apache.hadoop.log.LogLevel
- elif [ "$COMMAND" = "archive" ] ; then
- CLASS=org.apache.hadoop.tools.HadoopArchives
- CLASSPATH=${CLASSPATH}:${TOOL_PATH}
- elif [ "$COMMAND" = "credential" ] ; then
- CLASS=org.apache.hadoop.security.alias.CredentialShell
- elif [ "$COMMAND" = "classpath" ] ; then
- if [ "$#" -eq 1 ]; then
- # No need to bother starting up a JVM for this simple case.
- echo $CLASSPATH
- exit
- else
- CLASS=org.apache.hadoop.util.Classpath
- fi
- elif [[ "$COMMAND" = -* ]] ; then
- # class and package names cannot begin with a -
- echo "Error: No command named \`$COMMAND' was found. Perhaps you meant \`hadoop ${COMMAND#-}'"
- exit 1
- else
- CLASS=$COMMAND
+ ;;
+ archive)
+ CLASS=org.apache.hadoop.tools.HadoopArchives
+ hadoop_add_classpath "${TOOL_PATH}"
+ ;;
+ checknative)
+ CLASS=org.apache.hadoop.util.NativeLibraryChecker
+ ;;
+ classpath)
+ if [[ "$#" -eq 1 ]]; then
+ CLASS=org.apache.hadoop.util.Classpath
+ else
+ hadoop_finalize
+ echo "${CLASSPATH}"
+ exit 0
fi
- shift
-
- # Always respect HADOOP_OPTS and HADOOP_CLIENT_OPTS
- HADOOP_OPTS="$HADOOP_OPTS $HADOOP_CLIENT_OPTS"
-
- #make sure security appender is turned off
- HADOOP_OPTS="$HADOOP_OPTS -Dhadoop.security.logger=${HADOOP_SECURITY_LOGGER:-INFO,NullAppender}"
-
- export CLASSPATH=$CLASSPATH
- exec "$JAVA" $JAVA_HEAP_MAX $HADOOP_OPTS $CLASS "$@"
- ;;
-
+ ;;
+ credential)
+ CLASS=org.apache.hadoop.security.alias.CredentialShell
+ ;;
+ daemonlog)
+ CLASS=org.apache.hadoop.log.LogLevel
+ ;;
+ distch)
+ CLASS=org.apache.hadoop.tools.DistCh
+ hadoop_add_classpath "${TOOL_PATH}"
+ ;;
+ distcp)
+ CLASS=org.apache.hadoop.tools.DistCp
+ hadoop_add_classpath "${TOOL_PATH}"
+ ;;
+ fs)
+ CLASS=org.apache.hadoop.fs.FsShell
+ ;;
+ jar)
+ CLASS=org.apache.hadoop.util.RunJar
+ ;;
+ jnipath)
+ hadoop_finalize
+ echo "${JAVA_LIBRARY_PATH}"
+ exit 0
+ ;;
+ key)
+ CLASS=org.apache.hadoop.crypto.key.KeyShell
+ ;;
+ version)
+ CLASS=org.apache.hadoop.util.VersionInfo
+ ;;
+ -*|hdfs)
+ hadoop_exit_with_usage 1
+ ;;
+ *)
+ CLASS="${COMMAND}"
+ ;;
esac
+
+# Always respect HADOOP_OPTS and HADOOP_CLIENT_OPTS
+HADOOP_OPTS="${HADOOP_OPTS} ${HADOOP_CLIENT_OPTS}"
+
+hadoop_add_param HADOOP_OPTS Xmx "${JAVA_HEAP_MAX}"
+
+hadoop_finalize
+export CLASSPATH
+hadoop_java_exec "${COMMAND}" "${CLASS}" "$@"
+
Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/bin/hadoop-config.sh
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/bin/hadoop-config.sh?rev=1618847&r1=1618846&r2=1618847&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/bin/hadoop-config.sh (original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/bin/hadoop-config.sh Tue Aug 19 12:11:17 2014
@@ -1,3 +1,5 @@
+#
+#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
@@ -13,280 +15,176 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+####
+# IMPORTANT
+####
+
+## The hadoop-config.sh tends to get executed by non-Hadoop scripts.
+## Those parts expect this script to parse/manipulate $@. In order
+## to maintain backward compatibility, this means a surprising
+## lack of functions for bits that would be much better off in
+## a function.
+##
+## In other words, yes, there is some bad things happen here and
+## unless we break the rest of the ecosystem, we can't change it. :(
+
+
# included in all the hadoop scripts with source command
# should not be executable directly
# also should not be passed any arguments, since we need original $*
-
-# Resolve links ($0 may be a softlink) and convert a relative path
-# to an absolute path. NB: The -P option requires bash built-ins
-# or POSIX:2001 compliant cd and pwd.
-
-# HADOOP_CLASSPATH Extra Java CLASSPATH entries.
-#
-# HADOOP_USER_CLASSPATH_FIRST When defined, the HADOOP_CLASSPATH is
-# added in the beginning of the global
-# classpath. Can be defined, for example,
-# by doing
-# export HADOOP_USER_CLASSPATH_FIRST=true
-#
-
-this="${BASH_SOURCE-$0}"
-common_bin=$(cd -P -- "$(dirname -- "$this")" && pwd -P)
-script="$(basename -- "$this")"
-this="$common_bin/$script"
-
-[ -f "$common_bin/hadoop-layout.sh" ] && . "$common_bin/hadoop-layout.sh"
-
-HADOOP_COMMON_DIR=${HADOOP_COMMON_DIR:-"share/hadoop/common"}
-HADOOP_COMMON_LIB_JARS_DIR=${HADOOP_COMMON_LIB_JARS_DIR:-"share/hadoop/common/lib"}
-HADOOP_COMMON_LIB_NATIVE_DIR=${HADOOP_COMMON_LIB_NATIVE_DIR:-"lib/native"}
-HDFS_DIR=${HDFS_DIR:-"share/hadoop/hdfs"}
-HDFS_LIB_JARS_DIR=${HDFS_LIB_JARS_DIR:-"share/hadoop/hdfs/lib"}
-YARN_DIR=${YARN_DIR:-"share/hadoop/yarn"}
-YARN_LIB_JARS_DIR=${YARN_LIB_JARS_DIR:-"share/hadoop/yarn/lib"}
-MAPRED_DIR=${MAPRED_DIR:-"share/hadoop/mapreduce"}
-MAPRED_LIB_JARS_DIR=${MAPRED_LIB_JARS_DIR:-"share/hadoop/mapreduce/lib"}
-
-# the root of the Hadoop installation
-# See HADOOP-6255 for directory structure layout
-HADOOP_DEFAULT_PREFIX=$(cd -P -- "$common_bin"/.. && pwd -P)
-HADOOP_PREFIX=${HADOOP_PREFIX:-$HADOOP_DEFAULT_PREFIX}
-export HADOOP_PREFIX
-
-#check to see if the conf dir is given as an optional argument
-if [ $# -gt 1 ]
-then
- if [ "--config" = "$1" ]
- then
- shift
- confdir=$1
- if [ ! -d "$confdir" ]; then
- echo "Error: Cannot find configuration directory: $confdir"
- exit 1
- fi
- shift
- HADOOP_CONF_DIR=$confdir
- fi
-fi
-
-# Allow alternate conf dir location.
-if [ -e "${HADOOP_PREFIX}/conf/hadoop-env.sh" ]; then
- DEFAULT_CONF_DIR="conf"
-else
- DEFAULT_CONF_DIR="etc/hadoop"
-fi
-
-export HADOOP_CONF_DIR="${HADOOP_CONF_DIR:-$HADOOP_PREFIX/$DEFAULT_CONF_DIR}"
-
-if [ -f "${HADOOP_CONF_DIR}/hadoop-env.sh" ]; then
- . "${HADOOP_CONF_DIR}/hadoop-env.sh"
-fi
-
-# 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."
+#
+# after doing more config, caller should also exec finalize
+# function to finish last minute/default configs for
+# settings that might be different between daemons & interactive
+
+# you must be this high to ride the ride
+if [[ -z "${BASH_VERSINFO}" ]] || [[ "${BASH_VERSINFO}" -lt 3 ]]; then
+ echo "Hadoop requires bash v3 or better. Sorry."
exit 1
fi
-# Process command line options that specify hosts or file with host
-# list
-if [ $# -gt 1 ]
-then
- if [ "--hosts" = "$1" ]
- then
- shift
- export HADOOP_SLAVES="${HADOOP_CONF_DIR}/$1"
- shift
- elif [ "--hostnames" = "$1" ]
- then
- shift
- export HADOOP_SLAVE_NAMES=$1
- shift
- 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
+# In order to get partially bootstrapped, we need to figure out where
+# we are located. Chances are good that our caller has already done
+# this work for us, but just in case...
+
+if [[ -z "${HADOOP_LIBEXEC_DIR}" ]]; then
+ _hadoop_common_this="${BASH_SOURCE-$0}"
+ HADOOP_LIBEXEC_DIR=$(cd -P -- "$(dirname -- "${_hadoop_common_this}")" >/dev/null && pwd -P)
fi
-# check if net.ipv6.bindv6only is set to 1
-bindv6only=$(/sbin/sysctl -n net.ipv6.bindv6only 2> /dev/null)
-if [ -n "$bindv6only" ] && [ "$bindv6only" -eq "1" ] && [ "$HADOOP_ALLOW_IPV6" != "yes" ]
-then
- echo "Error: \"net.ipv6.bindv6only\" is set to 1 - Java networking could be broken"
- echo "For more info: http://wiki.apache.org/hadoop/HadoopIPv6"
+# get our functions defined for usage later
+if [[ -f "${HADOOP_LIBEXEC_DIR}/hadoop-functions.sh" ]]; then
+ . "${HADOOP_LIBEXEC_DIR}/hadoop-functions.sh"
+else
+ echo "ERROR: Unable to exec ${HADOOP_LIBEXEC_DIR}/hadoop-functions.sh." 1>&2
exit 1
fi
-# Newer versions of glibc use an arena memory allocator that causes virtual
-# memory usage to explode. This interacts badly with the many threads that
-# we use in Hadoop. Tune the variable down to prevent vmem explosion.
-export MALLOC_ARENA_MAX=${MALLOC_ARENA_MAX:-4}
-
-# Attempt to set JAVA_HOME if it is not set
-if [[ -z $JAVA_HOME ]]; then
- # On OSX use java_home (or /Library for older versions)
- if [ "Darwin" == "$(uname -s)" ]; then
- if [ -x /usr/libexec/java_home ]; then
- export JAVA_HOME=($(/usr/libexec/java_home))
- else
- export JAVA_HOME=(/Library/Java/Home)
- fi
- fi
-
- # Bail if we did not detect it
- if [[ -z $JAVA_HOME ]]; then
- echo "Error: JAVA_HOME is not set and could not be found." 1>&2
- exit 1
- fi
-fi
-
-JAVA=$JAVA_HOME/bin/java
-
-# check envvars which might override default args
-if [ "$HADOOP_HEAPSIZE" != "" ]; then
- #echo "run with heapsize $HADOOP_HEAPSIZE"
- JAVA_HEAP_MAX="-Xmx""$HADOOP_HEAPSIZE""m"
- #echo $JAVA_HEAP_MAX
-fi
-
-# CLASSPATH initially contains $HADOOP_CONF_DIR
-CLASSPATH="${HADOOP_CONF_DIR}"
-
-# so that filenames w/ spaces are handled correctly in loops below
-IFS=
-
-if [ "$HADOOP_COMMON_HOME" = "" ]; then
- if [ -d "${HADOOP_PREFIX}/$HADOOP_COMMON_DIR" ]; then
- export HADOOP_COMMON_HOME=$HADOOP_PREFIX
- fi
-fi
-
-# for releases, add core hadoop jar & webapps to CLASSPATH
-if [ -d "$HADOOP_COMMON_HOME/$HADOOP_COMMON_DIR/webapps" ]; then
- CLASSPATH=${CLASSPATH}:$HADOOP_COMMON_HOME/$HADOOP_COMMON_DIR
-fi
-
-if [ -d "$HADOOP_COMMON_HOME/$HADOOP_COMMON_LIB_JARS_DIR" ]; then
- CLASSPATH=${CLASSPATH}:$HADOOP_COMMON_HOME/$HADOOP_COMMON_LIB_JARS_DIR'/*'
+# allow overrides of the above and pre-defines of the below
+if [[ -f "${HADOOP_LIBEXEC_DIR}/hadoop-layout.sh" ]]; then
+ . "${HADOOP_LIBEXEC_DIR}/hadoop-layout.sh"
fi
-CLASSPATH=${CLASSPATH}:$HADOOP_COMMON_HOME/$HADOOP_COMMON_DIR'/*'
-
-# default log directory & file
-if [ "$HADOOP_LOG_DIR" = "" ]; then
- HADOOP_LOG_DIR="$HADOOP_PREFIX/logs"
-fi
-if [ "$HADOOP_LOGFILE" = "" ]; then
- HADOOP_LOGFILE='hadoop.log'
-fi
-
-# default policy file for service-level authorization
-if [ "$HADOOP_POLICYFILE" = "" ]; then
- HADOOP_POLICYFILE="hadoop-policy.xml"
-fi
-
-# restore ordinary behaviour
-unset IFS
-
-# setup 'java.library.path' for native-hadoop code if necessary
-
-if [ -d "${HADOOP_PREFIX}/build/native" -o -d "${HADOOP_PREFIX}/$HADOOP_COMMON_LIB_NATIVE_DIR" ]; then
-
- if [ -d "${HADOOP_PREFIX}/$HADOOP_COMMON_LIB_NATIVE_DIR" ]; then
- if [ "x$JAVA_LIBRARY_PATH" != "x" ]; then
- JAVA_LIBRARY_PATH=${JAVA_LIBRARY_PATH}:${HADOOP_PREFIX}/$HADOOP_COMMON_LIB_NATIVE_DIR
- else
- JAVA_LIBRARY_PATH=${HADOOP_PREFIX}/$HADOOP_COMMON_LIB_NATIVE_DIR
- fi
- fi
-fi
-
-# setup a default TOOL_PATH
-TOOL_PATH="${TOOL_PATH:-$HADOOP_PREFIX/share/hadoop/tools/lib/*}"
+#
+# IMPORTANT! We are not executing user provided code yet!
+#
-HADOOP_OPTS="$HADOOP_OPTS -Dhadoop.log.dir=$HADOOP_LOG_DIR"
-HADOOP_OPTS="$HADOOP_OPTS -Dhadoop.log.file=$HADOOP_LOGFILE"
-HADOOP_OPTS="$HADOOP_OPTS -Dhadoop.home.dir=$HADOOP_PREFIX"
-HADOOP_OPTS="$HADOOP_OPTS -Dhadoop.id.str=$HADOOP_IDENT_STRING"
-HADOOP_OPTS="$HADOOP_OPTS -Dhadoop.root.logger=${HADOOP_ROOT_LOGGER:-INFO,console}"
-if [ "x$JAVA_LIBRARY_PATH" != "x" ]; then
- HADOOP_OPTS="$HADOOP_OPTS -Djava.library.path=$JAVA_LIBRARY_PATH"
- export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$JAVA_LIBRARY_PATH
-fi
-HADOOP_OPTS="$HADOOP_OPTS -Dhadoop.policy.file=$HADOOP_POLICYFILE"
-
-# Disable ipv6 as it can cause issues
-HADOOP_OPTS="$HADOOP_OPTS -Djava.net.preferIPv4Stack=true"
-
-# put hdfs in classpath if present
-if [ "$HADOOP_HDFS_HOME" = "" ]; then
- if [ -d "${HADOOP_PREFIX}/$HDFS_DIR" ]; then
- export HADOOP_HDFS_HOME=$HADOOP_PREFIX
- fi
-fi
+# Let's go! Base definitions so we can move forward
+hadoop_bootstrap_init
-if [ -d "$HADOOP_HDFS_HOME/$HDFS_DIR/webapps" ]; then
- CLASSPATH=${CLASSPATH}:$HADOOP_HDFS_HOME/$HDFS_DIR
-fi
+# let's find our conf.
+#
+# first, check and process params passed to us
+# we process this in-line so that we can directly modify $@
+# if something downstream is processing that directly,
+# we need to make sure our params have been ripped out
+# note that we do many of them here for various utilities.
+# this provides consistency and forces a more consistent
+# user experience
+
+
+# save these off in case our caller needs them
+# shellcheck disable=SC2034
+HADOOP_USER_PARAMS="$@"
+
+HADOOP_DAEMON_MODE="default"
+
+while [[ -z "${_hadoop_common_done}" ]]; do
+ case $1 in
+ --buildpaths)
+ # shellcheck disable=SC2034
+ HADOOP_ENABLE_BUILD_PATHS=true
+ shift
+ ;;
+ --config)
+ shift
+ confdir=$1
+ shift
+ if [[ -d "${confdir}" ]]; then
+ # shellcheck disable=SC2034
+ YARN_CONF_DIR="${confdir}"
+ # shellcheck disable=SC2034
+ HADOOP_CONF_DIR="${confdir}"
+ elif [[ -z "${confdir}" ]]; then
+ hadoop_error "ERROR: No parameter provided for --config "
+ hadoop_exit_with_usage 1
+ else
+ hadoop_error "ERROR: Cannot find configuration directory \"${confdir}\""
+ hadoop_exit_with_usage 1
+ fi
+ ;;
+ --daemon)
+ shift
+ HADOOP_DAEMON_MODE=$1
+ shift
+ if [[ -z "${HADOOP_DAEMON_MODE}" || \
+ ! "${HADOOP_DAEMON_MODE}" =~ ^st(art|op|atus)$ ]]; then
+ hadoop_error "ERROR: --daemon must be followed by either \"start\", \"stop\", or \"status\"."
+ hadoop_exit_with_usage 1
+ fi
+ ;;
+ --help|-help|-h|help|--h|--\?|-\?|\?)
+ hadoop_exit_with_usage 0
+ ;;
+ --hostnames)
+ shift
+ # shellcheck disable=SC2034
+ HADOOP_SLAVE_NAMES="$1"
+ shift
+ ;;
+ --hosts)
+ shift
+ hadoop_populate_slaves_file "$1"
+ shift
+ ;;
+ *)
+ _hadoop_common_done=true
+ ;;
+ esac
+done
-if [ -d "$HADOOP_HDFS_HOME/$HDFS_LIB_JARS_DIR" ]; then
- CLASSPATH=${CLASSPATH}:$HADOOP_HDFS_HOME/$HDFS_LIB_JARS_DIR'/*'
-fi
+hadoop_find_confdir
+hadoop_exec_hadoopenv
-CLASSPATH=${CLASSPATH}:$HADOOP_HDFS_HOME/$HDFS_DIR'/*'
+#
+# IMPORTANT! User provided code is now available!
+#
-# put yarn in classpath if present
-if [ "$HADOOP_YARN_HOME" = "" ]; then
- if [ -d "${HADOOP_PREFIX}/$YARN_DIR" ]; then
- export HADOOP_YARN_HOME=$HADOOP_PREFIX
- fi
-fi
+# do all the OS-specific startup bits here
+# this allows us to get a decent JAVA_HOME,
+# call crle for LD_LIBRARY_PATH, etc.
+hadoop_os_tricks
-if [ -d "$HADOOP_YARN_HOME/$YARN_DIR/webapps" ]; then
- CLASSPATH=${CLASSPATH}:$HADOOP_YARN_HOME/$YARN_DIR
-fi
+hadoop_java_setup
-if [ -d "$HADOOP_YARN_HOME/$YARN_LIB_JARS_DIR" ]; then
- CLASSPATH=${CLASSPATH}:$HADOOP_YARN_HOME/$YARN_LIB_JARS_DIR'/*'
-fi
+hadoop_basic_init
-CLASSPATH=${CLASSPATH}:$HADOOP_YARN_HOME/$YARN_DIR'/*'
-
-# put mapred in classpath if present AND different from YARN
-if [ "$HADOOP_MAPRED_HOME" = "" ]; then
- if [ -d "${HADOOP_PREFIX}/$MAPRED_DIR" ]; then
- export HADOOP_MAPRED_HOME=$HADOOP_PREFIX
- fi
+# inject any sub-project overrides, defaults, etc.
+if declare -F hadoop_subproject_init >/dev/null ; then
+ hadoop_subproject_init
fi
-if [ "$HADOOP_MAPRED_HOME/$MAPRED_DIR" != "$HADOOP_YARN_HOME/$YARN_DIR" ] ; then
- if [ -d "$HADOOP_MAPRED_HOME/$MAPRED_DIR/webapps" ]; then
- CLASSPATH=${CLASSPATH}:$HADOOP_MAPRED_HOME/$MAPRED_DIR
- fi
-
- if [ -d "$HADOOP_MAPRED_HOME/$MAPRED_LIB_JARS_DIR" ]; then
- CLASSPATH=${CLASSPATH}:$HADOOP_MAPRED_HOME/$MAPRED_LIB_JARS_DIR'/*'
- fi
+# get the native libs in there pretty quick
+hadoop_add_javalibpath "${HADOOP_PREFIX}/build/native"
+hadoop_add_javalibpath "${HADOOP_PREFIX}/${HADOOP_COMMON_LIB_NATIVE_DIR}"
- CLASSPATH=${CLASSPATH}:$HADOOP_MAPRED_HOME/$MAPRED_DIR'/*'
-fi
+# get the basic java class path for these subprojects
+# in as quickly as possible since other stuff
+# will definitely depend upon it.
+#
+# at some point, this will get replaced with something pluggable
+# so that these functions can sit in their projects rather than
+# common
+#
+for i in common hdfs yarn mapred
+do
+ hadoop_add_to_classpath_$i
+done
-# Add the user-specified CLASSPATH via HADOOP_CLASSPATH
-# Add it first or last depending on if user has
-# set env-var HADOOP_USER_CLASSPATH_FIRST
-if [ "$HADOOP_CLASSPATH" != "" ]; then
- # Prefix it if its to be preceded
- if [ "$HADOOP_USER_CLASSPATH_FIRST" != "" ]; then
- CLASSPATH=${HADOOP_CLASSPATH}:${CLASSPATH}
- else
- CLASSPATH=${CLASSPATH}:${HADOOP_CLASSPATH}
- fi
+#
+# backwards compatibility. new stuff should
+# call this when they are ready
+#
+if [[ -z "${HADOOP_NEW_CONFIG}" ]]; then
+ hadoop_finalize
fi
Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/bin/hadoop-daemon.sh
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/bin/hadoop-daemon.sh?rev=1618847&r1=1618846&r2=1618847&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/bin/hadoop-daemon.sh (original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/bin/hadoop-daemon.sh Tue Aug 19 12:11:17 2014
@@ -15,200 +15,42 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-
-# Runs a Hadoop command as a daemon.
-#
-# Environment Variables
-#
-# HADOOP_CONF_DIR Alternate conf dir. Default is ${HADOOP_PREFIX}/conf.
-# HADOOP_LOG_DIR Where log files are stored. PWD by default.
-# 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>] [--hosts hostlistfile] [--script script] (start|stop) <hadoop-command> <args...>"
-
-# if no args specified, show usage
-if [ $# -le 1 ]; then
- echo $usage
- exit 1
-fi
-
-bin=`dirname "${BASH_SOURCE-$0}"`
-bin=`cd "$bin"; pwd`
-
-DEFAULT_LIBEXEC_DIR="$bin"/../libexec
-HADOOP_LIBEXEC_DIR=${HADOOP_LIBEXEC_DIR:-$DEFAULT_LIBEXEC_DIR}
-. $HADOOP_LIBEXEC_DIR/hadoop-config.sh
-
-# get arguments
-
-#default value
-hadoopScript="$HADOOP_PREFIX"/bin/hadoop
-if [ "--script" = "$1" ]
- then
- shift
- hadoopScript=$1
- shift
-fi
-startStop=$1
-shift
-command=$1
-shift
-
-hadoop_rotate_log ()
+function hadoop_usage
{
- log=$1;
- num=5;
- if [ -n "$2" ]; then
- num=$2
- fi
- if [ -f "$log" ]; then # rotate logs
- while [ $num -gt 1 ]; do
- prev=`expr $num - 1`
- [ -f "$log.$prev" ] && mv "$log.$prev" "$log.$num"
- num=$prev
- done
- mv "$log" "$log.$num";
- fi
+ echo "Usage: hadoop-daemon.sh [--config confdir] (start|stop|status) <hadoop-command> <args...>"
}
-if [ -f "${HADOOP_CONF_DIR}/hadoop-env.sh" ]; then
- . "${HADOOP_CONF_DIR}/hadoop-env.sh"
-fi
-
-# Determine if we're starting a secure datanode, and if so, redefine appropriate variables
-if [ "$command" == "datanode" ] && [ "$EUID" -eq 0 ] && [ -n "$HADOOP_SECURE_DN_USER" ]; then
- export HADOOP_PID_DIR=$HADOOP_SECURE_DN_PID_DIR
- export HADOOP_LOG_DIR=$HADOOP_SECURE_DN_LOG_DIR
- export HADOOP_IDENT_STRING=$HADOOP_SECURE_DN_USER
- starting_secure_dn="true"
-fi
-
-#Determine if we're starting a privileged NFS, if so, redefine the appropriate variables
-if [ "$command" == "nfs3" ] && [ "$EUID" -eq 0 ] && [ -n "$HADOOP_PRIVILEGED_NFS_USER" ]; then
- export HADOOP_PID_DIR=$HADOOP_PRIVILEGED_NFS_PID_DIR
- export HADOOP_LOG_DIR=$HADOOP_PRIVILEGED_NFS_LOG_DIR
- export HADOOP_IDENT_STRING=$HADOOP_PRIVILEGED_NFS_USER
- starting_privileged_nfs="true"
-fi
-
-if [ "$HADOOP_IDENT_STRING" = "" ]; then
- export HADOOP_IDENT_STRING="$USER"
-fi
-
-
-# get log directory
-if [ "$HADOOP_LOG_DIR" = "" ]; then
- export HADOOP_LOG_DIR="$HADOOP_PREFIX/logs"
+# let's locate libexec...
+if [[ -n "${HADOOP_PREFIX}" ]]; then
+ DEFAULT_LIBEXEC_DIR="${HADOOP_PREFIX}/libexec"
+else
+ this="${BASH_SOURCE-$0}"
+ bin=$(cd -P -- "$(dirname -- "${this}")" >/dev/null && pwd -P)
+ DEFAULT_LIBEXEC_DIR="${bin}/../libexec"
+fi
+
+HADOOP_LIBEXEC_DIR="${HADOOP_LIBEXEC_DIR:-$DEFAULT_LIBEXEC_DIR}"
+# shellcheck disable=SC2034
+HADOOP_NEW_CONFIG=true
+if [[ -f "${HADOOP_LIBEXEC_DIR}/hdfs-config.sh" ]]; then
+ . "${HADOOP_LIBEXEC_DIR}/hdfs-config.sh"
+else
+ echo "ERROR: Cannot execute ${HADOOP_LIBEXEC_DIR}/hdfs-config.sh." 2>&1
+ exit 1
fi
-if [ ! -w "$HADOOP_LOG_DIR" ] ; then
- mkdir -p "$HADOOP_LOG_DIR"
- chown $HADOOP_IDENT_STRING $HADOOP_LOG_DIR
+if [[ $# = 0 ]]; then
+ hadoop_exit_with_usage 1
fi
-if [ "$HADOOP_PID_DIR" = "" ]; then
- HADOOP_PID_DIR=/tmp
-fi
+daemonmode=$1
+shift
-# some variables
-export HADOOP_LOGFILE=hadoop-$HADOOP_IDENT_STRING-$command-$HOSTNAME.log
-export HADOOP_ROOT_LOGGER=${HADOOP_ROOT_LOGGER:-"INFO,RFA"}
-export HADOOP_SECURITY_LOGGER=${HADOOP_SECURITY_LOGGER:-"INFO,RFAS"}
-export HDFS_AUDIT_LOGGER=${HDFS_AUDIT_LOGGER:-"INFO,NullAppender"}
-log=$HADOOP_LOG_DIR/hadoop-$HADOOP_IDENT_STRING-$command-$HOSTNAME.out
-pid=$HADOOP_PID_DIR/hadoop-$HADOOP_IDENT_STRING-$command.pid
-HADOOP_STOP_TIMEOUT=${HADOOP_STOP_TIMEOUT:-5}
-
-# Set default scheduling priority
-if [ "$HADOOP_NICENESS" = "" ]; then
- export HADOOP_NICENESS=0
+if [[ -z "${HADOOP_HDFS_HOME}" ]]; then
+ hdfsscript="${HADOOP_PREFIX}/bin/hdfs"
+else
+ hdfsscript="${HADOOP_HDFS_HOME}/bin/hdfs"
fi
-case $startStop in
-
- (start)
-
- [ -w "$HADOOP_PID_DIR" ] || mkdir -p "$HADOOP_PID_DIR"
-
- if [ -f $pid ]; then
- if kill -0 `cat $pid` > /dev/null 2>&1; then
- echo $command running as process `cat $pid`. Stop it first.
- exit 1
- fi
- fi
-
- if [ "$HADOOP_MASTER" != "" ]; then
- echo rsync from $HADOOP_MASTER
- rsync -a -e ssh --delete --exclude=.svn --exclude='logs/*' --exclude='contrib/hod/logs/*' $HADOOP_MASTER/ "$HADOOP_PREFIX"
- fi
-
- hadoop_rotate_log $log
- echo starting $command, logging to $log
- cd "$HADOOP_PREFIX"
- case $command in
- namenode|secondarynamenode|datanode|journalnode|dfs|dfsadmin|fsck|balancer|zkfc)
- if [ -z "$HADOOP_HDFS_HOME" ]; then
- hdfsScript="$HADOOP_PREFIX"/bin/hdfs
- else
- hdfsScript="$HADOOP_HDFS_HOME"/bin/hdfs
- fi
- nohup nice -n $HADOOP_NICENESS $hdfsScript --config $HADOOP_CONF_DIR $command "$@" > "$log" 2>&1 < /dev/null &
- ;;
- (*)
- nohup nice -n $HADOOP_NICENESS $hadoopScript --config $HADOOP_CONF_DIR $command "$@" > "$log" 2>&1 < /dev/null &
- ;;
- esac
- echo $! > $pid
- sleep 1
- head "$log"
- # capture the ulimit output
- if [ "true" = "$starting_secure_dn" ]; then
- echo "ulimit -a for secure datanode user $HADOOP_SECURE_DN_USER" >> $log
- # capture the ulimit info for the appropriate user
- su --shell=/bin/bash $HADOOP_SECURE_DN_USER -c 'ulimit -a' >> $log 2>&1
- elif [ "true" = "$starting_privileged_nfs" ]; then
- echo "ulimit -a for privileged nfs user $HADOOP_PRIVILEGED_NFS_USER" >> $log
- su --shell=/bin/bash $HADOOP_PRIVILEGED_NFS_USER -c 'ulimit -a' >> $log 2>&1
- else
- echo "ulimit -a for user $USER" >> $log
- ulimit -a >> $log 2>&1
- fi
- sleep 3;
- if ! ps -p $! > /dev/null ; then
- exit 1
- fi
- ;;
-
- (stop)
-
- if [ -f $pid ]; then
- TARGET_PID=`cat $pid`
- if kill -0 $TARGET_PID > /dev/null 2>&1; then
- echo stopping $command
- kill $TARGET_PID
- sleep $HADOOP_STOP_TIMEOUT
- if kill -0 $TARGET_PID > /dev/null 2>&1; then
- echo "$command did not stop gracefully after $HADOOP_STOP_TIMEOUT seconds: killing with kill -9"
- kill -9 $TARGET_PID
- fi
- else
- echo no $command to stop
- fi
- rm -f $pid
- else
- echo no $command to stop
- fi
- ;;
-
- (*)
- echo $usage
- exit 1
- ;;
-
-esac
-
+exec "$hdfsscript" --config "${HADOOP_CONF_DIR}" --daemon "${daemonmode}" "$@"
Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/bin/hadoop-daemons.sh
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/bin/hadoop-daemons.sh?rev=1618847&r1=1618846&r2=1618847&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/bin/hadoop-daemons.sh (original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/bin/hadoop-daemons.sh Tue Aug 19 12:11:17 2014
@@ -18,19 +18,34 @@
# Run a Hadoop command on all slave hosts.
-usage="Usage: hadoop-daemons.sh [--config confdir] [--hosts hostlistfile] [start|stop] command args..."
+function hadoop_usage
+{
+ echo "Usage: hadoop-daemons.sh [--config confdir] [--hosts hostlistfile] (start|stop|status) <hadoop-command> <args...>"
+}
+
+this="${BASH_SOURCE-$0}"
+bin=$(cd -P -- "$(dirname -- "${this}")" >/dev/null && pwd -P)
+
+# let's locate libexec...
+if [[ -n "${HADOOP_PREFIX}" ]]; then
+ DEFAULT_LIBEXEC_DIR="${HADOOP_PREFIX}/libexec"
+else
+ DEFAULT_LIBEXEC_DIR="${bin}/../libexec"
+fi
-# if no args specified, show usage
-if [ $# -le 1 ]; then
- echo $usage
+HADOOP_LIBEXEC_DIR="${HADOOP_LIBEXEC_DIR:-$DEFAULT_LIBEXEC_DIR}"
+# shellcheck disable=SC2034
+HADOOP_NEW_CONFIG=true
+if [[ -f "${HADOOP_LIBEXEC_DIR}/hadoop-config.sh" ]]; then
+ . "${HADOOP_LIBEXEC_DIR}/hadoop-config.sh"
+else
+ echo "ERROR: Cannot execute ${HADOOP_LIBEXEC_DIR}/hadoop-config.sh." 2>&1
exit 1
fi
-bin=`dirname "${BASH_SOURCE-$0}"`
-bin=`cd "$bin"; pwd`
-
-DEFAULT_LIBEXEC_DIR="$bin"/../libexec
-HADOOP_LIBEXEC_DIR=${HADOOP_LIBEXEC_DIR:-$DEFAULT_LIBEXEC_DIR}
-. $HADOOP_LIBEXEC_DIR/hadoop-config.sh
+if [[ $# = 0 ]]; then
+ hadoop_exit_with_usage 1
+fi
-exec "$bin/slaves.sh" --config $HADOOP_CONF_DIR cd "$HADOOP_PREFIX" \; "$bin/hadoop-daemon.sh" --config $HADOOP_CONF_DIR "$@"
+hadoop_connect_to_hosts "${bin}/hadoop-daemon.sh" \
+--config "${HADOOP_CONF_DIR}" "$@"
Added: hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/bin/hadoop-functions.sh
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/bin/hadoop-functions.sh?rev=1618847&view=auto
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/bin/hadoop-functions.sh (added)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/bin/hadoop-functions.sh Tue Aug 19 12:11:17 2014
@@ -0,0 +1,1036 @@
+#!/bin/bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+function hadoop_error
+{
+ # NOTE: This function is not user replaceable.
+
+ echo "$*" 1>&2
+}
+
+function hadoop_bootstrap_init
+{
+ # NOTE: This function is not user replaceable.
+
+ # the root of the Hadoop installation
+ # See HADOOP-6255 for the expected directory structure layout
+
+ # By now, HADOOP_LIBEXEC_DIR should have been defined upstream
+ # We can piggyback off of that to figure out where the default
+ # HADOOP_FREFIX should be. This allows us to run without
+ # HADOOP_PREFIX ever being defined by a human! As a consequence
+ # HADOOP_LIBEXEC_DIR now becomes perhaps the single most powerful
+ # env var within Hadoop.
+ if [[ -z "${HADOOP_LIBEXEC_DIR}" ]]; then
+ hadoop_error "HADOOP_LIBEXEC_DIR is not defined. Exiting."
+ exit 1
+ fi
+ HADOOP_DEFAULT_PREFIX=$(cd -P -- "${HADOOP_LIBEXEC_DIR}/.." >/dev/null && pwd -P)
+ HADOOP_PREFIX=${HADOOP_PREFIX:-$HADOOP_DEFAULT_PREFIX}
+ export HADOOP_PREFIX
+
+ #
+ # short-cuts. vendors may redefine these as well, preferably
+ # in hadoop-layouts.sh
+ #
+ HADOOP_COMMON_DIR=${HADOOP_COMMON_DIR:-"share/hadoop/common"}
+ HADOOP_COMMON_LIB_JARS_DIR=${HADOOP_COMMON_LIB_JARS_DIR:-"share/hadoop/common/lib"}
+ HADOOP_COMMON_LIB_NATIVE_DIR=${HADOOP_COMMON_LIB_NATIVE_DIR:-"lib/native"}
+ HDFS_DIR=${HDFS_DIR:-"share/hadoop/hdfs"}
+ HDFS_LIB_JARS_DIR=${HDFS_LIB_JARS_DIR:-"share/hadoop/hdfs/lib"}
+ YARN_DIR=${YARN_DIR:-"share/hadoop/yarn"}
+ YARN_LIB_JARS_DIR=${YARN_LIB_JARS_DIR:-"share/hadoop/yarn/lib"}
+ MAPRED_DIR=${MAPRED_DIR:-"share/hadoop/mapreduce"}
+ MAPRED_LIB_JARS_DIR=${MAPRED_LIB_JARS_DIR:-"share/hadoop/mapreduce/lib"}
+ # setup a default TOOL_PATH
+ TOOL_PATH=${TOOL_PATH:-${HADOOP_PREFIX}/share/hadoop/tools/lib/*}
+
+ export HADOOP_OS_TYPE=${HADOOP_OS_TYPE:-$(uname -s)}
+
+
+ # defaults
+ export HADOOP_OPTS=${HADOOP_OPTS:-"-Djava.net.preferIPv4Stack=true"}
+}
+
+function hadoop_find_confdir
+{
+ # NOTE: This function is not user replaceable.
+
+ # Look for the basic hadoop configuration area.
+ #
+ #
+ # An attempt at compatibility with some Hadoop 1.x
+ # installs.
+ if [[ -e "${HADOOP_PREFIX}/conf/hadoop-env.sh" ]]; then
+ DEFAULT_CONF_DIR="conf"
+ else
+ DEFAULT_CONF_DIR="etc/hadoop"
+ fi
+ export HADOOP_CONF_DIR="${HADOOP_CONF_DIR:-${HADOOP_PREFIX}/${DEFAULT_CONF_DIR}}"
+}
+
+function hadoop_exec_hadoopenv
+{
+ # NOTE: This function is not user replaceable.
+
+ if [[ -z "${HADOOP_ENV_PROCESSED}" ]]; then
+ if [[ -f "${HADOOP_CONF_DIR}/hadoop-env.sh" ]]; then
+ export HADOOP_ENV_PROCESSED=true
+ . "${HADOOP_CONF_DIR}/hadoop-env.sh"
+ fi
+ fi
+}
+
+
+function hadoop_basic_init
+{
+ # Some of these are also set in hadoop-env.sh.
+ # we still set them here just in case hadoop-env.sh is
+ # broken in some way, set up defaults, etc.
+ #
+ # but it is important to note that if you update these
+ # you also need to update hadoop-env.sh as well!!!
+
+ # CLASSPATH initially contains $HADOOP_CONF_DIR
+ CLASSPATH="${HADOOP_CONF_DIR}"
+
+ if [[ -z "${HADOOP_COMMON_HOME}" ]] &&
+ [[ -d "${HADOOP_PREFIX}/${HADOOP_COMMON_DIR}" ]]; then
+ export HADOOP_COMMON_HOME="${HADOOP_PREFIX}"
+ fi
+
+ # default policy file for service-level authorization
+ HADOOP_POLICYFILE=${HADOOP_POLICYFILE:-"hadoop-policy.xml"}
+
+ # define HADOOP_HDFS_HOME
+ if [[ -z "${HADOOP_HDFS_HOME}" ]] &&
+ [[ -d "${HADOOP_PREFIX}/${HDFS_DIR}" ]]; then
+ export HADOOP_HDFS_HOME="${HADOOP_PREFIX}"
+ fi
+
+ # define HADOOP_YARN_HOME
+ if [[ -z "${HADOOP_YARN_HOME}" ]] &&
+ [[ -d "${HADOOP_PREFIX}/${YARN_DIR}" ]]; then
+ export HADOOP_YARN_HOME="${HADOOP_PREFIX}"
+ fi
+
+ # define HADOOP_MAPRED_HOME
+ if [[ -z "${HADOOP_MAPRED_HOME}" ]] &&
+ [[ -d "${HADOOP_PREFIX}/${MAPRED_DIR}" ]]; then
+ export HADOOP_MAPRED_HOME="${HADOOP_PREFIX}"
+ fi
+
+ HADOOP_IDENT_STRING=${HADOP_IDENT_STRING:-$USER}
+ HADOOP_LOG_DIR=${HADOOP_LOG_DIR:-"${HADOOP_PREFIX}/logs"}
+ HADOOP_LOGFILE=${HADOOP_LOGFILE:-hadoop.log}
+ HADOOP_NICENESS=${HADOOP_NICENESS:-0}
+ HADOOP_STOP_TIMEOUT=${HADOOP_STOP_TIMEOUT:-5}
+ HADOOP_PID_DIR=${HADOOP_PID_DIR:-/tmp}
+ HADOOP_ROOT_LOGGER=${HADOOP_ROOT_LOGGER:-INFO,console}
+ HADOOP_DAEMON_ROOT_LOGGER=${HADOOP_DAEMON_ROOT_LOGGER:-INFO,RFA}
+ HADOOP_SECURITY_LOGGER=${HADOOP_SECURITY_LOGGER:-INFO,NullAppender}
+ HADOOP_HEAPSIZE=${HADOOP_HEAPSIZE:-1024}
+ HADOOP_SSH_OPTS=${HADOOP_SSH_OPTS:-"-o BatchMode=yes -o StrictHostKeyChecking=no -o ConnectTimeout=10s"}
+ HADOOP_SECURE_LOG_DIR=${HADOOP_SECURE_LOG_DIR:-${HADOOP_LOG_DIR}}
+ HADOOP_SECURE_PID_DIR=${HADOOP_SECURE_PID_DIR:-${HADOOP_PID_DIR}}
+ HADOOP_SSH_PARALLEL=${HADOOP_SSH_PARALLEL:-10}
+}
+
+function hadoop_populate_slaves_file()
+{
+ # NOTE: This function is not user replaceable.
+
+ local slavesfile=$1
+ shift
+ if [[ -f "${slavesfile}" ]]; then
+ # shellcheck disable=2034
+ HADOOP_SLAVES="${slavesfile}"
+ elif [[ -f "${HADOOP_CONF_DIR}/${slavesfile}" ]]; then
+ # shellcheck disable=2034
+ HADOOP_SLAVES="${HADOOP_CONF_DIR}/${slavesfile}"
+ # shellcheck disable=2034
+ YARN_SLAVES="${HADOOP_CONF_DIR}/${slavesfile}"
+ else
+ hadoop_error "ERROR: Cannot find hosts file \"${slavesfile}\""
+ hadoop_exit_with_usage 1
+ fi
+}
+
+function hadoop_rotate_log
+{
+ #
+ # log rotation (mainly used for .out files)
+ # Users are likely to replace this one for something
+ # that gzips or uses dates or who knows what.
+ #
+ # be aware that &1 and &2 might go through here
+ # so don't do anything too crazy...
+ #
+ local log=$1;
+ local num=${2:-5};
+
+ if [[ -f "${log}" ]]; then # rotate logs
+ while [[ ${num} -gt 1 ]]; do
+ #shellcheck disable=SC2086
+ let prev=${num}-1
+ if [[ -f "${log}.${prev}" ]]; then
+ mv "${log}.${prev}" "${log}.${num}"
+ fi
+ num=${prev}
+ done
+ mv "${log}" "${log}.${num}"
+ fi
+}
+
+function hadoop_actual_ssh
+{
+ # we are passing this function to xargs
+ # should get hostname followed by rest of command line
+ local slave=$1
+ shift
+
+ # shellcheck disable=SC2086
+ ssh ${HADOOP_SSH_OPTS} ${slave} $"${@// /\\ }" 2>&1 | sed "s/^/$slave: /"
+}
+
+function hadoop_connect_to_hosts
+{
+ # shellcheck disable=SC2124
+ local params="$@"
+
+ #
+ # ssh (or whatever) to a host
+ #
+ # User can specify hostnames or a file where the hostnames are (not both)
+ if [[ -n "${HADOOP_SLAVES}" && -n "${HADOOP_SLAVE_NAMES}" ]] ; then
+ hadoop_error "ERROR: Both HADOOP_SLAVES and HADOOP_SLAVE_NAME were defined. Aborting."
+ exit 1
+ fi
+
+ if [[ -n "${HADOOP_SLAVE_NAMES}" ]] ; then
+ SLAVE_NAMES=${HADOOP_SLAVE_NAMES}
+ else
+ SLAVE_FILE=${HADOOP_SLAVES:-${HADOOP_CONF_DIR}/slaves}
+ fi
+
+ # if pdsh is available, let's use it. otherwise default
+ # to a loop around ssh. (ugh)
+ if [[ -e '/usr/bin/pdsh' ]]; then
+ if [[ -z "${HADOOP_SLAVE_NAMES}" ]] ; then
+ # if we were given a file, just let pdsh deal with it.
+ # shellcheck disable=SC2086
+ PDSH_SSH_ARGS_APPEND="${HADOOP_SSH_OPTS}" pdsh \
+ -f "${HADOOP_SSH_PARALLEL}" -w ^"${SLAVE_FILE}" $"${@// /\\ }" 2>&1
+ else
+ # no spaces allowed in the pdsh arg host list
+ # shellcheck disable=SC2086
+ SLAVE_NAMES=$(echo ${SLAVE_NAMES} | tr -s ' ' ,)
+ PDSH_SSH_ARGS_APPEND="${HADOOP_SSH_OPTS}" pdsh \
+ -f "${HADOOP_SSH_PARALLEL}" -w "${SLAVE_NAMES}" $"${@// /\\ }" 2>&1
+ fi
+ else
+ if [[ -z "${SLAVE_NAMES}" ]]; then
+ SLAVE_NAMES=$(sed 's/#.*$//;/^$/d' "${SLAVE_FILE}")
+ fi
+
+ # quoting here gets tricky. it's easier to push it into a function
+ # so that we don't have to deal with it. However...
+ # xargs can't use a function so instead we'll export it out
+ # and force it into a subshell
+ # moral of the story: just use pdsh.
+ export -f hadoop_actual_ssh
+ export HADOOP_SSH_OPTS
+ echo "${SLAVE_NAMES}" | \
+ xargs -n 1 -P"${HADOOP_SSH_PARALLEL}" \
+ -I {} bash -c -- "hadoop_actual_ssh {} ${params}"
+ wait
+ fi
+}
+
+function hadoop_add_param
+{
+ #
+ # general param dedupe..
+ # $1 is what we are adding to
+ # $2 is the name of what we want to add (key)
+ # $3 is the key+value of what we're adding
+ #
+ # doing it this way allows us to support all sorts of
+ # different syntaxes, just so long as they are space
+ # delimited
+ #
+ if [[ ! ${!1} =~ $2 ]] ; then
+ # shellcheck disable=SC2086
+ eval $1="'${!1} $3'"
+ fi
+}
+
+function hadoop_add_classpath
+{
+ # two params:
+ # $1 = directory, file, wildcard, whatever to add
+ # $2 = before or after, which determines where in the
+ # classpath this object should go. default is after
+ # return 0 = success
+ # return 1 = failure (duplicate, doesn't exist, whatever)
+
+ # However, with classpath (& JLP), we can do dedupe
+ # along with some sanity checking (e.g., missing directories)
+ # since we have a better idea of what is legal
+ #
+ # for wildcard at end, we can
+ # at least check the dir exists
+ if [[ $1 =~ ^.*\*$ ]]; then
+ local mp=$(dirname "$1")
+ if [[ ! -d "${mp}" ]]; then
+ return 1
+ fi
+
+ # no wildcard in the middle, so check existence
+ # (doesn't matter *what* it is)
+ elif [[ ! $1 =~ ^.*\*.*$ ]] && [[ ! -e "$1" ]]; then
+ return 1
+ fi
+
+ if [[ -z "${CLASSPATH}" ]]; then
+ CLASSPATH=$1
+ elif [[ ":${CLASSPATH}:" != *":$1:"* ]]; then
+ if [[ "$2" = "before" ]]; then
+ CLASSPATH="$1:${CLASSPATH}"
+ else
+ CLASSPATH+=:$1
+ fi
+ fi
+ return 0
+}
+
+function hadoop_add_colonpath
+{
+ # two params:
+ # $1 = directory, file, wildcard, whatever to add
+ # $2 = before or after, which determines where in the
+ # classpath this object should go
+ # return 0 = success
+ # return 1 = failure (duplicate)
+
+ # this is CLASSPATH, JLP, etc but with dedupe but no
+ # other checking
+ if [[ -d "${2}" ]] && [[ ":${!1}:" != *":$2:"* ]]; then
+ if [[ -z "${!1}" ]]; then
+ # shellcheck disable=SC2086
+ eval $1="'$2'"
+ elif [[ "$3" = "before" ]]; then
+ # shellcheck disable=SC2086
+ eval $1="'$2:${!1}'"
+ else
+ # shellcheck disable=SC2086
+ eval $1+="'$2'"
+ fi
+ fi
+}
+
+function hadoop_add_javalibpath
+{
+ # specialized function for a common use case
+ hadoop_add_colonpath JAVA_LIBRARY_PATH "$1" "$2"
+}
+
+function hadoop_add_ldlibpath
+{
+ # specialized function for a common use case
+ hadoop_add_colonpath LD_LIBRARY_PATH "$1" "$2"
+
+ # note that we export this
+ export LD_LIBRARY_PATH
+}
+
+function hadoop_add_to_classpath_common
+{
+
+ #
+ # get all of the common jars+config in the path
+ #
+
+ # developers
+ if [[ -n "${HADOOP_ENABLE_BUILD_PATHS}" ]]; then
+ hadoop_add_classpath "${HADOOP_COMMON_HOME}/hadoop-common/target/classes"
+ fi
+
+ if [[ -d "${HADOOP_COMMON_HOME}/${HADOOP_COMMON_DIR}/webapps" ]]; then
+ hadoop_add_classpath "${HADOOP_COMMON_HOME}/${HADOOP_COMMON_DIR}"
+ fi
+
+ hadoop_add_classpath "${HADOOP_COMMON_HOME}/${HADOOP_COMMON_LIB_JARS_DIR}"'/*'
+ hadoop_add_classpath "${HADOOP_COMMON_HOME}/${HADOOP_COMMON_DIR}"'/*'
+}
+
+function hadoop_add_to_classpath_hdfs
+{
+ #
+ # get all of the hdfs jars+config in the path
+ #
+ # developers
+ if [[ -n "${HADOOP_ENABLE_BUILD_PATHS}" ]]; then
+ hadoop_add_classpath "${HADOOP_HDFS_HOME}/hadoop-hdfs/target/classes"
+ fi
+
+ # put hdfs in classpath if present
+ if [[ -d "${HADOOP_HDFS_HOME}/${HDFS_DIR}/webapps" ]]; then
+ hadoop_add_classpath "${HADOOP_HDFS_HOME}/${HDFS_DIR}"
+ fi
+
+ hadoop_add_classpath "${HADOOP_HDFS_HOME}/${HDFS_LIB_JARS_DIR}"'/*'
+ hadoop_add_classpath "${HADOOP_HDFS_HOME}/${HDFS_DIR}"'/*'
+}
+
+function hadoop_add_to_classpath_yarn
+{
+ #
+ # get all of the yarn jars+config in the path
+ #
+ # developers
+ if [[ -n "${HADOOP_ENABLE_BUILD_PATHS}" ]]; then
+ for i in yarn-api yarn-common yarn-mapreduce yarn-master-worker \
+ yarn-server/yarn-server-nodemanager \
+ yarn-server/yarn-server-common \
+ yarn-server/yarn-server-resourcemanager; do
+ hadoop_add_classpath "${HADOOP_YARN_HOME}/$i/target/classes"
+ done
+
+ hadoop_add_classpath "${HADOOP_YARN_HOME}/build/test/classes"
+ hadoop_add_classpath "${HADOOP_YARN_HOME}/build/tools"
+ fi
+
+ if [[ -d "${HADOOP_YARN_HOME}/${YARN_DIR}/webapps" ]]; then
+ hadoop_add_classpath "${HADOOP_YARN_HOME}/${YARN_DIR}"
+ fi
+
+ hadoop_add_classpath "${HADOOP_YARN_HOME}/${YARN_LIB_JARS_DIR}"'/*'
+ hadoop_add_classpath "${HADOOP_YARN_HOME}/${YARN_DIR}"'/*'
+}
+
+function hadoop_add_to_classpath_mapred
+{
+ #
+ # get all of the mapreduce jars+config in the path
+ #
+ # developers
+ if [[ -n "${HADOOP_ENABLE_BUILD_PATHS}" ]]; then
+ hadoop_add_classpath "${HADOOP_MAPRED_HOME}/hadoop-mapreduce-client-shuffle/target/classes"
+ hadoop_add_classpath "${HADOOP_MAPRED_HOME}/hadoop-mapreduce-client-common/target/classes"
+ hadoop_add_classpath "${HADOOP_MAPRED_HOME}/hadoop-mapreduce-client-hs/target/classes"
+ hadoop_add_classpath "${HADOOP_MAPRED_HOME}/hadoop-mapreduce-client-hs-plugins/target/classes"
+ hadoop_add_classpath "${HADOOP_MAPRED_HOME}/hadoop-mapreduce-client-app/target/classes"
+ hadoop_add_classpath "${HADOOP_MAPRED_HOME}/hadoop-mapreduce-client-jobclient/target/classes"
+ hadoop_add_classpath "${HADOOP_MAPRED_HOME}/hadoop-mapreduce-client-core/target/classes"
+ fi
+
+ if [[ -d "${HADOOP_MAPRED_HOME}/${MAPRED_DIR}/webapps" ]]; then
+ hadoop_add_classpath "${HADOOP_MAPRED_HOME}/${MAPRED_DIR}"
+ fi
+
+ hadoop_add_classpath "${HADOOP_MAPRED_HOME}/${MAPRED_LIB_JARS_DIR}"'/*'
+ hadoop_add_classpath "${HADOOP_MAPRED_HOME}/${MAPRED_DIR}"'/*'
+}
+
+
+function hadoop_add_to_classpath_userpath
+{
+ # Add the user-specified HADOOP_CLASSPATH to the
+ # official CLASSPATH env var.
+ # Add it first or last depending on if user has
+ # set env-var HADOOP_USER_CLASSPATH_FIRST
+ # we'll also dedupe it, because we're cool like that.
+ #
+ local c
+ local array
+ local i
+ local j
+ let c=0
+
+ if [[ -n "${HADOOP_CLASSPATH}" ]]; then
+ # I wonder if Java runs on VMS.
+ for i in $(echo "${HADOOP_CLASSPATH}" | tr : '\n'); do
+ array[$c]=$i
+ let c+=1
+ done
+ let j=c-1
+
+ if [[ -z "${HADOOP_USER_CLASSPATH_FIRST}" ]]; then
+ for ((i=j; i>=0; i--)); do
+ hadoop_add_classpath "${array[$i]}" before
+ done
+ else
+ for ((i=0; i<=j; i++)); do
+ hadoop_add_classpath "${array[$i]}" after
+ done
+ fi
+ fi
+}
+
+function hadoop_os_tricks
+{
+ local bindv6only
+
+ # some OSes have special needs. here's some out of the box
+ # examples for OS X and Linux. Vendors, replace this with your special sauce.
+ case ${HADOOP_OS_TYPE} in
+ Darwin)
+ if [[ -x /usr/libexec/java_home ]]; then
+ export JAVA_HOME="$(/usr/libexec/java_home)"
+ else
+ export JAVA_HOME=/Library/Java/Home
+ fi
+ ;;
+ Linux)
+ bindv6only=$(/sbin/sysctl -n net.ipv6.bindv6only 2> /dev/null)
+
+ # NOTE! HADOOP_ALLOW_IPV6 is a developer hook. We leave it
+ # undocumented in hadoop-env.sh because we don't want users to
+ # shoot themselves in the foot while devs make IPv6 work.
+ if [[ -n "${bindv6only}" ]] &&
+ [[ "${bindv6only}" -eq "1" ]] &&
+ [[ "${HADOOP_ALLOW_IPV6}" != "yes" ]]; then
+ hadoop_error "ERROR: \"net.ipv6.bindv6only\" is set to 1 "
+ hadoop_error "ERROR: Hadoop networking could be broken. Aborting."
+ hadoop_error "ERROR: For more info: http://wiki.apache.org/hadoop/HadoopIPv6"
+ exit 1
+ fi
+ # Newer versions of glibc use an arena memory allocator that
+ # causes virtual # memory usage to explode. This interacts badly
+ # with the many threads that we use in Hadoop. Tune the variable
+ # down to prevent vmem explosion.
+ export MALLOC_ARENA_MAX=${MALLOC_ARENA_MAX:-4}
+ ;;
+ esac
+}
+
+function hadoop_java_setup
+{
+ # Bail if we did not detect it
+ if [[ -z "${JAVA_HOME}" ]]; then
+ hadoop_error "ERROR: JAVA_HOME is not set and could not be found."
+ exit 1
+ fi
+
+ if [[ ! -d "${JAVA_HOME}" ]]; then
+ hadoop_error "ERROR: JAVA_HOME ${JAVA_HOME} does not exist."
+ exit 1
+ fi
+
+ JAVA="${JAVA_HOME}/bin/java"
+
+ if [[ ! -x "$JAVA" ]]; then
+ hadoop_error "ERROR: $JAVA is not executable."
+ exit 1
+ fi
+ # shellcheck disable=SC2034
+ JAVA_HEAP_MAX=-Xmx1g
+ HADOOP_HEAPSIZE=${HADOOP_HEAPSIZE:-1024}
+
+ # check envvars which might override default args
+ if [[ -n "$HADOOP_HEAPSIZE" ]]; then
+ # shellcheck disable=SC2034
+ JAVA_HEAP_MAX="-Xmx${HADOOP_HEAPSIZE}m"
+ fi
+}
+
+
+function hadoop_finalize_libpaths
+{
+ if [[ -n "${JAVA_LIBRARY_PATH}" ]]; then
+ hadoop_add_param HADOOP_OPTS java.library.path \
+ "-Djava.library.path=${JAVA_LIBRARY_PATH}"
+ export LD_LIBRARY_PATH
+ fi
+}
+
+#
+# fill in any last minute options that might not have been defined yet
+#
+# Note that we are replacing ' ' with '\ ' so that directories with
+# spaces work correctly when run exec blah
+#
+function hadoop_finalize_hadoop_opts
+{
+ hadoop_add_param HADOOP_OPTS hadoop.log.dir "-Dhadoop.log.dir=${HADOOP_LOG_DIR/ /\ }"
+ hadoop_add_param HADOOP_OPTS hadoop.log.file "-Dhadoop.log.file=${HADOOP_LOGFILE/ /\ }"
+ hadoop_add_param HADOOP_OPTS hadoop.home.dir "-Dhadoop.home.dir=${HADOOP_PREFIX/ /\ }"
+ hadoop_add_param HADOOP_OPTS hadoop.id.str "-Dhadoop.id.str=${HADOOP_IDENT_STRING/ /\ }"
+ hadoop_add_param HADOOP_OPTS hadoop.root.logger "-Dhadoop.root.logger=${HADOOP_ROOT_LOGGER}"
+ hadoop_add_param HADOOP_OPTS hadoop.policy.file "-Dhadoop.policy.file=${HADOOP_POLICYFILE/ /\ }"
+ hadoop_add_param HADOOP_OPTS hadoop.security.logger "-Dhadoop.security.logger=${HADOOP_SECURITY_LOGGER}"
+}
+
+function hadoop_finalize_classpath
+{
+
+ # we want the HADOOP_CONF_DIR at the end
+ # according to oom, it gives a 2% perf boost
+ hadoop_add_classpath "${HADOOP_CONF_DIR}" after
+
+ # user classpath gets added at the last minute. this allows
+ # override of CONF dirs and more
+ hadoop_add_to_classpath_userpath
+}
+
+function hadoop_finalize
+{
+ # user classpath gets added at the last minute. this allows
+ # override of CONF dirs and more
+ hadoop_finalize_classpath
+ hadoop_finalize_libpaths
+ hadoop_finalize_hadoop_opts
+}
+
+function hadoop_exit_with_usage
+{
+ # NOTE: This function is not user replaceable.
+
+ local exitcode=$1
+ if [[ -z $exitcode ]]; then
+ exitcode=1
+ fi
+ if declare -F hadoop_usage >/dev/null ; then
+ hadoop_usage
+ elif [[ -x /usr/bin/cowsay ]]; then
+ /usr/bin/cowsay -f elephant "Sorry, no help available."
+ else
+ hadoop_error "Sorry, no help available."
+ fi
+ exit $exitcode
+}
+
+function hadoop_verify_secure_prereq
+{
+ # if you are on an OS like Illumos that has functional roles
+ # and you are using pfexec, you'll probably want to change
+ # this.
+
+ # ${EUID} comes from the shell itself!
+ if [[ "${EUID}" -ne 0 ]] || [[ -n "${HADOOP_SECURE_COMMAND}" ]]; then
+ hadoop_error "ERROR: You must be a privileged in order to run a secure serice."
+ return 1
+ else
+ return 0
+ fi
+}
+
+function hadoop_setup_secure_service
+{
+ # need a more complicated setup? replace me!
+
+ HADOOP_PID_DIR=${HADOOP_SECURE_PID_DIR}
+ HADOOP_LOG_DIR=${HADOOP_SECURE_LOG_DIR}
+}
+
+function hadoop_verify_piddir
+{
+ if [[ -z "${HADOOP_PID_DIR}" ]]; then
+ hadoop_error "No pid directory defined."
+ exit 1
+ fi
+ if [[ ! -w "${HADOOP_PID_DIR}" ]] && [[ ! -d "${HADOOP_PID_DIR}" ]]; then
+ hadoop_error "WARNING: ${HADOOP_PID_DIR} does not exist. Creating."
+ mkdir -p "${HADOOP_PID_DIR}" > /dev/null 2>&1
+ if [[ $? -gt 0 ]]; then
+ hadoop_error "ERROR: Unable to create ${HADOOP_PID_DIR}. Aborting."
+ exit 1
+ fi
+ fi
+ touch "${HADOOP_PID_DIR}/$$" >/dev/null 2>&1
+ if [[ $? -gt 0 ]]; then
+ hadoop_error "ERROR: Unable to write in ${HADOOP_PID_DIR}. Aborting."
+ exit 1
+ fi
+ rm "${HADOOP_PID_DIR}/$$" >/dev/null 2>&1
+}
+
+function hadoop_verify_logdir
+{
+ if [[ -z "${HADOOP_LOG_DIR}" ]]; then
+ hadoop_error "No log directory defined."
+ exit 1
+ fi
+ if [[ ! -w "${HADOOP_LOG_DIR}" ]] && [[ ! -d "${HADOOP_LOG_DIR}" ]]; then
+ hadoop_error "WARNING: ${HADOOP_LOG_DIR} does not exist. Creating."
+ mkdir -p "${HADOOP_LOG_DIR}" > /dev/null 2>&1
+ if [[ $? -gt 0 ]]; then
+ hadoop_error "ERROR: Unable to create ${HADOOP_LOG_DIR}. Aborting."
+ exit 1
+ fi
+ fi
+ touch "${HADOOP_LOG_DIR}/$$" >/dev/null 2>&1
+ if [[ $? -gt 0 ]]; then
+ hadoop_error "ERROR: Unable to write in ${HADOOP_LOG_DIR}. Aborting."
+ exit 1
+ fi
+ rm "${HADOOP_LOG_DIR}/$$" >/dev/null 2>&1
+}
+
+function hadoop_status_daemon() {
+ #
+ # LSB 4.1.0 compatible status command (1)
+ #
+ # 0 = program is running
+ # 1 = dead, but still a pid (2)
+ # 2 = (not used by us)
+ # 3 = not running
+ #
+ # 1 - this is not an endorsement of the LSB
+ #
+ # 2 - technically, the specification says /var/run/pid, so
+ # we should never return this value, but we're giving
+ # them the benefit of a doubt and returning 1 even if
+ # our pid is not in in /var/run .
+ #
+
+ local pidfile=$1
+ shift
+
+ local pid
+
+ if [[ -f "${pidfile}" ]]; then
+ pid=$(cat "${pidfile}")
+ if ps -p "${pid}" > /dev/null 2>&1; then
+ return 0
+ fi
+ return 1
+ fi
+ return 3
+}
+
+function hadoop_java_exec
+{
+ # run a java command. this is used for
+ # non-daemons
+
+ local command=$1
+ local class=$2
+ shift 2
+ # we eval this so that paths with spaces work
+ #shellcheck disable=SC2086
+ eval exec "$JAVA" "-Dproc_${command}" ${HADOOP_OPTS} "${class}" "$@"
+
+}
+
+function hadoop_start_daemon
+{
+ # this is our non-privileged daemon starter
+ # that fires up a daemon in the *foreground*
+ # so complex! so wow! much java!
+ local command=$1
+ local class=$2
+ shift 2
+ #shellcheck disable=SC2086
+ eval exec "$JAVA" "-Dproc_${command}" ${HADOOP_OPTS} "${class}" "$@"
+}
+
+function hadoop_start_daemon_wrapper
+{
+ # this is our non-privileged daemon start
+ # that fires up a daemon in the *background*
+ local daemonname=$1
+ local class=$2
+ local pidfile=$3
+ local outfile=$4
+ shift 4
+
+ hadoop_rotate_log "${outfile}"
+
+ hadoop_start_daemon "${daemonname}" \
+ "$class" "$@" >> "${outfile}" 2>&1 < /dev/null &
+ #shellcheck disable=SC2086
+ echo $! > "${pidfile}" 2>/dev/null
+ if [[ $? -gt 0 ]]; then
+ hadoop_error "ERROR: Cannot write pid ${pidfile}."
+ fi
+
+ # shellcheck disable=SC2086
+ renice "${HADOOP_NICENESS}" $! >/dev/null 2>&1
+ if [[ $? -gt 0 ]]; then
+ hadoop_error "ERROR: Cannot set priority of process $!"
+ fi
+
+ # shellcheck disable=SC2086
+ disown $! 2>&1
+ if [[ $? -gt 0 ]]; then
+ hadoop_error "ERROR: Cannot disconnect process $!"
+ fi
+ sleep 1
+
+ # capture the ulimit output
+ ulimit -a >> "${outfile}" 2>&1
+
+ # shellcheck disable=SC2086
+ if ! ps -p $! >/dev/null 2>&1; then
+ return 1
+ fi
+ return 0
+}
+
+function hadoop_start_secure_daemon
+{
+ # this is used to launch a secure daemon in the *foreground*
+ #
+ local daemonname=$1
+ local class=$2
+
+ # pid file to create for our deamon
+ local daemonpidfile=$3
+
+ # where to send stdout. jsvc has bad habits so this *may* be &1
+ # which means you send it to stdout!
+ local daemonoutfile=$4
+
+ # where to send stderr. same thing, except &2 = stderr
+ local daemonerrfile=$5
+ shift 5
+
+
+
+ hadoop_rotate_log "${daemonoutfile}"
+ hadoop_rotate_log "${daemonerrfile}"
+
+ jsvc="${JSVC_HOME}/jsvc"
+ if [[ ! -f "${jsvc}" ]]; then
+ hadoop_error "JSVC_HOME is not set or set incorrectly. jsvc is required to run secure"
+ hadoop_error "or privileged daemons. Please download and install jsvc from "
+ hadoop_error "http://archive.apache.org/dist/commons/daemon/binaries/ "
+ hadoop_error "and set JSVC_HOME to the directory containing the jsvc binary."
+ exit 1
+ fi
+
+ # note that shellcheck will throw a
+ # bogus for-our-use-case 2086 here.
+ # it doesn't properly support multi-line situations
+
+ exec "${jsvc}" \
+ "-Dproc_${daemonname}" \
+ -outfile "${daemonoutfile}" \
+ -errfile "${daemonerrfile}" \
+ -pidfile "${daemonpidfile}" \
+ -nodetach \
+ -user "${HADOOP_SECURE_USER}" \
+ -cp "${CLASSPATH}" \
+ ${HADOOP_OPTS} \
+ "${class}" "$@"
+}
+
+function hadoop_start_secure_daemon_wrapper
+{
+ # this wraps hadoop_start_secure_daemon to take care
+ # of the dirty work to launch a daemon in the background!
+ local daemonname=$1
+ local class=$2
+
+ # same rules as hadoop_start_secure_daemon except we
+ # have some additional parameters
+
+ local daemonpidfile=$3
+
+ local daemonoutfile=$4
+
+ # the pid file of the subprocess that spawned our
+ # secure launcher
+ local jsvcpidfile=$5
+
+ # the output of the subprocess that spawned our secure
+ # launcher
+ local jsvcoutfile=$6
+
+ local daemonerrfile=$7
+ shift 7
+
+ hadoop_rotate_log "${jsvcoutfile}"
+
+ hadoop_start_secure_daemon \
+ "${daemonname}" \
+ "${class}" \
+ "${daemonpidfile}" \
+ "${daemonoutfile}" \
+ "${daemonerrfile}" "$@" >> "${jsvcoutfile}" 2>&1 < /dev/null &
+
+ # This wrapper should only have one child. Unlike Shawty Lo.
+ #shellcheck disable=SC2086
+ echo $! > "${jsvcpidfile}" 2>/dev/null
+ if [[ $? -gt 0 ]]; then
+ hadoop_error "ERROR: Cannot write pid ${pidfile}."
+ fi
+ sleep 1
+ #shellcheck disable=SC2086
+ renice "${HADOOP_NICENESS}" $! >/dev/null 2>&1
+ if [[ $? -gt 0 ]]; then
+ hadoop_error "ERROR: Cannot set priority of process $!"
+ fi
+ if [[ -f "${daemonpidfile}" ]]; then
+ #shellcheck disable=SC2046
+ renice "${HADOOP_NICENESS}" $(cat "${daemonpidfile}") >/dev/null 2>&1
+ if [[ $? -gt 0 ]]; then
+ hadoop_error "ERROR: Cannot set priority of process $(cat "${daemonpidfile}")"
+ fi
+ fi
+ #shellcheck disable=SC2086
+ disown $! 2>&1
+ if [[ $? -gt 0 ]]; then
+ hadoop_error "ERROR: Cannot disconnect process $!"
+ fi
+ # capture the ulimit output
+ su "${HADOOP_SECURE_USER}" -c 'bash -c "ulimit -a"' >> "${jsvcoutfile}" 2>&1
+ #shellcheck disable=SC2086
+ if ! ps -p $! >/dev/null 2>&1; then
+ return 1
+ fi
+ return 0
+}
+
+function hadoop_stop_daemon
+{
+ local cmd=$1
+ local pidfile=$2
+ shift 2
+
+ local pid
+
+ if [[ -f "${pidfile}" ]]; then
+ pid=$(cat "$pidfile")
+
+ kill "${pid}" >/dev/null 2>&1
+ sleep "${HADOOP_STOP_TIMEOUT}"
+ if kill -0 "${pid}" > /dev/null 2>&1; then
+ hadoop_error "WARNING: ${cmd} did not stop gracefully after ${HADOOP_STOP_TIMEOUT} seconds: Trying to kill with kill -9"
+ kill -9 "${pid}" >/dev/null 2>&1
+ fi
+ if ps -p "${pid}" > /dev/null 2>&1; then
+ hadoop_error "ERROR: Unable to kill ${pid}"
+ else
+ rm -f "${pidfile}" >/dev/null 2>&1
+ fi
+ fi
+}
+
+
+function hadoop_stop_secure_daemon
+{
+ local command=$1
+ local daemonpidfile=$2
+ local privpidfile=$3
+ shift 3
+ local ret
+
+ hadoop_stop_daemon "${command}" "${daemonpidfile}"
+ ret=$?
+ rm -f "${daemonpidfile}" "${privpidfile}" 2>/dev/null
+ return ${ret}
+}
+
+function hadoop_daemon_handler
+{
+ local daemonmode=$1
+ local daemonname=$2
+ local class=$3
+ local pidfile=$4
+ local outfile=$5
+ shift 5
+
+ case ${daemonmode} in
+ status)
+ hadoop_status_daemon "${daemon_pidfile}"
+ exit $?
+ ;;
+
+ stop)
+ hadoop_stop_daemon "${daemonname}" "${daemon_pidfile}"
+ exit $?
+ ;;
+
+ ##COMPAT -- older hadoops would also start daemons by default
+ start|default)
+ hadoop_verify_piddir
+ hadoop_verify_logdir
+ hadoop_status_daemon "${daemon_pidfile}"
+ if [[ $? == 0 ]]; then
+ hadoop_error "${daemonname} running as process $(cat "${daemon_pidfile}"). Stop it first."
+ exit 1
+ else
+ # stale pid file, so just remove it and continue on
+ rm -f "${daemon_pidfile}" >/dev/null 2>&1
+ fi
+ ##COMPAT - differenticate between --daemon start and nothing
+ # "nothing" shouldn't detach
+ if [[ "$daemonmode" = "default" ]]; then
+ hadoop_start_daemon "${daemonname}" "${class}" "$@"
+ else
+ hadoop_start_daemon_wrapper "${daemonname}" \
+ "${class}" "${daemon_pidfile}" "${daemon_outfile}" "$@"
+ fi
+ ;;
+ esac
+}
+
+
+function hadoop_secure_daemon_handler
+{
+ local daemonmode=$1
+ local daemonname=$2
+ local classname=$3
+ local daemon_pidfile=$4
+ local daemon_outfile=$5
+ local priv_pidfile=$6
+ local priv_outfile=$7
+ local priv_errfile=$8
+ shift 8
+
+ case ${daemonmode} in
+ status)
+ hadoop_status_daemon "${daemon_pidfile}"
+ exit $?
+ ;;
+
+ stop)
+ hadoop_stop_secure_daemon "${daemonname}" \
+ "${daemon_pidfile}" "${priv_pidfile}"
+ exit $?
+ ;;
+
+ ##COMPAT -- older hadoops would also start daemons by default
+ start|default)
+ hadoop_verify_piddir
+ hadoop_verify_logdir
+ hadoop_status_daemon "${daemon_pidfile}"
+ if [[ $? == 0 ]]; then
+ hadoop_error "${daemonname} running as process $(cat "${daemon_pidfile}"). Stop it first."
+ exit 1
+ else
+ # stale pid file, so just remove it and continue on
+ rm -f "${daemon_pidfile}" >/dev/null 2>&1
+ fi
+
+ ##COMPAT - differenticate between --daemon start and nothing
+ # "nothing" shouldn't detach
+ if [[ "${daemonmode}" = "default" ]]; then
+ hadoop_start_secure_daemon "${daemonname}" "${classname}" \
+ "${daemon_pidfile}" "${daemon_outfile}" \
+ "${priv_errfile}" "$@"
+ else
+ hadoop_start_secure_daemon_wrapper "${daemonname}" "${classname}" \
+ "${daemon_pidfile}" "${daemon_outfile}" \
+ "${priv_pidfile}" "${priv_outfile}" "${priv_errfile}" "$@"
+ fi
+ ;;
+ esac
+}
+
Added: hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/bin/hadoop-layout.sh.example
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/bin/hadoop-layout.sh.example?rev=1618847&view=auto
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/bin/hadoop-layout.sh.example (added)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/bin/hadoop-layout.sh.example Tue Aug 19 12:11:17 2014
@@ -0,0 +1,93 @@
+# Copyright 2014 The Apache Software Foundation
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+##
+## VENDORS!
+##
+## This is where you can redefine the layout of Hadoop directories
+## and expect to be reasonably compatible. Needless to say, this
+## is expert level stuff and one needs to tread carefully.
+##
+## If you move HADOOP_LIBEXEC_DIR from some location that
+## isn't bin/../libexec, you MUST define either HADOOP_LIBEXEC_DIR
+## or have HADOOP_PREFIX/libexec/hadoop-config.sh and
+## HADOOP_PREFIX/libexec/hadoop-layout.sh (this file) exist.
+
+## NOTE:
+##
+## hadoop-functions.sh gets executed BEFORE this file. So you can
+## redefine all of those functions here.
+##
+## *-env.sh get executed AFTER this file but generally too late to
+## override the settings (but not the functions!) here. However, this
+## also means you cannot use things like HADOOP_CONF_DIR for these
+## definitions.
+
+####
+# Common disk layout
+####
+
+# Default location for the common/core Hadoop project
+# export HADOOP_COMMON_HOME=$HADOOP_PREFIX
+
+# Relative locations where components under HADOOP_COMMON_HOME are located
+# export HADOOP_COMMON_DIR="share/hadoop/common"
+# export HADOOP_COMMON_LIB_JARS_DIR="share/hadoop/common/lib"
+# export HADOOP_COMMON_LIB_NATIVE_DIR="lib/native"
+
+####
+# HDFS disk layout
+####
+
+# Default location for the HDFS subproject
+# export HADOOP_HDFS_HOME=$HADOOP_PREFIX
+
+# Relative locations where components under HADOOP_HDFS_HOME are located
+# export HDFS_DIR="share/hadoop/hdfs"
+# export HDFS_LIB_JARS_DIR="share/hadoop/hdfs/lib"
+
+####
+# YARN disk layout
+####
+
+# Default location for the YARN subproject
+# export HADOOP_YARN_HOME=$HADOOP_PREFIX
+
+# Relative locations where components under HADOOP_YARN_HOME are located
+# export YARN_DIR="share/hadoop/yarn"
+# export YARN_LIB_JARS_DIR="share/hadoop/yarn/lib"
+
+# Default location for the MapReduce subproject
+# export HADOOP_MAPRED_HOME=$HADOOP_PREFIX
+
+####
+# MapReduce disk layout
+####
+
+# Relative locations where components under HADOOP_MAPRED_HOME are located
+# export MAPRED_DIR="share/hadoop/mapreduce"
+# export MAPRED_LIB_JARS_DIR="share/hadoop/mapreduce/lib"
+
+####
+# Misc paths
+####
+
+# setup a default TOOL_PATH, where things like distcp lives
+# note that this path only gets added for certain commands and not
+# part of the general classpath
+# export TOOL_PATH="$HADOOP_PREFIX/share/hadoop/tools/lib/*"
Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/bin/rcc
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/bin/rcc?rev=1618847&r1=1618846&r2=1618847&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/bin/rcc (original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/bin/rcc Tue Aug 19 12:11:17 2014
@@ -15,47 +15,28 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-
-# The Hadoop record compiler
-#
-# Environment Variables
-#
-# JAVA_HOME The java implementation to use. Overrides JAVA_HOME.
-#
-# HADOOP_OPTS Extra Java runtime options.
-#
-# HADOOP_CONF_DIR Alternate conf dir. Default is ${HADOOP_PREFIX}/conf.
-#
-
-bin=`dirname "${BASH_SOURCE-$0}"`
-bin=`cd "$bin"; pwd`
+# This script runs the hadoop core commands.
+this="${BASH_SOURCE-$0}"
+bin=$(cd -P -- "$(dirname -- "$this")" >/dev/null && pwd -P)
+script="$(basename -- "$this")"
+this="$bin/$script"
DEFAULT_LIBEXEC_DIR="$bin"/../libexec
HADOOP_LIBEXEC_DIR=${HADOOP_LIBEXEC_DIR:-$DEFAULT_LIBEXEC_DIR}
-. $HADOOP_LIBEXEC_DIR/hadoop-config.sh
+HADOOP_NEW_CONFIG=true
+. "$HADOOP_LIBEXEC_DIR/hadoop-config.sh"
-if [ -f "${HADOOP_CONF_DIR}/hadoop-env.sh" ]; then
- . "${HADOOP_CONF_DIR}/hadoop-env.sh"
+if [ $# = 0 ]; then
+ hadoop_exit_with_usage 1
fi
-# some Java parameters
-if [ "$JAVA_HOME" != "" ]; then
- #echo "run java in $JAVA_HOME"
- JAVA_HOME=$JAVA_HOME
-fi
-
-if [ "$JAVA_HOME" = "" ]; then
- echo "Error: JAVA_HOME is not set."
- exit 1
-fi
-
-JAVA=$JAVA_HOME/bin/java
-JAVA_HEAP_MAX=-Xmx1000m
+CLASS='org.apache.hadoop.record.compiler.generated.Rcc'
-# restore ordinary behaviour
-unset IFS
+# Always respect HADOOP_OPTS and HADOOP_CLIENT_OPTS
+HADOOP_OPTS="$HADOOP_OPTS $HADOOP_CLIENT_OPTS"
-CLASS='org.apache.hadoop.record.compiler.generated.Rcc'
+hadoop_add_param HADOOP_OPTS Xmx "$JAVA_HEAP_MAX"
-# run it
-exec "$JAVA" $HADOOP_OPTS -classpath "$CLASSPATH" $CLASS "$@"
+hadoop_finalize
+export CLASSPATH
+hadoop_java_exec rcc "${CLASS}" "$@"
Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/bin/slaves.sh
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/bin/slaves.sh?rev=1618847&r1=1618846&r2=1618847&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/bin/slaves.sh (original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/bin/slaves.sh Tue Aug 19 12:11:17 2014
@@ -27,38 +27,33 @@
# HADOOP_SSH_OPTS Options passed to ssh when running remote commands.
##
-usage="Usage: slaves.sh [--config confdir] command..."
+function hadoop_usage {
+ echo "Usage: slaves.sh [--config confdir] command..."
+}
+
+# let's locate libexec...
+if [[ -n "${HADOOP_PREFIX}" ]]; then
+ DEFAULT_LIBEXEC_DIR="${HADOOP_PREFIX}/libexec"
+else
+ this="${BASH_SOURCE-$0}"
+ bin=$(cd -P -- "$(dirname -- "${this}")" >dev/null && pwd -P)
+ DEFAULT_LIBEXEC_DIR="${bin}/../libexec"
+fi
-# if no args specified, show usage
-if [ $# -le 0 ]; then
- echo $usage
+HADOOP_LIBEXEC_DIR="${HADOOP_LIBEXEC_DIR:-$DEFAULT_LIBEXEC_DIR}"
+# shellcheck disable=SC2034
+HADOOP_NEW_CONFIG=true
+if [[ -f "${HADOOP_LIBEXEC_DIR}/hadoop-config.sh" ]]; then
+ . "${HADOOP_LIBEXEC_DIR}/hadoop-config.sh"
+else
+ echo "ERROR: Cannot execute ${HADOOP_LIBEXEC_DIR}/hadoop-config.sh." 2>&1
exit 1
fi
-bin=`dirname "${BASH_SOURCE-$0}"`
-bin=`cd "$bin"; pwd`
-
-DEFAULT_LIBEXEC_DIR="$bin"/../libexec
-HADOOP_LIBEXEC_DIR=${HADOOP_LIBEXEC_DIR:-$DEFAULT_LIBEXEC_DIR}
-. $HADOOP_LIBEXEC_DIR/hadoop-config.sh
-
-
-# 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')
+# if no args specified, show usage
+if [[ $# -le 0 ]]; then
+ hadoop_exit_with_usage 1
fi
-# start the daemons
-for slave in $SLAVE_NAMES ; do
- ssh $HADOOP_SSH_OPTS $slave $"${@// /\\ }" \
- 2>&1 | sed "s/^/$slave: /" &
- if [ "$HADOOP_SLAVE_SLEEP" != "" ]; then
- sleep $HADOOP_SLAVE_SLEEP
- fi
-done
+hadoop_connect_to_hosts "$@"
-wait
Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/bin/start-all.sh
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/bin/start-all.sh?rev=1618847&r1=1618846&r2=1618847&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/bin/start-all.sh (original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/bin/start-all.sh Tue Aug 19 12:11:17 2014
@@ -15,24 +15,38 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+echo "This script is deprecated. Use start-dfs.sh and start-yarn.sh instead."
+exit 1
-# Start all hadoop daemons. Run this on master node.
-echo "This script is Deprecated. Instead use start-dfs.sh and start-yarn.sh"
-bin=`dirname "${BASH_SOURCE-$0}"`
-bin=`cd "$bin"; pwd`
-
-DEFAULT_LIBEXEC_DIR="$bin"/../libexec
-HADOOP_LIBEXEC_DIR=${HADOOP_LIBEXEC_DIR:-$DEFAULT_LIBEXEC_DIR}
-. $HADOOP_LIBEXEC_DIR/hadoop-config.sh
+# let's locate libexec...
+if [[ -n "${HADOOP_PREFIX}" ]]; then
+ DEFAULT_LIBEXEC_DIR="${HADOOP_PREFIX}/libexec"
+else
+ this="${BASH_SOURCE-$0}"
+ bin=$(cd -P -- "$(dirname -- "${this}")" >/dev/null && pwd -P)
+ DEFAULT_LIBEXEC_DIR="${bin}/../libexec"
+fi
+HADOOP_LIBEXEC_DIR="${HADOOP_LIBEXEC_DIR:-$DEFAULT_LIBEXEC_DIR}"
+# shellcheck disable=SC2034
+HADOOP_NEW_CONFIG=true
+if [[ -f "${HADOOP_LIBEXEC_DIR}/hadoop-config.sh" ]]; then
+ . "${HADOOP_LIBEXEC_DIR}/hadoop-config.sh"
+else
+ echo "ERROR: Cannot execute ${HADOOP_LIBEXEC_DIR}/hadoop-config.sh." 2>&1
+ exit 1
+fi
# start hdfs daemons if hdfs is present
-if [ -f "${HADOOP_HDFS_HOME}"/sbin/start-dfs.sh ]; then
- "${HADOOP_HDFS_HOME}"/sbin/start-dfs.sh --config $HADOOP_CONF_DIR
+if [[ -f "${HADOOP_HDFS_HOME}/sbin/start-dfs.sh" ]]; then
+ "${HADOOP_HDFS_HOME}/sbin/start-dfs.sh" --config "${HADOOP_CONF_DIR}"
fi
# start yarn daemons if yarn is present
-if [ -f "${HADOOP_YARN_HOME}"/sbin/start-yarn.sh ]; then
- "${HADOOP_YARN_HOME}"/sbin/start-yarn.sh --config $HADOOP_CONF_DIR
+if [[ -f "${HADOOP_YARN_HOME}/sbin/start-yarn.sh" ]]; then
+ "${HADOOP_YARN_HOME}/sbin/start-yarn.sh" --config "${HADOOP_CONF_DIR}"
fi
+
+
+
Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/bin/stop-all.sh
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/bin/stop-all.sh?rev=1618847&r1=1618846&r2=1618847&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/bin/stop-all.sh (original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/bin/stop-all.sh Tue Aug 19 12:11:17 2014
@@ -18,21 +18,35 @@
# Stop all hadoop daemons. Run this on master node.
-echo "This script is Deprecated. Instead use stop-dfs.sh and stop-yarn.sh"
+echo "This script is deprecated. Use stop-dfs.sh and stop-yarn.sh instead."
+exit 1
-bin=`dirname "${BASH_SOURCE-$0}"`
-bin=`cd "$bin"; pwd`
+# let's locate libexec...
+if [[ -n "${HADOOP_PREFIX}" ]]; then
+ DEFAULT_LIBEXEC_DIR="${HADOOP_PREFIX}/libexec"
+else
+ this="${BASH_SOURCE-$0}"
+ bin=$(cd -P -- "$(dirname -- "${this}")" >dev/null && pwd -P)
+ DEFAULT_LIBEXEC_DIR="${bin}/../libexec"
+fi
-DEFAULT_LIBEXEC_DIR="$bin"/../libexec
-HADOOP_LIBEXEC_DIR=${HADOOP_LIBEXEC_DIR:-$DEFAULT_LIBEXEC_DIR}
-. $HADOOP_LIBEXEC_DIR/hadoop-config.sh
+HADOOP_LIBEXEC_DIR="${HADOOP_LIBEXEC_DIR:-$DEFAULT_LIBEXEC_DIR}"
+# shellcheck disable=SC2034
+HADOOP_NEW_CONFIG=true
+if [[ -f "${HADOOP_LIBEXEC_DIR}/hadoop-config.sh" ]]; then
+ . "${HADOOP_LIBEXEC_DIR}/hadoop-config.sh"
+else
+ echo "ERROR: Cannot execute ${HADOOP_LIBEXEC_DIR}/hadoop-config.sh." 2>&1
+ exit 1
+fi
# stop hdfs daemons if hdfs is present
-if [ -f "${HADOOP_HDFS_HOME}"/sbin/stop-dfs.sh ]; then
- "${HADOOP_HDFS_HOME}"/sbin/stop-dfs.sh --config $HADOOP_CONF_DIR
+if [[ -f "${HADOOP_HDFS_HOME}/sbin/stop-dfs.sh" ]]; then
+ "${HADOOP_HDFS_HOME}/sbin/stop-dfs.sh" --config "${HADOOP_CONF_DIR}"
fi
# stop yarn daemons if yarn is present
-if [ -f "${HADOOP_HDFS_HOME}"/sbin/stop-yarn.sh ]; then
- "${HADOOP_HDFS_HOME}"/sbin/stop-yarn.sh --config $HADOOP_CONF_DIR
+if [[ -f "${HADOOP_HDFS_HOME}/sbin/stop-yarn.sh" ]]; then
+ "${HADOOP_HDFS_HOME}/sbin/stop-yarn.sh" --config "${HADOOP_CONF_DIR}"
fi
+