mapred 3.7 KB

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