mapred 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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=`dirname "$0"`
  17. bin=`cd "$bin"; pwd`
  18. . $bin/mapred-config.sh
  19. function print_usage(){
  20. echo "Usage: mapred [--config confdir] COMMAND"
  21. echo " where COMMAND is one of:"
  22. echo " mradmin run a Map-Reduce admin client"
  23. echo " jobtracker run the MapReduce job Tracker node"
  24. echo " tasktracker run a MapReduce task Tracker node"
  25. echo " pipes run a Pipes job"
  26. echo " job manipulate MapReduce jobs"
  27. echo " queue get information regarding JobQueues"
  28. echo ""
  29. echo "Most commands print help when invoked w/o parameters."
  30. }
  31. if [ $# = 0 ]; then
  32. print_usage
  33. exit
  34. fi
  35. COMMAND=$1
  36. shift
  37. if [ "$COMMAND" = "mradmin" ] ; then
  38. CLASS=org.apache.hadoop.mapred.tools.MRAdmin
  39. HADOOP_OPTS="$HADOOP_OPTS $HADOOP_CLIENT_OPTS"
  40. elif [ "$COMMAND" = "jobtracker" ] ; then
  41. CLASS=org.apache.hadoop.mapred.JobTracker
  42. HADOOP_OPTS="$HADOOP_OPTS $HADOOP_JOBTRACKER_OPTS"
  43. elif [ "$COMMAND" = "tasktracker" ] ; then
  44. CLASS=org.apache.hadoop.mapred.TaskTracker
  45. HADOOP_OPTS="$HADOOP_OPTS $HADOOP_TASKTRACKER_OPTS"
  46. elif [ "$COMMAND" = "job" ] ; then
  47. CLASS=org.apache.hadoop.mapred.JobClient
  48. elif [ "$COMMAND" = "queue" ] ; then
  49. CLASS=org.apache.hadoop.mapred.JobQueueClient
  50. elif [ "$COMMAND" = "pipes" ] ; then
  51. CLASS=org.apache.hadoop.mapred.pipes.Submitter
  52. HADOOP_OPTS="$HADOOP_OPTS $HADOOP_CLIENT_OPTS"
  53. elif [ "$COMMAND" = "sampler" ] ; then
  54. CLASS=org.apache.hadoop.mapred.lib.InputSampler
  55. HADOOP_OPTS="$HADOOP_OPTS $HADOOP_CLIENT_OPTS"
  56. else
  57. echo $COMMAND - invalid command
  58. print_usage
  59. exit
  60. fi
  61. # for developers, add mapred classes to CLASSPATH
  62. if [ -d "$HADOOP_MAPRED_HOME/build/classes" ]; then
  63. CLASSPATH=${CLASSPATH}:$HADOOP_MAPRED_HOME/build/classes
  64. fi
  65. if [ -d "$HADOOP_MAPRED_HOME/build/webapps" ]; then
  66. CLASSPATH=${CLASSPATH}:$HADOOP_MAPRED_HOME/build
  67. fi
  68. if [ -d "$HADOOP_MAPRED_HOME/build/test/classes" ]; then
  69. CLASSPATH=${CLASSPATH}:$HADOOP_MAPRED_HOME/build/test/classes
  70. fi
  71. if [ -d "$HADOOP_MAPRED_HOME/build/tools" ]; then
  72. CLASSPATH=${CLASSPATH}:$HADOOP_MAPRED_HOME/build/tools
  73. fi
  74. # for releases, add core mapred jar & webapps to CLASSPATH
  75. if [ -d "$HADOOP_MAPRED_HOME/webapps" ]; then
  76. CLASSPATH=${CLASSPATH}:$HADOOP_MAPRED_HOME
  77. fi
  78. for f in $HADOOP_MAPRED_HOME/hadoop-mapred-*.jar; do
  79. CLASSPATH=${CLASSPATH}:$f;
  80. done
  81. # add libs to CLASSPATH
  82. for f in $HADOOP_MAPRED_HOME/lib/*.jar; do
  83. CLASSPATH=${CLASSPATH}:$f;
  84. done
  85. if $cygwin; then
  86. CLASSPATH=`cygpath -p -w "$CLASSPATH"`
  87. fi
  88. export CLASSPATH
  89. exec "$JAVA" $JAVA_HEAP_MAX $HADOOP_OPTS $CLASS "$@"