mapred 3.6 KB

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