MAPREDUCE-279. MapReduce 2.0. Merging MR-279 branch into trunk. Contributed by Arun C Murthy, Christopher Douglas, Devaraj Das, Greg Roelofs, Jeffrey Naisbitt, Josh Wills, Jonathan Eagles, Krishna Ramachandran, Luke Lu, Mahadev Konar, Robert Evans, Sharad Agarwal, Siddharth Seth, Thomas Graves, and Vinod Kumar Vavilapalli.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1159166 13f79535-47bb-0310-9956-ffa450edef68
2011-08-18 11:07:10 +00:00
|
|
|
#!/usr/bin/env 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.
|
|
|
|
|
2015-07-16 23:58:11 +00:00
|
|
|
MYNAME="${BASH_SOURCE-$0}"
|
2016-03-28 16:00:07 +00:00
|
|
|
HADOOP_SHELL_EXECNAME="${MYNAME##*/}"
|
2015-07-16 23:58:11 +00:00
|
|
|
|
2016-03-28 16:00:07 +00:00
|
|
|
## @description build up the yarn command's usage text.
|
|
|
|
## @audience public
|
|
|
|
## @stability stable
|
|
|
|
## @replaceable no
|
2014-08-19 12:11:17 +00:00
|
|
|
function hadoop_usage
|
|
|
|
{
|
2015-07-31 21:32:21 +00:00
|
|
|
hadoop_add_option "--buildpaths" "attempt to add class files from build tree"
|
|
|
|
hadoop_add_option "--daemon (start|status|stop)" "operate on a daemon"
|
2016-06-28 12:53:03 +00:00
|
|
|
hadoop_add_option "--hostnames list[,of,host,names]" "hosts to use in worker mode"
|
2015-07-31 21:32:21 +00:00
|
|
|
hadoop_add_option "--loglevel level" "set the log4j level for this command"
|
2016-06-28 12:53:03 +00:00
|
|
|
hadoop_add_option "--hosts filename" "list of hosts to use in worker mode"
|
|
|
|
hadoop_add_option "--workers" "turn on worker mode"
|
2015-07-31 21:32:21 +00:00
|
|
|
|
2017-10-29 06:04:19 +00:00
|
|
|
hadoop_add_subcommand "app|application" client "prints application(s) report/kill application/manage long running application"
|
2017-08-02 17:17:40 +00:00
|
|
|
hadoop_add_subcommand "applicationattempt" client "prints applicationattempt(s) report"
|
|
|
|
hadoop_add_subcommand "classpath" client "prints the class path needed to get the hadoop jar and the required libraries"
|
|
|
|
hadoop_add_subcommand "cluster" client "prints cluster information"
|
|
|
|
hadoop_add_subcommand "container" client "prints container(s) report"
|
|
|
|
hadoop_add_subcommand "daemonlog" admin "get/set the log level for each daemon"
|
|
|
|
hadoop_add_subcommand "envvars" client "display computed Hadoop environment variables"
|
|
|
|
hadoop_add_subcommand "jar <jar>" client "run a jar file"
|
|
|
|
hadoop_add_subcommand "logs" client "dump container logs"
|
|
|
|
hadoop_add_subcommand "node" admin "prints node report(s)"
|
|
|
|
hadoop_add_subcommand "nodemanager" daemon "run a nodemanager on each worker"
|
|
|
|
hadoop_add_subcommand "proxyserver" daemon "run the web app proxy server"
|
|
|
|
hadoop_add_subcommand "queue" client "prints queue information"
|
2017-10-13 17:49:38 +00:00
|
|
|
hadoop_add_subcommand "registrydns" daemon "run the registry DNS server"
|
2017-08-02 17:17:40 +00:00
|
|
|
hadoop_add_subcommand "resourcemanager" daemon "run the ResourceManager"
|
|
|
|
hadoop_add_subcommand "rmadmin" admin "admin tools"
|
|
|
|
hadoop_add_subcommand "router" daemon "run the Router daemon"
|
2017-09-26 00:52:40 +00:00
|
|
|
hadoop_add_subcommand "schedulerconf" client "Updates scheduler configuration"
|
2017-08-02 17:17:40 +00:00
|
|
|
hadoop_add_subcommand "scmadmin" admin "SharedCacheManager admin tools"
|
2017-09-08 06:25:31 +00:00
|
|
|
hadoop_add_subcommand "sharedcachemanager" daemon "run the SharedCacheManager daemon"
|
2017-08-02 17:17:40 +00:00
|
|
|
hadoop_add_subcommand "timelinereader" client "run the timeline reader server"
|
|
|
|
hadoop_add_subcommand "timelineserver" daemon "run the timeline server"
|
|
|
|
hadoop_add_subcommand "top" client "view cluster information"
|
|
|
|
hadoop_add_subcommand "version" client "print the version"
|
2016-03-28 16:00:07 +00:00
|
|
|
hadoop_generate_usage "${HADOOP_SHELL_EXECNAME}" true
|
2013-02-22 18:36:24 +00:00
|
|
|
}
|
|
|
|
|
2016-03-28 16:00:07 +00:00
|
|
|
## @description Default command handler for yarn command
|
|
|
|
## @audience public
|
|
|
|
## @stability stable
|
|
|
|
## @replaceable no
|
|
|
|
## @param CLI arguments
|
|
|
|
function yarncmd_case
|
|
|
|
{
|
|
|
|
subcmd=$1
|
|
|
|
shift
|
|
|
|
|
|
|
|
case ${subcmd} in
|
2017-10-29 06:04:19 +00:00
|
|
|
app|application|applicationattempt|container)
|
|
|
|
HADOOP_CLASSNAME=org.apache.hadoop.yarn.client.cli.ApplicationCLI
|
|
|
|
set -- "${subcmd}" "$@"
|
|
|
|
HADOOP_SUBCMD_ARGS=("$@")
|
2017-08-29 18:09:00 +00:00
|
|
|
local sld="${HADOOP_YARN_HOME}/${YARN_DIR},\
|
|
|
|
${HADOOP_YARN_HOME}/${YARN_LIB_JARS_DIR},\
|
|
|
|
${HADOOP_HDFS_HOME}/${HDFS_DIR},\
|
|
|
|
${HADOOP_HDFS_HOME}/${HDFS_LIB_JARS_DIR},\
|
|
|
|
${HADOOP_COMMON_HOME}/${HADOOP_COMMON_DIR},\
|
|
|
|
${HADOOP_COMMON_HOME}/${HADOOP_COMMON_LIB_JARS_DIR}"
|
|
|
|
hadoop_translate_cygwin_path sld
|
|
|
|
hadoop_add_param HADOOP_OPTS service.libdir "-Dservice.libdir=${sld}"
|
|
|
|
;;
|
2016-03-28 16:00:07 +00:00
|
|
|
classpath)
|
|
|
|
hadoop_do_classpath_subcommand HADOOP_CLASSNAME "$@"
|
|
|
|
;;
|
|
|
|
cluster)
|
|
|
|
HADOOP_CLASSNAME=org.apache.hadoop.yarn.client.cli.ClusterCLI
|
|
|
|
;;
|
|
|
|
daemonlog)
|
|
|
|
HADOOP_CLASSNAME=org.apache.hadoop.log.LogLevel
|
|
|
|
;;
|
|
|
|
envvars)
|
|
|
|
echo "JAVA_HOME='${JAVA_HOME}'"
|
|
|
|
echo "HADOOP_YARN_HOME='${HADOOP_YARN_HOME}'"
|
|
|
|
echo "YARN_DIR='${YARN_DIR}'"
|
|
|
|
echo "YARN_LIB_JARS_DIR='${YARN_LIB_JARS_DIR}'"
|
|
|
|
echo "HADOOP_CONF_DIR='${HADOOP_CONF_DIR}'"
|
|
|
|
echo "HADOOP_TOOLS_HOME='${HADOOP_TOOLS_HOME}'"
|
|
|
|
echo "HADOOP_TOOLS_DIR='${HADOOP_TOOLS_DIR}'"
|
|
|
|
echo "HADOOP_TOOLS_LIB_JARS_DIR='${HADOOP_TOOLS_LIB_JARS_DIR}'"
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
jar)
|
|
|
|
HADOOP_CLASSNAME=org.apache.hadoop.util.RunJar
|
|
|
|
;;
|
|
|
|
historyserver)
|
|
|
|
HADOOP_SUBCMD_SUPPORTDAEMONIZATION="true"
|
|
|
|
echo "DEPRECATED: Use of this command to start the timeline server is deprecated." 1>&2
|
|
|
|
echo "Instead use the timelineserver command for it." 1>&2
|
|
|
|
echo "Starting the History Server anyway..." 1>&2
|
|
|
|
HADOOP_CLASSNAME='org.apache.hadoop.yarn.server.applicationhistoryservice.ApplicationHistoryServer'
|
|
|
|
;;
|
|
|
|
logs)
|
|
|
|
HADOOP_CLASSNAME=org.apache.hadoop.yarn.client.cli.LogsCLI
|
|
|
|
;;
|
|
|
|
node)
|
|
|
|
HADOOP_CLASSNAME=org.apache.hadoop.yarn.client.cli.NodeCLI
|
|
|
|
;;
|
|
|
|
nodemanager)
|
|
|
|
HADOOP_SUBCMD_SUPPORTDAEMONIZATION="true"
|
|
|
|
HADOOP_CLASSNAME='org.apache.hadoop.yarn.server.nodemanager.NodeManager'
|
|
|
|
# Backwards compatibility
|
|
|
|
if [[ -n "${YARN_NODEMANAGER_HEAPSIZE}" ]]; then
|
|
|
|
HADOOP_HEAPSIZE_MAX="${YARN_NODEMANAGER_HEAPSIZE}"
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
proxyserver)
|
|
|
|
HADOOP_SUBCMD_SUPPORTDAEMONIZATION="true"
|
|
|
|
HADOOP_CLASSNAME='org.apache.hadoop.yarn.server.webproxy.WebAppProxyServer'
|
|
|
|
# Backwards compatibility
|
|
|
|
if [[ -n "${YARN_PROXYSERVER_HEAPSIZE}" ]]; then
|
|
|
|
HADOOP_HEAPSIZE_MAX="${YARN_PROXYSERVER_HEAPSIZE}"
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
queue)
|
|
|
|
HADOOP_CLASSNAME=org.apache.hadoop.yarn.client.cli.QueueCLI
|
|
|
|
;;
|
2017-10-13 17:49:38 +00:00
|
|
|
registrydns)
|
|
|
|
HADOOP_SUBCMD_SUPPORTDAEMONIZATION="true"
|
|
|
|
HADOOP_SECURE_CLASSNAME='org.apache.hadoop.registry.server.dns.PrivilegedRegistryDNSStarter'
|
|
|
|
HADOOP_CLASSNAME='org.apache.hadoop.registry.server.dns.RegistryDNSServer'
|
|
|
|
;;
|
2016-03-28 16:00:07 +00:00
|
|
|
resourcemanager)
|
|
|
|
HADOOP_SUBCMD_SUPPORTDAEMONIZATION="true"
|
|
|
|
HADOOP_CLASSNAME='org.apache.hadoop.yarn.server.resourcemanager.ResourceManager'
|
|
|
|
# Backwards compatibility
|
|
|
|
if [[ -n "${YARN_RESOURCEMANAGER_HEAPSIZE}" ]]; then
|
|
|
|
HADOOP_HEAPSIZE_MAX="${YARN_RESOURCEMANAGER_HEAPSIZE}"
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
rmadmin)
|
|
|
|
HADOOP_CLASSNAME='org.apache.hadoop.yarn.client.cli.RMAdminCLI'
|
|
|
|
;;
|
2017-06-19 17:52:23 +00:00
|
|
|
router)
|
|
|
|
HADOOP_SUBCMD_SUPPORTDAEMONIZATION="true"
|
|
|
|
HADOOP_CLASSNAME='org.apache.hadoop.yarn.server.router.Router'
|
|
|
|
;;
|
2017-09-26 00:52:40 +00:00
|
|
|
schedulerconf)
|
2017-07-07 21:16:46 +00:00
|
|
|
HADOOP_CLASSNAME='org.apache.hadoop.yarn.client.cli.SchedConfCLI'
|
|
|
|
;;
|
2016-03-28 16:00:07 +00:00
|
|
|
scmadmin)
|
|
|
|
HADOOP_CLASSNAME='org.apache.hadoop.yarn.client.SCMAdmin'
|
|
|
|
;;
|
|
|
|
sharedcachemanager)
|
|
|
|
HADOOP_SUBCMD_SUPPORTDAEMONIZATION="true"
|
|
|
|
HADOOP_CLASSNAME='org.apache.hadoop.yarn.server.sharedcachemanager.SharedCacheManager'
|
|
|
|
;;
|
2016-06-21 23:38:20 +00:00
|
|
|
timelinereader)
|
|
|
|
HADOOP_SUBCMD_SUPPORTDAEMONIZATION="true"
|
|
|
|
HADOOP_CLASSNAME='org.apache.hadoop.yarn.server.timelineservice.reader.TimelineReaderServer'
|
|
|
|
;;
|
2016-03-28 16:00:07 +00:00
|
|
|
timelineserver)
|
|
|
|
HADOOP_SUBCMD_SUPPORTDAEMONIZATION="true"
|
|
|
|
HADOOP_CLASSNAME='org.apache.hadoop.yarn.server.applicationhistoryservice.ApplicationHistoryServer'
|
|
|
|
# Backwards compatibility
|
|
|
|
if [[ -n "${YARN_TIMELINESERVER_HEAPSIZE}" ]]; then
|
|
|
|
HADOOP_HEAPSIZE_MAX="${YARN_TIMELINESERVER_HEAPSIZE}"
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
version)
|
|
|
|
HADOOP_CLASSNAME=org.apache.hadoop.util.VersionInfo
|
|
|
|
;;
|
|
|
|
top)
|
|
|
|
doNotSetCols=0
|
|
|
|
doNotSetRows=0
|
|
|
|
for i in "$@"; do
|
|
|
|
if [[ $i == "-cols" ]]; then
|
|
|
|
doNotSetCols=1
|
|
|
|
fi
|
|
|
|
if [[ $i == "-rows" ]]; then
|
|
|
|
doNotSetRows=1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
if [ $doNotSetCols == 0 ] && [ -n "${TERM}" ]; then
|
|
|
|
cols=$(tput cols)
|
|
|
|
if [ -n "$cols" ]; then
|
|
|
|
args=( $@ )
|
|
|
|
args=("${args[@]}" "-cols" "$cols")
|
|
|
|
set -- "${args[@]}"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if [ $doNotSetRows == 0 ] && [ -n "${TERM}" ]; then
|
|
|
|
rows=$(tput lines)
|
|
|
|
if [ -n "$rows" ]; then
|
|
|
|
args=( $@ )
|
|
|
|
args=("${args[@]}" "-rows" "$rows")
|
|
|
|
set -- "${args[@]}"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
HADOOP_CLASSNAME=org.apache.hadoop.yarn.client.cli.TopCLI
|
2016-05-26 23:43:08 +00:00
|
|
|
HADOOP_SUBCMD_ARGS=("$@")
|
2016-03-28 16:00:07 +00:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
HADOOP_CLASSNAME="${subcmd}"
|
|
|
|
if ! hadoop_validate_classname "${HADOOP_CLASSNAME}"; then
|
|
|
|
hadoop_exit_with_usage 1
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
2014-08-19 12:11:17 +00:00
|
|
|
|
|
|
|
# let's locate libexec...
|
2016-03-24 15:47:00 +00:00
|
|
|
if [[ -n "${HADOOP_HOME}" ]]; then
|
|
|
|
HADOOP_DEFAULT_LIBEXEC_DIR="${HADOOP_HOME}/libexec"
|
2014-08-19 12:11:17 +00:00
|
|
|
else
|
2015-07-16 23:58:11 +00:00
|
|
|
bin=$(cd -P -- "$(dirname -- "${MYNAME}")" >/dev/null && pwd -P)
|
2015-11-04 10:26:17 +00:00
|
|
|
HADOOP_DEFAULT_LIBEXEC_DIR="${bin}/../libexec"
|
2014-08-19 12:11:17 +00:00
|
|
|
fi
|
|
|
|
|
2015-11-04 10:26:17 +00:00
|
|
|
HADOOP_LIBEXEC_DIR="${HADOOP_LIBEXEC_DIR:-$HADOOP_DEFAULT_LIBEXEC_DIR}"
|
2014-08-19 12:11:17 +00:00
|
|
|
HADOOP_NEW_CONFIG=true
|
|
|
|
if [[ -f "${HADOOP_LIBEXEC_DIR}/yarn-config.sh" ]]; then
|
2017-03-29 16:56:25 +00:00
|
|
|
# shellcheck source=./hadoop-yarn-project/hadoop-yarn/bin/yarn-config.sh
|
2014-08-19 12:11:17 +00:00
|
|
|
. "${HADOOP_LIBEXEC_DIR}/yarn-config.sh"
|
|
|
|
else
|
|
|
|
echo "ERROR: Cannot execute ${HADOOP_LIBEXEC_DIR}/yarn-config.sh." 2>&1
|
MAPREDUCE-279. MapReduce 2.0. Merging MR-279 branch into trunk. Contributed by Arun C Murthy, Christopher Douglas, Devaraj Das, Greg Roelofs, Jeffrey Naisbitt, Josh Wills, Jonathan Eagles, Krishna Ramachandran, Luke Lu, Mahadev Konar, Robert Evans, Sharad Agarwal, Siddharth Seth, Thomas Graves, and Vinod Kumar Vavilapalli.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1159166 13f79535-47bb-0310-9956-ffa450edef68
2011-08-18 11:07:10 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2016-08-05 01:08:23 +00:00
|
|
|
# now that we have support code, let's abs MYNAME so we can use it later
|
|
|
|
MYNAME=$(hadoop_abs "${MYNAME}")
|
|
|
|
|
2014-08-19 12:11:17 +00:00
|
|
|
# if no args specified, show usage
|
|
|
|
if [[ $# = 0 ]]; then
|
|
|
|
hadoop_exit_with_usage 1
|
|
|
|
fi
|
|
|
|
|
MAPREDUCE-279. MapReduce 2.0. Merging MR-279 branch into trunk. Contributed by Arun C Murthy, Christopher Douglas, Devaraj Das, Greg Roelofs, Jeffrey Naisbitt, Josh Wills, Jonathan Eagles, Krishna Ramachandran, Luke Lu, Mahadev Konar, Robert Evans, Sharad Agarwal, Siddharth Seth, Thomas Graves, and Vinod Kumar Vavilapalli.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1159166 13f79535-47bb-0310-9956-ffa450edef68
2011-08-18 11:07:10 +00:00
|
|
|
# get arguments
|
2016-03-28 16:00:07 +00:00
|
|
|
HADOOP_SUBCMD=$1
|
MAPREDUCE-279. MapReduce 2.0. Merging MR-279 branch into trunk. Contributed by Arun C Murthy, Christopher Douglas, Devaraj Das, Greg Roelofs, Jeffrey Naisbitt, Josh Wills, Jonathan Eagles, Krishna Ramachandran, Luke Lu, Mahadev Konar, Robert Evans, Sharad Agarwal, Siddharth Seth, Thomas Graves, and Vinod Kumar Vavilapalli.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1159166 13f79535-47bb-0310-9956-ffa450edef68
2011-08-18 11:07:10 +00:00
|
|
|
shift
|
|
|
|
|
2016-08-05 01:08:23 +00:00
|
|
|
if hadoop_need_reexec yarn "${HADOOP_SUBCMD}"; then
|
|
|
|
hadoop_uservar_su yarn "${HADOOP_SUBCMD}" \
|
|
|
|
"${MYNAME}" \
|
|
|
|
"--reexec" \
|
|
|
|
"${HADOOP_USER_PARAMS[@]}"
|
|
|
|
exit $?
|
|
|
|
fi
|
|
|
|
|
2017-03-29 16:56:25 +00:00
|
|
|
hadoop_verify_user_perm "${HADOOP_SHELL_EXECNAME}" "${HADOOP_SUBCMD}"
|
2016-09-12 18:10:00 +00:00
|
|
|
|
2016-03-28 16:00:07 +00:00
|
|
|
HADOOP_SUBCMD_ARGS=("$@")
|
|
|
|
|
|
|
|
if declare -f yarn_subcommand_"${HADOOP_SUBCMD}" >/dev/null 2>&1; then
|
|
|
|
hadoop_debug "Calling dynamically: yarn_subcommand_${HADOOP_SUBCMD} ${HADOOP_SUBCMD_ARGS[*]}"
|
|
|
|
"yarn_subcommand_${HADOOP_SUBCMD}" "${HADOOP_SUBCMD_ARGS[@]}"
|
|
|
|
else
|
|
|
|
yarncmd_case "${HADOOP_SUBCMD}" "${HADOOP_SUBCMD_ARGS[@]}"
|
|
|
|
fi
|
2013-02-22 18:36:24 +00:00
|
|
|
|
2016-09-12 18:10:00 +00:00
|
|
|
# It's unclear if YARN_CLIENT_OPTS is actually a useful
|
|
|
|
# thing to have separate from HADOOP_CLIENT_OPTS. Someone
|
|
|
|
# might use it, so let's not deprecate it and just override
|
|
|
|
# HADOOP_CLIENT_OPTS instead before we (potentially) add it
|
|
|
|
# to the command line
|
|
|
|
if [[ -n "${YARN_CLIENT_OPTS}" ]]; then
|
|
|
|
HADOOP_CLIENT_OPTS=${YARN_CLIENT_OPTS}
|
|
|
|
fi
|
|
|
|
|
|
|
|
hadoop_add_client_opts
|
2014-12-10 21:41:28 +00:00
|
|
|
|
2016-06-28 12:53:03 +00:00
|
|
|
if [[ ${HADOOP_WORKER_MODE} = true ]]; then
|
|
|
|
hadoop_common_worker_mode_execute "${HADOOP_YARN_HOME}/bin/yarn" "${HADOOP_USER_PARAMS[@]}"
|
2015-02-13 02:01:28 +00:00
|
|
|
exit $?
|
|
|
|
fi
|
|
|
|
|
2016-09-12 18:10:00 +00:00
|
|
|
hadoop_subcommand_opts "${HADOOP_SHELL_EXECNAME}" "${HADOOP_SUBCMD}"
|
|
|
|
|
2017-03-29 16:56:25 +00:00
|
|
|
# everything is in globals at this point, so call the generic handler
|
|
|
|
hadoop_generic_java_subcmd_handler
|