mapred.cmd 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. @echo off
  2. @rem Licensed to the Apache Software Foundation (ASF) under one or more
  3. @rem contributor license agreements. See the NOTICE file distributed with
  4. @rem this work for additional information regarding copyright ownership.
  5. @rem The ASF licenses this file to You under the Apache License, Version 2.0
  6. @rem (the "License"); you may not use this file except in compliance with
  7. @rem the License. You may obtain a copy of the License at
  8. @rem
  9. @rem http://www.apache.org/licenses/LICENSE-2.0
  10. @rem
  11. @rem Unless required by applicable law or agreed to in writing, software
  12. @rem distributed under the License is distributed on an "AS IS" BASIS,
  13. @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. @rem See the License for the specific language governing permissions and
  15. @rem limitations under the License.
  16. @rem The Hadoop mapred command script
  17. setlocal enabledelayedexpansion
  18. if not defined HADOOP_BIN_PATH (
  19. set HADOOP_BIN_PATH=%~dp0
  20. )
  21. if "%HADOOP_BIN_PATH:~`%" == "\" (
  22. set HADOOP_BIN_PATH=%HADOOP_BIN_PATH:~0,-1%
  23. )
  24. @rem Determine log file name.
  25. @rem If we're being called by --service we need to use %2.
  26. @rem If we're being called with --config and --service we need to use %4.
  27. @rem Otherwise use %1
  28. if "%1" == "--service" (
  29. set HADOOP_LOGFILE=mapred-%2-%computername%.log
  30. ) else if "%1" == "--config" (
  31. if "%3" == "--service" (
  32. set HADOOP_LOGFILE=mapred-%4-%computername%.log
  33. )
  34. )
  35. if not defined HADOOP_ROOT_LOGGER (
  36. set HADOOP_ROOT_LOGGER=INFO,DRFA
  37. )
  38. )
  39. set DEFAULT_LIBEXEC_DIR=%HADOOP_BIN_PATH%\..\libexec
  40. if not defined HADOOP_LIBEXEC_DIR (
  41. set HADOOP_LIBEXEC_DIR=%DEFAULT_LIBEXEC_DIR%
  42. )
  43. call %DEFAULT_LIBEXEC_DIR%\mapred-config.cmd %*
  44. if "%1" == "--config" (
  45. shift
  46. shift
  47. )
  48. if "%1" == "--loglevel" (
  49. shift
  50. shift
  51. )
  52. if "%1" == "--service" (
  53. set service_entry=true
  54. set HADOOP_ROOT_LOGGER=INFO,DRFA
  55. shift
  56. )
  57. :main
  58. if exist %MAPRED_CONF_DIR%\mapred-env.cmd (
  59. call %MAPRED_CONF_DIR%\mapred-env.cmd
  60. )
  61. set mapred-command=%1
  62. call :make_command_arguments %*
  63. if not defined mapred-command (
  64. goto print_usage
  65. )
  66. @rem JAVA and JAVA_HEAP_MAX are set in hadoop-confg.cmd
  67. if defined MAPRED_HEAPSIZE (
  68. @rem echo run with Java heapsize %MAPRED_HEAPSIZE%
  69. set JAVA_HEAP_SIZE=-Xmx%MAPRED_HEAPSIZE%m
  70. )
  71. @rem CLASSPATH initially contains HADOOP_CONF_DIR and MAPRED_CONF_DIR
  72. if not defined HADOOP_CONF_DIR (
  73. echo NO HADOOP_CONF_DIR set.
  74. echo Please specify it either in mapred-env.cmd or in the environment.
  75. goto :eof
  76. )
  77. set CLASSPATH=%HADOOP_CONF_DIR%;%MAPRED_CONF_DIR%;%CLASSPATH%
  78. @rem for developers, add Hadoop classes to CLASSPATH
  79. if exist %HADOOP_MAPRED_HOME%\build\classes (
  80. set CLASSPATH=%CLASSPATH%;%HADOOP_MAPRED_HOME%\build\classes
  81. )
  82. if exist %HADOOP_MAPRED_HOME%\build\webapps (
  83. set CLASSPATH=%CLASSPATH%;%HADOOP_MAPRED_HOME%\build
  84. )
  85. if exist %HADOOP_MAPRED_HOME%\build\test\classes (
  86. set CLASSPATH=%CLASSPATH%;%HADOOP_MAPRED_HOME%\build\test\classes
  87. )
  88. if exist %HADOOP_MAPRED_HOME%\build\tools (
  89. set CLASSPATH=%CLASSPATH%;%HADOOP_MAPRED_HOME%\build\tools
  90. )
  91. @rem Need YARN jars also
  92. set CLASSPATH=%CLASSPATH%;%HADOOP_YARN_HOME%\%YARN_DIR%\*
  93. @rem add libs to CLASSPATH
  94. set CLASSPATH=%CLASSPATH%;%HADOOP_MAPRED_HOME%\%MAPRED_LIB_JARS_DIR%\*
  95. @rem add modules to CLASSPATH
  96. set CLASSPATH=%CLASSPATH%;%HADOOP_MAPRED_HOME%\modules\*
  97. if %mapred-command% == classpath (
  98. if not defined mapred-command-arguments (
  99. @rem No need to bother starting up a JVM for this simple case.
  100. @echo %CLASSPATH%
  101. exit /b
  102. )
  103. )
  104. call :%mapred-command% %mapred-command-arguments%
  105. set java_arguments=%JAVA_HEAP_MAX% %HADOOP_OPTS% -classpath %CLASSPATH% %CLASS% %mapred-command-arguments%
  106. if defined service_entry (
  107. call :makeServiceXml %java_arguments%
  108. ) else (
  109. call %JAVA% %java_arguments%
  110. )
  111. goto :eof
  112. :classpath
  113. set CLASS=org.apache.hadoop.util.Classpath
  114. goto :eof
  115. :job
  116. set CLASS=org.apache.hadoop.mapred.JobClient
  117. set HADOOP_OPTS=%HADOOP_OPTS% %HADOOP_CLIENT_OPTS%
  118. goto :eof
  119. :queue
  120. set CLASS=org.apache.hadoop.mapred.JobQueueClient
  121. set HADOOP_OPTS=%HADOOP_OPTS% %HADOOP_CLIENT_OPTS%
  122. goto :eof
  123. :sampler
  124. set CLASS=org.apache.hadoop.mapred.lib.InputSampler
  125. set HADOOP_OPTS=%HADOOP_OPTS% %HADOOP_CLIENT_OPTS%
  126. goto :eof
  127. :historyserver
  128. set CLASS=org.apache.hadoop.mapreduce.v2.hs.JobHistoryServer
  129. if not defined HADOOP_JHS_LOGGER (
  130. set HADOOP_JHS_LOGGER=INFO,console
  131. )
  132. set HADOOP_OPTS=%HADOOP_OPTS% -Dmapred.jobsummary.logger=%HADOOP_JHS_LOGGER% %HADOOP_JOB_HISTORYSERVER_OPTS%
  133. if defined HADOOP_JOB_HISTORYSERVER_HEAPSIZE (
  134. set JAVA_HEAP_MAX=-Xmx%HADOOP_JOB_HISTORYSERVER_HEAPSIZE%m
  135. )
  136. goto :eof
  137. :distcp
  138. set CLASS=org.apache.hadoop.tools.DistCp
  139. set CLASSPATH=%CLASSPATH%;%TOO_PATH%
  140. set HADOOP_OPTS=%HADOOP_OPTS% %HADOOP_CLIENT_OPTS%
  141. goto :eof
  142. :archive
  143. set CLASS=org.apache.hadop.tools.HadoopArchives
  144. set CLASSPATH=%CLASSPATH%;%TOO_PATH%
  145. set HADOOP_OPTS=%HADOOP_OPTS% %HADOOP_CLIENT_OPTS%
  146. :hsadmin
  147. set CLASS=org.apache.hadoop.mapreduce.v2.hs.client.HSAdmin
  148. set HADOOP_OPTS=%HADOOP_OPTS% %HADOOP_CLIENT_OPTS%
  149. :pipes
  150. goto not_supported
  151. :mradmin
  152. goto not_supported
  153. :jobtracker
  154. goto not_supported
  155. :tasktracker
  156. goto not_supported
  157. :groups
  158. goto not_supported
  159. @rem This changes %1, %2 etc. Hence those cannot be used after calling this.
  160. :make_command_arguments
  161. if [%2] == [] goto :eof
  162. if "%1" == "--config" (
  163. shift
  164. shift
  165. )
  166. if "%1" == "--loglevel" (
  167. shift
  168. shift
  169. )
  170. if "%1" == "--service" (
  171. shift
  172. )
  173. shift
  174. set _mapredarguments=
  175. :MakeCmdArgsLoop
  176. if [%1]==[] goto :EndLoop
  177. if not defined _mapredarguments (
  178. set _mapredarguments=%1
  179. ) else (
  180. set _mapredarguments=!_mapredarguments! %1
  181. )
  182. shift
  183. goto :MakeCmdArgsLoop
  184. :EndLoop
  185. set mapred-command-arguments=%_mapredarguments%
  186. goto :eof
  187. :makeServiceXml
  188. set arguments=%*
  189. @echo ^<service^>
  190. @echo ^<id^>%mapred-command%^</id^>
  191. @echo ^<name^>%mapred-command%^</name^>
  192. @echo ^<description^>This service runs Hadoop %mapred-command%^</description^>
  193. @echo ^<executable^>%JAVA%^</executable^>
  194. @echo ^<arguments^>%arguments%^</arguments^>
  195. @echo ^</service^>
  196. goto :eof
  197. :not_supported
  198. @echo Sorry, the %COMMAND% command is no longer supported.
  199. @echo You may find similar functionality with the "yarn" shell command.
  200. goto print_usage
  201. :print_usage
  202. @echo Usage: mapred [--config confdir] [--loglevel loglevel] COMMAND
  203. @echo where COMMAND is one of:
  204. @echo job manipulate MapReduce jobs
  205. @echo queue get information regarding JobQueues
  206. @echo classpath prints the class path needed for running
  207. @echo mapreduce subcommands
  208. @echo historyserver run job history servers as a standalone daemon
  209. @echo distcp ^<srcurl^> ^<desturl^> copy file or directories recursively
  210. @echo archive -archiveName NAME -p ^<parent path^> ^<src^>* ^<dest^> create a hadoop archive
  211. @echo hsadmin job history server admin interface
  212. @echo
  213. @echo Most commands print help when invoked w/o parameters.
  214. endlocal