2011-10-28 01:56:57 +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.
|
|
|
|
|
2014-08-19 12:11:17 +00:00
|
|
|
function hadoop_usage
|
|
|
|
{
|
2014-11-13 05:41:19 +00:00
|
|
|
echo "Usage: mapred [--config confdir] [--daemon (start|stop|status)]"
|
|
|
|
echo " [--loglevel loglevel] COMMAND"
|
2011-10-28 01:56:57 +00:00
|
|
|
echo " where COMMAND is one of:"
|
2014-08-19 12:11:17 +00:00
|
|
|
|
|
|
|
echo " archive -archiveName NAME -p <parent path> <src>* <dest> create a hadoop archive"
|
2011-10-28 01:56:57 +00:00
|
|
|
echo " classpath prints the class path needed for running"
|
|
|
|
echo " mapreduce subcommands"
|
2012-02-07 01:49:50 +00:00
|
|
|
echo " distcp <srcurl> <desturl> copy file or directories recursively"
|
2014-08-19 12:11:17 +00:00
|
|
|
echo " historyserver run job history servers as a standalone daemon"
|
2014-11-14 21:10:06 +00:00
|
|
|
echo " hsadmin job history server admin interface"
|
|
|
|
echo " job manipulate MapReduce jobs"
|
2014-08-19 12:11:17 +00:00
|
|
|
echo " pipes run a Pipes job"
|
|
|
|
echo " queue get information regarding JobQueues"
|
|
|
|
echo " sampler sampler"
|
2014-08-20 18:47:10 +00:00
|
|
|
echo " version print the version"
|
2011-10-28 01:56:57 +00:00
|
|
|
echo ""
|
|
|
|
echo "Most commands print help when invoked w/o parameters."
|
|
|
|
}
|
|
|
|
|
2014-08-19 12:11:17 +00:00
|
|
|
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
|
|
|
|
|
|
|
|
HADOOP_LIBEXEC_DIR="${HADOOP_LIBEXEC_DIR:-$DEFAULT_LIBEXEC_DIR}"
|
|
|
|
# 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-28 01:56:57 +00:00
|
|
|
if [ $# = 0 ]; then
|
2014-08-19 12:11:17 +00:00
|
|
|
hadoop_exit_with_usage 1
|
2011-10-28 01:56:57 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
COMMAND=$1
|
|
|
|
shift
|
|
|
|
|
2014-08-19 12:11:17 +00:00
|
|
|
case ${COMMAND} in
|
|
|
|
mradmin|jobtracker|tasktracker|groups)
|
2014-08-28 17:37:23 +00: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 12:11:17 +00:00
|
|
|
hadoop_exit_with_usage 1
|
|
|
|
;;
|
|
|
|
archive)
|
|
|
|
CLASS=org.apache.hadoop.tools.HadoopArchives
|
2014-08-28 17:37:23 +00:00
|
|
|
hadoop_debug "Injecting TOOL_PATH into CLASSPATH"
|
2014-08-19 12:11:17 +00:00
|
|
|
hadoop_add_classpath "${TOOL_PATH}"
|
2014-08-28 17:37:23 +00:00
|
|
|
hadoop_debug "Appending HADOOP_CLIENT_OPTS onto HADOOP_OPTS"
|
2014-08-19 12:11:17 +00:00
|
|
|
HADOOP_OPTS="${HADOOP_OPTS} ${HADOOP_CLIENT_OPTS}"
|
|
|
|
;;
|
|
|
|
classpath)
|
|
|
|
hadoop_finalize
|
|
|
|
echo "${CLASSPATH}"
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
distcp)
|
|
|
|
CLASS=org.apache.hadoop.tools.DistCp
|
2014-08-28 17:37:23 +00:00
|
|
|
hadoop_debug "Injecting TOOL_PATH into CLASSPATH"
|
2014-08-19 12:11:17 +00:00
|
|
|
hadoop_add_classpath "${TOOL_PATH}"
|
2014-08-28 17:37:23 +00:00
|
|
|
hadoop_debug "Appending HADOOP_CLIENT_OPTS onto HADOOP_OPTS"
|
2014-08-19 12:11:17 +00:00
|
|
|
HADOOP_OPTS="${HADOOP_OPTS} ${HADOOP_CLIENT_OPTS}"
|
|
|
|
;;
|
|
|
|
historyserver)
|
2014-11-19 22:49:16 +00:00
|
|
|
supportdaemonization="true"
|
2014-08-19 12:11:17 +00:00
|
|
|
CLASS=org.apache.hadoop.mapreduce.v2.hs.JobHistoryServer
|
2014-08-28 17:37:23 +00:00
|
|
|
hadoop_debug "Appending HADOOP_JOB_HISTORYSERVER_OPTS onto HADOOP_OPTS"
|
2014-08-19 12:11:17 +00:00
|
|
|
HADOOP_OPTS="${HADOOP_OPTS} ${HADOOP_JOB_HISTORYSERVER_OPTS}"
|
|
|
|
if [ -n "${HADOOP_JOB_HISTORYSERVER_HEAPSIZE}" ]; then
|
|
|
|
JAVA_HEAP_MAX="-Xmx${HADOOP_JOB_HISTORYSERVER_HEAPSIZE}m"
|
|
|
|
fi
|
|
|
|
HADOOP_DAEMON_ROOT_LOGGER=${HADOOP_JHS_LOGGER:-$HADOOP_DAEMON_ROOT_LOGGER}
|
|
|
|
;;
|
2014-11-14 21:10:06 +00: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 12:11:17 +00:00
|
|
|
job)
|
|
|
|
CLASS=org.apache.hadoop.mapred.JobClient
|
2014-11-14 21:10:06 +00:00
|
|
|
hadoop_debug "Appending HADOOP_CLIENT_OPTS onto HADOOP_OPTS"
|
|
|
|
HADOOP_OPTS="${HADOOP_OPTS} ${HADOOP_CLIENT_OPTS}"
|
2014-08-19 12:11:17 +00:00
|
|
|
;;
|
|
|
|
pipes)
|
|
|
|
CLASS=org.apache.hadoop.mapred.pipes.Submitter
|
2014-08-28 17:37:23 +00:00
|
|
|
hadoop_debug "Appending HADOOP_CLIENT_OPTS onto HADOOP_OPTS"
|
2014-08-19 12:11:17 +00: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 17:37:23 +00:00
|
|
|
hadoop_debug "Appending HADOOP_CLIENT_OPTS onto HADOOP_OPTS"
|
2014-08-19 12:11:17 +00:00
|
|
|
HADOOP_OPTS="${HADOOP_OPTS} ${HADOOP_CLIENT_OPTS}"
|
|
|
|
;;
|
2014-08-20 18:47:10 +00:00
|
|
|
version)
|
|
|
|
CLASS=org.apache.hadoop.util.VersionInfo
|
2014-08-28 17:37:23 +00:00
|
|
|
hadoop_debug "Appending HADOOP_CLIENT_OPTS onto HADOOP_OPTS"
|
2014-08-20 18:47:10 +00:00
|
|
|
HADOOP_OPTS="${HADOOP_OPTS} ${HADOOP_CLIENT_OPTS}"
|
|
|
|
;;
|
2014-09-23 19:24:23 +00:00
|
|
|
*)
|
|
|
|
CLASS="${COMMAND}"
|
|
|
|
if ! hadoop_validate_classname "${CLASS}"; then
|
|
|
|
hadoop_exit_with_usage 1
|
|
|
|
fi
|
2014-08-19 12:11:17 +00:00
|
|
|
;;
|
2013-02-27 02:42:38 +00:00
|
|
|
esac
|
|
|
|
|
2014-08-19 12:11:17 +00: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-28 01:56:57 +00:00
|
|
|
|
|
|
|
|
2014-08-19 12:11:17 +00: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-28 01:56:57 +00:00
|
|
|
fi
|
|
|
|
|
2014-08-19 12:11:17 +00:00
|
|
|
hadoop_add_param HADOOP_OPTS Xmx "${JAVA_HEAP_MAX}"
|
|
|
|
hadoop_finalize
|
2011-10-28 17:08:09 +00:00
|
|
|
|
2014-11-19 22:49:16 +00:00
|
|
|
if [[ -n "${supportdaemonization}" ]]; then
|
2014-08-19 12:11:17 +00: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
|
|
|
|
|