mapred.cmd 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  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. set service_entry=true
  31. ) else if "%1" == "--config" (
  32. if "%3" == "--service" (
  33. set service_entry=true
  34. set HADOOP_LOGFILE=mapred-%4-%computername%.log
  35. )
  36. )
  37. if defined service_entry (
  38. if not defined HADOOP_ROOT_LOGGER (
  39. set HADOOP_ROOT_LOGGER=INFO,DRFA
  40. )
  41. )
  42. set DEFAULT_LIBEXEC_DIR=%HADOOP_BIN_PATH%\..\libexec
  43. if not defined HADOOP_LIBEXEC_DIR (
  44. set HADOOP_LIBEXEC_DIR=%DEFAULT_LIBEXEC_DIR%
  45. )
  46. call %DEFAULT_LIBEXEC_DIR%\mapred-config.cmd %*
  47. if "%1" == "--config" (
  48. shift
  49. shift
  50. )
  51. if "%1" == "--service" (
  52. shift
  53. )
  54. :main
  55. if exist %MAPRED_CONF_DIR%\mapred-env.cmd (
  56. call %MAPRED_CONF_DIR%\mapred-env.cmd
  57. )
  58. set mapred-command=%1
  59. call :make_command_arguments %*
  60. if not defined mapred-command (
  61. goto print_usage
  62. )
  63. @rem JAVA and JAVA_HEAP_MAX are set in hadoop-confg.cmd
  64. if defined MAPRED_HEAPSIZE (
  65. @rem echo run with Java heapsize %MAPRED_HEAPSIZE%
  66. set JAVA_HEAP_SIZE=-Xmx%MAPRED_HEAPSIZE%m
  67. )
  68. @rem CLASSPATH initially contains HADOOP_CONF_DIR and MAPRED_CONF_DIR
  69. if not defined HADOOP_CONF_DIR (
  70. echo NO HADOOP_CONF_DIR set.
  71. echo Please specify it either in mapred-env.cmd or in the environment.
  72. goto :eof
  73. )
  74. set CLASSPATH=%HADOOP_CONF_DIR%;%MAPRED_CONF_DIR%;%CLASSPATH%
  75. @rem for developers, add Hadoop classes to CLASSPATH
  76. if exist %HADOOP_MAPRED_HOME%\build\classes (
  77. set CLASSPATH=%CLASSPATH%;%HADOOP_MAPRED_HOME%\build\classes
  78. )
  79. if exist %HADOOP_MAPRED_HOME%\build\webapps (
  80. set CLASSPATH=%CLASSPATH%;%HADOOP_MAPRED_HOME%\build
  81. )
  82. if exist %HADOOP_MAPRED_HOME%\build\test\classes (
  83. set CLASSPATH=%CLASSPATH%;%HADOOP_MAPRED_HOME%\build\test\classes
  84. )
  85. if exist %HADOOP_MAPRED_HOME%\build\tools (
  86. set CLASSPATH=%CLASSPATH%;%HADOOP_MAPRED_HOME%\build\tools
  87. )
  88. @rem Need YARN jars also
  89. set CLASSPATH=%CLASSPATH%;%HADOOP_YARN_HOME%\%YARN_DIR%\*
  90. @rem add libs to CLASSPATH
  91. set CLASSPATH=%CLASSPATH%;%HADOOP_MAPRED_HOME%\%MAPRED_LIB_JARS_DIR%\*
  92. @rem add modules to CLASSPATH
  93. set CLASSPATH=%CLASSPATH%;%HADOOP_MAPRED_HOME%\modules\*
  94. call :%mapred-command% %mapred-command-arguments%
  95. set java_arguments=%JAVA_HEAP_MAX% %HADOOP_OPTS% -classpath %CLASSPATH% %CLASS% %mapred-command-arguments%
  96. if defined service_entry (
  97. call :makeServiceXml %java_arguments%
  98. ) else (
  99. call %JAVA% %java_arguments%
  100. )
  101. goto :eof
  102. :classpath
  103. @echo %CLASSPATH%
  104. goto :eof
  105. :job
  106. set CLASS=org.apache.hadoop.mapred.JobClient
  107. set HADOOP_OPTS=%HADOOP_OPTS% %HADOOP_CLIENT_OPTS%
  108. goto :eof
  109. :queue
  110. set CLASS=org.apache.hadoop.mapred.JobQueueClient
  111. set HADOOP_OPTS=%HADOOP_OPTS% %HADOOP_CLIENT_OPTS%
  112. goto :eof
  113. :pipes
  114. set CLASS=org.apache.hadoop.mapred.pipes.Submitter
  115. set HADOOP_OPTS=%HADOOP_OPTS% %HADOOP_CLIENT_OPTS%
  116. goto :eof
  117. :sampler
  118. set CLASS=org.apache.hadoop.mapred.lib.InputSampler
  119. set HADOOP_OPTS=%HADOOP_OPTS% %HADOOP_CLIENT_OPTS%
  120. goto :eof
  121. :jobhistoryserver
  122. set CLASS=org.apache.hadoop.mapreduce.v2.hs.JobHistoryServer
  123. if not defined HADOOP_JHS_LOGGER (
  124. set HADOOP_JHS_LOGGER=INFO,console
  125. )
  126. set HADOOP_OPTS=%HADOOP_OPTS% -Dmapred.jobsummary.logger=%HADOOP_JHS_LOGGER% %HADOOP_JOB_HISTORYSERVER_OPTS%
  127. if defined HADOOP_JOB_HISTORYSERVER_HEAPSIZE (
  128. set JAVA_HEAP_MAX=-Xmx%HADOOP_JOB_HISTORYSERVER_HEAPSIZE%m
  129. )
  130. goto :eof
  131. :distcp
  132. set CLASS=org.apache.hadoop.tools.DistCp
  133. set CLASSPATH=%CLASSPATH%;%TOO_PATH%
  134. set HADOOP_OPTS=%HADOOP_OPTS% %HADOOP_CLIENT_OPTS%
  135. goto :eof
  136. :archive
  137. set CLASS=org.apache.hadop.tools.HadoopArchives
  138. set CLASSPATH=%CLASSPATH%;%TOO_PATH%
  139. set HADOOP_OPTS=%HADOOP_OPTS% %HADOOP_CLIENT_OPTS%
  140. :hsadmin
  141. set CLASS=org.apache.hadoop.mapreduce.v2.hs.client.HSAdmin
  142. set HADOOP_OPTS=%HADOOP_OPTS% %HADOOP_CLIENT_OPTS%
  143. :mradmin
  144. goto not_supported
  145. :jobtracker
  146. goto not_supported
  147. :tasktracker
  148. goto not_supported
  149. :groups
  150. goto not_supported
  151. @rem This changes %1, %2 etc. Hence those cannot be used after calling this.
  152. :make_command_arguments
  153. if [%2] == [] goto :eof
  154. if "%1" == "--config" (
  155. shift
  156. shift
  157. )
  158. if "%1" == "--service" (
  159. shift
  160. )
  161. shift
  162. set _mapredarguments=
  163. :MakeCmdArgsLoop
  164. if [%1]==[] goto :EndLoop
  165. if not defined _mapredarguments (
  166. set _mapredarguments=%1
  167. ) else (
  168. set _mapredarguments=!_mapredarguments! %1
  169. )
  170. shift
  171. goto :MakeCmdArgsLoop
  172. :EndLoop
  173. set mapred-command-arguments=%_mapredarguments%
  174. goto :eof
  175. :makeServiceXml
  176. set arguments=%*
  177. @echo ^<service^>
  178. @echo ^<id^>%mapred-command%^</id^>
  179. @echo ^<name^>%mapred-command%^</name^>
  180. @echo ^<description^>This service runs Hadoop %mapred-command%^</description^>
  181. @echo ^<executable^>%JAVA%^</executable^>
  182. @echo ^<arguments^>%arguments%^</arguments^>
  183. @echo ^</service^>
  184. goto :eof
  185. :not_supported
  186. @echo Sorry, the %COMMAND% command is no longer supported.
  187. @echo You may find similar functionality with the "yarn" shell command.
  188. goto print_usage
  189. :print_usage
  190. @echo Usage: mapred [--config confdir] COMMAND
  191. @echo where COMMAND is one of:
  192. @echo pipes run a Pipes job
  193. @echo job manipulate MapReduce jobs
  194. @echo queue get information regarding JobQueues
  195. @echo classpath prints the class path needed for running
  196. @echo mapreduce subcommands
  197. @echo jobhistoryserver run job history servers as a standalone daemon
  198. @echo distcp ^<srcurl^> ^<desturl^> copy file or directories recursively
  199. @echo archive -archiveName NAME -p ^<parent path^> ^<src^>* ^<dest^> create a hadoop archive
  200. @echo hsadmin job history server admin interface
  201. @echo
  202. @echo Most commands print help when invoked w/o parameters.
  203. endlocal