2011-10-27 21:56:57 -04: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 19:58:11 -04:00
|
|
|
MYNAME="${BASH_SOURCE-$0}"
|
|
|
|
|
2014-08-19 08:11:17 -04:00
|
|
|
function hadoop_usage
|
|
|
|
{
|
2015-07-16 19:58:11 -04:00
|
|
|
hadoop_add_subcommand "archive" "create a hadoop archive"
|
2015-09-09 20:41:27 -04:00
|
|
|
hadoop_add_subcommand "archive-logs" "combine aggregated logs into hadoop archives"
|
2015-07-16 19:58:11 -04:00
|
|
|
hadoop_add_subcommand "classpath" "prints the class path needed for running mapreduce subcommands"
|
|
|
|
hadoop_add_subcommand "distcp" "copy file or directories recursively"
|
2015-11-07 11:32:56 -05:00
|
|
|
hadoop_add_subcommand "envvars" "display computed Hadoop environment variables"
|
2015-07-16 19:58:11 -04:00
|
|
|
hadoop_add_subcommand "historyserver" "run job history servers as a standalone daemon"
|
|
|
|
hadoop_add_subcommand "hsadmin" "job history server admin interface"
|
|
|
|
hadoop_add_subcommand "job" "manipulate MapReduce jobs"
|
|
|
|
hadoop_add_subcommand "pipes" "run a Pipes job"
|
|
|
|
hadoop_add_subcommand "queue" "get information regarding JobQueues"
|
|
|
|
hadoop_add_subcommand "sampler" "sampler"
|
|
|
|
hadoop_add_subcommand "version" "print the version"
|
2015-07-31 17:32:21 -04:00
|
|
|
hadoop_generate_usage "${MYNAME}" true
|
2011-10-27 21:56:57 -04:00
|
|
|
}
|
|
|
|
|
2015-07-16 19:58:11 -04:00
|
|
|
bin=$(cd -P -- "$(dirname -- "${MYNAME}")" >/dev/null && pwd -P)
|
2014-08-19 08:11:17 -04:00
|
|
|
|
|
|
|
# let's locate libexec...
|
|
|
|
if [[ -n "${HADOOP_PREFIX}" ]]; then
|
2015-11-04 05:26:17 -05:00
|
|
|
HADOOP_DEFAULT_LIBEXEC_DIR="${HADOOP_PREFIX}/libexec"
|
2014-08-19 08:11:17 -04:00
|
|
|
else
|
2015-11-04 05:26:17 -05:00
|
|
|
HADOOP_DEFAULT_LIBEXEC_DIR="${bin}/../libexec"
|
2014-08-19 08:11:17 -04:00
|
|
|
fi
|
|
|
|
|
2015-11-04 05:26:17 -05:00
|
|
|
HADOOP_LIBEXEC_DIR="${HADOOP_LIBEXEC_DIR:-$HADOOP_DEFAULT_LIBEXEC_DIR}"
|
2014-08-19 08:11:17 -04:00
|
|
|
# shellcheck disable=SC2034
|
|
|
|
HADOOP_NEW_CONFIG=true
|
|
|
|
if [[ -f "${HADOOP_LIBEXEC_DIR}/mapred-config.sh" ]]; then
|
|
|
|
. "${HADOOP_LIBEXEC_DIR}/mapred-config.sh"
|
|
|
|
else
|
|
|
|
echo "ERROR: Cannot execute ${HADOOP_LIBEXEC_DIR}/mapred-config.sh." 2>&1
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2011-10-27 21:56:57 -04:00
|
|
|
if [ $# = 0 ]; then
|
2014-08-19 08:11:17 -04:00
|
|
|
hadoop_exit_with_usage 1
|
2011-10-27 21:56:57 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
COMMAND=$1
|
|
|
|
shift
|
|
|
|
|
2014-08-19 08:11:17 -04:00
|
|
|
case ${COMMAND} in
|
|
|
|
mradmin|jobtracker|tasktracker|groups)
|
2014-08-28 13:37:23 -04:00
|
|
|
hadoop_error "Sorry, the ${COMMAND} command is no longer supported."
|
|
|
|
hadoop_error "You may find similar functionality with the \"yarn\" shell command."
|
2014-08-19 08:11:17 -04:00
|
|
|
hadoop_exit_with_usage 1
|
|
|
|
;;
|
|
|
|
archive)
|
|
|
|
CLASS=org.apache.hadoop.tools.HadoopArchives
|
2016-03-02 16:13:36 -05:00
|
|
|
hadoop_add_to_classpath_tools hadoop-archives
|
2014-08-28 13:37:23 -04:00
|
|
|
hadoop_debug "Appending HADOOP_CLIENT_OPTS onto HADOOP_OPTS"
|
2014-08-19 08:11:17 -04:00
|
|
|
HADOOP_OPTS="${HADOOP_OPTS} ${HADOOP_CLIENT_OPTS}"
|
|
|
|
;;
|
2015-09-09 20:41:27 -04:00
|
|
|
archive-logs)
|
|
|
|
CLASS=org.apache.hadoop.tools.HadoopArchiveLogs
|
2016-03-02 16:13:36 -05:00
|
|
|
hadoop_add_to_classpath_tools hadoop-archive-logs
|
2015-09-09 20:41:27 -04:00
|
|
|
hadoop_debug "Appending HADOOP_CLIENT_OPTS onto HADOOP_OPTS"
|
|
|
|
HADOOP_OPTS="${HADOOP_OPTS} ${HADOOP_CLIENT_OPTS}"
|
|
|
|
;;
|
2014-08-19 08:11:17 -04:00
|
|
|
classpath)
|
2015-03-26 01:36:09 -04:00
|
|
|
hadoop_do_classpath_subcommand CLASS "$@"
|
2014-08-19 08:11:17 -04:00
|
|
|
;;
|
|
|
|
distcp)
|
|
|
|
CLASS=org.apache.hadoop.tools.DistCp
|
2016-03-02 16:13:36 -05:00
|
|
|
hadoop_add_to_classpath_tools hadoop-distcp
|
2014-08-28 13:37:23 -04:00
|
|
|
hadoop_debug "Appending HADOOP_CLIENT_OPTS onto HADOOP_OPTS"
|
2014-08-19 08:11:17 -04:00
|
|
|
HADOOP_OPTS="${HADOOP_OPTS} ${HADOOP_CLIENT_OPTS}"
|
|
|
|
;;
|
2015-11-07 11:32:56 -05:00
|
|
|
envvars)
|
|
|
|
echo "JAVA_HOME='${JAVA_HOME}'"
|
|
|
|
echo "HADOOP_MAPRED_HOME='${HADOOP_MAPRED_HOME}'"
|
|
|
|
echo "MAPRED_DIR='${MAPRED_DIR}'"
|
|
|
|
echo "MAPRED_LIB_JARS_DIR='${MAPRED_LIB_JARS_DIR}'"
|
|
|
|
echo "HADOOP_CONF_DIR='${HADOOP_CONF_DIR}'"
|
2016-03-02 16:13:36 -05:00
|
|
|
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}'"
|
2015-11-07 11:32:56 -05:00
|
|
|
exit 0
|
|
|
|
;;
|
2014-08-19 08:11:17 -04:00
|
|
|
historyserver)
|
2014-11-19 17:49:16 -05:00
|
|
|
supportdaemonization="true"
|
2014-08-19 08:11:17 -04:00
|
|
|
CLASS=org.apache.hadoop.mapreduce.v2.hs.JobHistoryServer
|
2014-08-28 13:37:23 -04:00
|
|
|
hadoop_debug "Appending HADOOP_JOB_HISTORYSERVER_OPTS onto HADOOP_OPTS"
|
2014-08-19 08:11:17 -04:00
|
|
|
HADOOP_OPTS="${HADOOP_OPTS} ${HADOOP_JOB_HISTORYSERVER_OPTS}"
|
|
|
|
if [ -n "${HADOOP_JOB_HISTORYSERVER_HEAPSIZE}" ]; then
|
2014-12-10 16:37:32 -05:00
|
|
|
HADOOP_HEAPSIZE_MAX="${HADOOP_JOB_HISTORYSERVER_HEAPSIZE}"
|
2014-08-19 08:11:17 -04:00
|
|
|
fi
|
|
|
|
HADOOP_DAEMON_ROOT_LOGGER=${HADOOP_JHS_LOGGER:-$HADOOP_DAEMON_ROOT_LOGGER}
|
|
|
|
;;
|
2014-11-14 16:10:06 -05:00
|
|
|
hsadmin)
|
|
|
|
CLASS=org.apache.hadoop.mapreduce.v2.hs.client.HSAdmin
|
|
|
|
hadoop_debug "Appending HADOOP_CLIENT_OPTS onto HADOOP_OPTS"
|
|
|
|
HADOOP_OPTS="${HADOOP_OPTS} ${HADOOP_CLIENT_OPTS}"
|
|
|
|
;;
|
2014-08-19 08:11:17 -04:00
|
|
|
job)
|
|
|
|
CLASS=org.apache.hadoop.mapred.JobClient
|
2014-11-14 16:10:06 -05:00
|
|
|
hadoop_debug "Appending HADOOP_CLIENT_OPTS onto HADOOP_OPTS"
|
|
|
|
HADOOP_OPTS="${HADOOP_OPTS} ${HADOOP_CLIENT_OPTS}"
|
2014-08-19 08:11:17 -04:00
|
|
|
;;
|
|
|
|
pipes)
|
|
|
|
CLASS=org.apache.hadoop.mapred.pipes.Submitter
|
2014-08-28 13:37:23 -04:00
|
|
|
hadoop_debug "Appending HADOOP_CLIENT_OPTS onto HADOOP_OPTS"
|
2014-08-19 08:11:17 -04:00
|
|
|
HADOOP_OPTS="${HADOOP_OPTS} ${HADOOP_CLIENT_OPTS}"
|
|
|
|
;;
|
|
|
|
queue)
|
|
|
|
CLASS=org.apache.hadoop.mapred.JobQueueClient
|
|
|
|
;;
|
|
|
|
sampler)
|
|
|
|
CLASS=org.apache.hadoop.mapred.lib.InputSampler
|
2014-08-28 13:37:23 -04:00
|
|
|
hadoop_debug "Appending HADOOP_CLIENT_OPTS onto HADOOP_OPTS"
|
2014-08-19 08:11:17 -04:00
|
|
|
HADOOP_OPTS="${HADOOP_OPTS} ${HADOOP_CLIENT_OPTS}"
|
|
|
|
;;
|
2014-08-20 14:47:10 -04:00
|
|
|
version)
|
|
|
|
CLASS=org.apache.hadoop.util.VersionInfo
|
2014-08-28 13:37:23 -04:00
|
|
|
hadoop_debug "Appending HADOOP_CLIENT_OPTS onto HADOOP_OPTS"
|
2014-08-20 14:47:10 -04:00
|
|
|
HADOOP_OPTS="${HADOOP_OPTS} ${HADOOP_CLIENT_OPTS}"
|
|
|
|
;;
|
2014-09-23 15:24:23 -04:00
|
|
|
*)
|
|
|
|
CLASS="${COMMAND}"
|
|
|
|
if ! hadoop_validate_classname "${CLASS}"; then
|
|
|
|
hadoop_exit_with_usage 1
|
|
|
|
fi
|
2014-08-19 08:11:17 -04:00
|
|
|
;;
|
2013-02-26 21:42:38 -05:00
|
|
|
esac
|
2014-12-10 16:41:28 -05:00
|
|
|
|
|
|
|
hadoop_verify_user "${COMMAND}"
|
2015-02-12 21:01:28 -05:00
|
|
|
|
|
|
|
if [[ ${HADOOP_SLAVE_MODE} = true ]]; then
|
|
|
|
hadoop_common_slave_mode_execute "${HADOOP_MAPRED_HOME}/bin/mapred" "${HADOOP_USER_PARAMS[@]}"
|
|
|
|
exit $?
|
|
|
|
fi
|
2013-02-26 21:42:38 -05:00
|
|
|
|
2014-08-19 08:11:17 -04:00
|
|
|
daemon_outfile="${HADOOP_LOG_DIR}/hadoop-${HADOOP_IDENT_STRING}-${COMMAND}-${HOSTNAME}.out"
|
|
|
|
daemon_pidfile="${HADOOP_PID_DIR}/hadoop-${HADOOP_IDENT_STRING}-${COMMAND}.pid"
|
2011-10-27 21:56:57 -04:00
|
|
|
|
|
|
|
|
2014-08-19 08:11:17 -04:00
|
|
|
if [[ "${HADOOP_DAEMON_MODE}" != "default" ]]; then
|
|
|
|
# shellcheck disable=SC2034
|
|
|
|
HADOOP_ROOT_LOGGER="${HADOOP_DAEMON_ROOT_LOGGER}"
|
|
|
|
hadoop_add_param HADOOP_OPTS mapred.jobsummary.logger "-Dmapred.jobsummary.logger=${HADOOP_ROOT_LOGGER}"
|
|
|
|
# shellcheck disable=SC2034
|
|
|
|
HADOOP_LOGFILE="hadoop-${HADOOP_IDENT_STRING}-${COMMAND}-${HOSTNAME}.log"
|
2011-10-27 21:56:57 -04:00
|
|
|
fi
|
|
|
|
|
2014-08-19 08:11:17 -04:00
|
|
|
hadoop_finalize
|
2011-10-28 13:08:09 -04:00
|
|
|
|
2014-11-19 17:49:16 -05:00
|
|
|
if [[ -n "${supportdaemonization}" ]]; then
|
2014-08-19 08:11:17 -04:00
|
|
|
if [[ -n "${secure_service}" ]]; then
|
|
|
|
hadoop_secure_daemon_handler "${HADOOP_DAEMON_MODE}" "${COMMAND}"\
|
|
|
|
"${CLASS}" "${daemon_pidfile}" "${daemon_outfile}" \
|
|
|
|
"${priv_pidfile}" "${priv_outfile}" "${priv_errfile}" "$@"
|
|
|
|
else
|
|
|
|
hadoop_daemon_handler "${HADOOP_DAEMON_MODE}" "${COMMAND}" "${CLASS}" \
|
|
|
|
"${daemon_pidfile}" "${daemon_outfile}" "$@"
|
|
|
|
fi
|
|
|
|
exit $?
|
|
|
|
else
|
|
|
|
hadoop_java_exec "${COMMAND}" "${CLASS}" "$@"
|
|
|
|
fi
|
|
|
|
|