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.
|
|
|
|
|
|
|
|
bin=`which $0`
|
|
|
|
bin=`dirname ${bin}`
|
2012-09-29 10:57:53 +00:00
|
|
|
bin=`cd "$bin" > /dev/null; pwd`
|
2011-10-28 01:56:57 +00:00
|
|
|
|
2011-11-18 00:57:08 +00:00
|
|
|
DEFAULT_LIBEXEC_DIR="$bin"/../libexec
|
|
|
|
HADOOP_LIBEXEC_DIR=${HADOOP_LIBEXEC_DIR:-$DEFAULT_LIBEXEC_DIR}
|
|
|
|
if [ -e ${HADOOP_LIBEXEC_DIR}/mapred-config.sh ]; then
|
|
|
|
. ${HADOOP_LIBEXEC_DIR}/mapred-config.sh
|
2011-10-28 01:56:57 +00:00
|
|
|
else
|
|
|
|
. "$bin/mapred-config.sh"
|
|
|
|
fi
|
|
|
|
|
|
|
|
function print_usage(){
|
|
|
|
echo "Usage: mapred [--config confdir] COMMAND"
|
|
|
|
echo " where COMMAND is one of:"
|
|
|
|
echo " pipes run a Pipes job"
|
|
|
|
echo " job manipulate MapReduce jobs"
|
|
|
|
echo " queue get information regarding JobQueues"
|
|
|
|
echo " classpath prints the class path needed for running"
|
|
|
|
echo " mapreduce subcommands"
|
|
|
|
echo " groups get the groups which users belong to"
|
2012-02-06 23:11:26 +00:00
|
|
|
echo " historyserver run job history servers as a standalone daemon"
|
2012-02-07 01:49:50 +00:00
|
|
|
echo " distcp <srcurl> <desturl> copy file or directories recursively"
|
|
|
|
echo " archive -archiveName NAME -p <parent path> <src>* <dest> create a hadoop archive"
|
2011-10-28 01:56:57 +00:00
|
|
|
echo ""
|
|
|
|
echo "Most commands print help when invoked w/o parameters."
|
|
|
|
}
|
|
|
|
|
|
|
|
if [ $# = 0 ]; then
|
|
|
|
print_usage
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
COMMAND=$1
|
|
|
|
shift
|
|
|
|
|
2012-01-25 21:22:33 +00:00
|
|
|
if [ "$COMMAND" = "job" ] ; then
|
2011-10-28 01:56:57 +00:00
|
|
|
CLASS=org.apache.hadoop.mapred.JobClient
|
|
|
|
elif [ "$COMMAND" = "queue" ] ; then
|
|
|
|
CLASS=org.apache.hadoop.mapred.JobQueueClient
|
|
|
|
elif [ "$COMMAND" = "pipes" ] ; then
|
|
|
|
CLASS=org.apache.hadoop.mapred.pipes.Submitter
|
|
|
|
HADOOP_OPTS="$HADOOP_OPTS $HADOOP_CLIENT_OPTS"
|
|
|
|
elif [ "$COMMAND" = "sampler" ] ; then
|
|
|
|
CLASS=org.apache.hadoop.mapred.lib.InputSampler
|
|
|
|
HADOOP_OPTS="$HADOOP_OPTS $HADOOP_CLIENT_OPTS"
|
|
|
|
elif [ "$COMMAND" = "classpath" ] ; then
|
|
|
|
echo -n
|
|
|
|
elif [ "$COMMAND" = "groups" ] ; then
|
|
|
|
CLASS=org.apache.hadoop.mapred.tools.GetGroups
|
|
|
|
HADOOP_OPTS="$HADOOP_OPTS $HADOOP_CLIENT_OPTS"
|
2012-02-06 23:11:26 +00:00
|
|
|
elif [ "$COMMAND" = "historyserver" ] ; then
|
|
|
|
CLASS=org.apache.hadoop.mapreduce.v2.hs.JobHistoryServer
|
2012-03-05 19:03:56 +00:00
|
|
|
HADOOP_OPTS="$HADOOP_OPTS -Dmapred.jobsummary.logger=${HADOOP_JHS_LOGGER:-INFO,console} $HADOOP_JOB_HISTORYSERVER_OPTS"
|
|
|
|
if [ "$HADOOP_JOB_HISTORYSERVER_HEAPSIZE" != "" ]; then
|
|
|
|
JAVA_HEAP_MAX="-Xmx""$HADOOP_JOB_HISTORYSERVER_HEAPSIZE""m"
|
|
|
|
fi
|
2012-01-25 21:22:33 +00:00
|
|
|
elif [ "$COMMAND" = "mradmin" ] \
|
|
|
|
|| [ "$COMMAND" = "jobtracker" ] \
|
|
|
|
|| [ "$COMMAND" = "tasktracker" ] ; then
|
|
|
|
echo "Sorry, the $COMMAND command is no longer supported."
|
|
|
|
echo "You may find similar functionality with the \"yarn\" shell command."
|
|
|
|
print_usage
|
|
|
|
exit
|
2012-02-07 01:49:50 +00:00
|
|
|
elif [ "$COMMAND" = "distcp" ] ; then
|
|
|
|
CLASS=org.apache.hadoop.tools.DistCp
|
|
|
|
CLASSPATH=${CLASSPATH}:${TOOL_PATH}
|
|
|
|
HADOOP_OPTS="$HADOOP_OPTS $HADOOP_CLIENT_OPTS"
|
|
|
|
elif [ "$COMMAND" = "archive" ] ; then
|
|
|
|
CLASS=org.apache.hadoop.tools.HadoopArchives
|
|
|
|
CLASSPATH=${CLASSPATH}:${TOOL_PATH}
|
|
|
|
HADOOP_OPTS="$HADOOP_OPTS $HADOOP_CLIENT_OPTS"
|
2011-10-28 01:56:57 +00:00
|
|
|
else
|
|
|
|
echo $COMMAND - invalid command
|
|
|
|
print_usage
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
# for developers, add mapred classes to CLASSPATH
|
|
|
|
if [ -d "$HADOOP_MAPRED_HOME/build/classes" ]; then
|
|
|
|
CLASSPATH=${CLASSPATH}:$HADOOP_MAPRED_HOME/build/classes
|
|
|
|
fi
|
|
|
|
if [ -d "$HADOOP_MAPRED_HOME/build/webapps" ]; then
|
|
|
|
CLASSPATH=${CLASSPATH}:$HADOOP_MAPRED_HOME/build
|
|
|
|
fi
|
|
|
|
if [ -d "$HADOOP_MAPRED_HOME/build/test/classes" ]; then
|
|
|
|
CLASSPATH=${CLASSPATH}:$HADOOP_MAPRED_HOME/build/test/classes
|
|
|
|
fi
|
|
|
|
if [ -d "$HADOOP_MAPRED_HOME/build/tools" ]; then
|
|
|
|
CLASSPATH=${CLASSPATH}:$HADOOP_MAPRED_HOME/build/tools
|
|
|
|
fi
|
|
|
|
|
|
|
|
# for releases, add core mapred jar & webapps to CLASSPATH
|
2012-01-27 23:53:35 +00:00
|
|
|
if [ -d "$HADOOP_PREFIX/${MAPRED_DIR}/webapps" ]; then
|
|
|
|
CLASSPATH=${CLASSPATH}:$HADOOP_PREFIX/${MAPRED_DIR}
|
2011-10-28 01:56:57 +00:00
|
|
|
fi
|
2012-01-27 23:53:35 +00:00
|
|
|
for f in $HADOOP_MAPRED_HOME/${MAPRED_DIR}/*.jar; do
|
2011-10-28 01:56:57 +00:00
|
|
|
CLASSPATH=${CLASSPATH}:$f;
|
|
|
|
done
|
|
|
|
|
2012-09-25 23:49:09 +00:00
|
|
|
# Need YARN jars also
|
|
|
|
for f in $HADOOP_YARN_HOME/${YARN_DIR}/*.jar; do
|
|
|
|
CLASSPATH=${CLASSPATH}:$f;
|
|
|
|
done
|
|
|
|
|
2011-10-28 01:56:57 +00:00
|
|
|
# add libs to CLASSPATH
|
2012-01-27 23:53:35 +00:00
|
|
|
for f in $HADOOP_MAPRED_HOME/${MAPRED_LIB_JARS_DIR}/*.jar; do
|
2011-10-28 01:56:57 +00:00
|
|
|
CLASSPATH=${CLASSPATH}:$f;
|
|
|
|
done
|
|
|
|
|
2012-02-06 23:11:26 +00:00
|
|
|
# add modules to CLASSPATH
|
|
|
|
for f in $HADOOP_MAPRED_HOME/modules/*.jar; do
|
|
|
|
CLASSPATH=${CLASSPATH}:$f;
|
|
|
|
done
|
|
|
|
|
2011-10-28 01:56:57 +00:00
|
|
|
if $cygwin; then
|
|
|
|
CLASSPATH=`cygpath -p -w "$CLASSPATH"`
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$COMMAND" = "classpath" ] ; then
|
|
|
|
echo $CLASSPATH
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2012-02-06 23:11:26 +00:00
|
|
|
HADOOP_OPTS="$HADOOP_OPTS -Dhadoop.security.logger=${HADOOP_SECURITY_LOGGER:-INFO,NullAppender}"
|
2011-10-28 17:08:09 +00:00
|
|
|
|
2011-10-28 01:56:57 +00:00
|
|
|
export CLASSPATH
|
2012-02-24 23:00:17 +00:00
|
|
|
exec "$JAVA" -Dproc_$COMMAND $JAVA_HEAP_MAX $HADOOP_OPTS $CLASS "$@"
|