mapred 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. #!/usr/bin/env bash
  2. # Licensed to the Apache Software Foundation (ASF) under one or more
  3. # contributor license agreements. See the NOTICE file distributed with
  4. # this work for additional information regarding copyright ownership.
  5. # The ASF licenses this file to You under the Apache License, Version 2.0
  6. # (the "License"); you may not use this file except in compliance with
  7. # the License. You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. bin=`which $0`
  17. bin=`dirname ${bin}`
  18. bin=`cd "$bin"; pwd`
  19. DEFAULT_LIBEXEC_DIR="$bin"/../libexec
  20. HADOOP_LIBEXEC_DIR=${HADOOP_LIBEXEC_DIR:-$DEFAULT_LIBEXEC_DIR}
  21. if [ -e ${HADOOP_LIBEXEC_DIR}/mapred-config.sh ]; then
  22. . ${HADOOP_LIBEXEC_DIR}/mapred-config.sh
  23. else
  24. . "$bin/mapred-config.sh"
  25. fi
  26. function print_usage(){
  27. echo "Usage: mapred [--config confdir] COMMAND"
  28. echo " where COMMAND is one of:"
  29. echo " pipes run a Pipes job"
  30. echo " job manipulate MapReduce jobs"
  31. echo " queue get information regarding JobQueues"
  32. echo " classpath prints the class path needed for running"
  33. echo " mapreduce subcommands"
  34. echo " groups get the groups which users belong to"
  35. echo ""
  36. echo "Most commands print help when invoked w/o parameters."
  37. }
  38. if [ $# = 0 ]; then
  39. print_usage
  40. exit
  41. fi
  42. COMMAND=$1
  43. shift
  44. if [ "$COMMAND" = "job" ] ; then
  45. CLASS=org.apache.hadoop.mapred.JobClient
  46. elif [ "$COMMAND" = "queue" ] ; then
  47. CLASS=org.apache.hadoop.mapred.JobQueueClient
  48. elif [ "$COMMAND" = "pipes" ] ; then
  49. CLASS=org.apache.hadoop.mapred.pipes.Submitter
  50. HADOOP_OPTS="$HADOOP_OPTS $HADOOP_CLIENT_OPTS"
  51. elif [ "$COMMAND" = "sampler" ] ; then
  52. CLASS=org.apache.hadoop.mapred.lib.InputSampler
  53. HADOOP_OPTS="$HADOOP_OPTS $HADOOP_CLIENT_OPTS"
  54. elif [ "$COMMAND" = "classpath" ] ; then
  55. echo -n
  56. elif [ "$COMMAND" = "groups" ] ; then
  57. CLASS=org.apache.hadoop.mapred.tools.GetGroups
  58. HADOOP_OPTS="$HADOOP_OPTS $HADOOP_CLIENT_OPTS"
  59. elif [ "$COMMAND" = "mradmin" ] \
  60. || [ "$COMMAND" = "jobtracker" ] \
  61. || [ "$COMMAND" = "tasktracker" ] ; then
  62. echo "Sorry, the $COMMAND command is no longer supported."
  63. echo "You may find similar functionality with the \"yarn\" shell command."
  64. print_usage
  65. exit
  66. else
  67. echo $COMMAND - invalid command
  68. print_usage
  69. exit
  70. fi
  71. # for developers, add mapred classes to CLASSPATH
  72. if [ -d "$HADOOP_MAPRED_HOME/build/classes" ]; then
  73. CLASSPATH=${CLASSPATH}:$HADOOP_MAPRED_HOME/build/classes
  74. fi
  75. if [ -d "$HADOOP_MAPRED_HOME/build/webapps" ]; then
  76. CLASSPATH=${CLASSPATH}:$HADOOP_MAPRED_HOME/build
  77. fi
  78. if [ -d "$HADOOP_MAPRED_HOME/build/test/classes" ]; then
  79. CLASSPATH=${CLASSPATH}:$HADOOP_MAPRED_HOME/build/test/classes
  80. fi
  81. if [ -d "$HADOOP_MAPRED_HOME/build/tools" ]; then
  82. CLASSPATH=${CLASSPATH}:$HADOOP_MAPRED_HOME/build/tools
  83. fi
  84. # for releases, add core mapred jar & webapps to CLASSPATH
  85. if [ -d "$HADOOP_PREFIX/share/hadoop/mapreduce/webapps" ]; then
  86. CLASSPATH=${CLASSPATH}:$HADOOP_PREFIX/share/hadoop/mapreduce
  87. fi
  88. for f in $HADOOP_MAPRED_HOME/share/hadoop-mapreduce/*.jar; do
  89. CLASSPATH=${CLASSPATH}:$f;
  90. done
  91. # add libs to CLASSPATH
  92. for f in $HADOOP_MAPRED_HOME/lib/*.jar; do
  93. CLASSPATH=${CLASSPATH}:$f;
  94. done
  95. if $cygwin; then
  96. CLASSPATH=`cygpath -p -w "$CLASSPATH"`
  97. fi
  98. if [ "$COMMAND" = "classpath" ] ; then
  99. echo $CLASSPATH
  100. exit
  101. fi
  102. #turn security logger on the jobtracker
  103. if [ $COMMAND = "jobtracker" ]; then
  104. HADOOP_OPTS="$HADOOP_OPTS -Dhadoop.security.logger=${HADOOP_SECURITY_LOGGER:-INFO,DRFAS}"
  105. else
  106. HADOOP_OPTS="$HADOOP_OPTS -Dhadoop.security.logger=${HADOOP_SECURITY_LOGGER:-INFO,NullAppender}"
  107. fi
  108. export CLASSPATH
  109. exec "$JAVA" $JAVA_HEAP_MAX $HADOOP_OPTS $CLASS "$@"