yarn.cmd 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  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 command script
  17. @rem
  18. @rem Environment Variables
  19. @rem
  20. @rem JAVA_HOME The java implementation to use. Overrides JAVA_HOME.
  21. @rem
  22. @rem YARN_CLASSPATH Extra Java CLASSPATH entries.
  23. @rem
  24. @rem YARN_HEAPSIZE The maximum amount of heap to use, in MB.
  25. @rem Default is 1000.
  26. @rem
  27. @rem YARN_{COMMAND}_HEAPSIZE overrides YARN_HEAPSIZE for a given command
  28. @rem eg YARN_NODEMANAGER_HEAPSIZE sets the heap
  29. @rem size for the NodeManager. If you set the
  30. @rem heap size in YARN_{COMMAND}_OPTS or YARN_OPTS
  31. @rem they take precedence.
  32. @rem
  33. @rem YARN_OPTS Extra Java runtime options.
  34. @rem
  35. @rem YARN_CLIENT_OPTS when the respective command is run.
  36. @rem YARN_{COMMAND}_OPTS etc YARN_NODEMANAGER_OPTS applies to NodeManager
  37. @rem for e.g. YARN_CLIENT_OPTS applies to
  38. @rem more than one command (fs, dfs, fsck,
  39. @rem dfsadmin etc)
  40. @rem
  41. @rem YARN_CONF_DIR Alternate conf dir. Default is ${HADOOP_YARN_HOME}/conf.
  42. @rem
  43. @rem YARN_ROOT_LOGGER The root appender. Default is INFO,console
  44. @rem
  45. setlocal enabledelayedexpansion
  46. if not defined HADOOP_BIN_PATH (
  47. set HADOOP_BIN_PATH=%~dp0
  48. )
  49. if "%HADOOP_BIN_PATH:~-1%" == "\" (
  50. set HADOOP_BIN_PATH=%HADOOP_BIN_PATH:~0,-1%
  51. )
  52. set DEFAULT_LIBEXEC_DIR=%HADOOP_BIN_PATH%\..\libexec
  53. if not defined HADOOP_LIBEXEC_DIR (
  54. set HADOOP_LIBEXEC_DIR=%DEFAULT_LIBEXEC_DIR%
  55. )
  56. call %DEFAULT_LIBEXEC_DIR%\yarn-config.cmd %*
  57. if "%1" == "--config" (
  58. shift
  59. shift
  60. )
  61. :main
  62. if exist %YARN_CONF_DIR%\yarn-env.cmd (
  63. call %YARN_CONF_DIR%\yarn-env.cmd
  64. )
  65. set yarn-command=%1
  66. call :make_command_arguments %*
  67. if not defined yarn-command (
  68. goto print_usage
  69. )
  70. @rem JAVA and JAVA_HEAP_MAX and set in hadoop-config.cmd
  71. if defined YARN_HEAPSIZE (
  72. @rem echo run with Java heapsize %YARN_HEAPSIZE%
  73. set JAVA_HEAP_MAX=-Xmx%YARN_HEAPSIZE%m
  74. )
  75. @rem CLASSPATH initially contains HADOOP_CONF_DIR & YARN_CONF_DIR
  76. if not defined HADOOP_CONF_DIR (
  77. echo No HADOOP_CONF_DIR set.
  78. echo Please specify it either in yarn-env.cmd or in the environment.
  79. goto :eof
  80. )
  81. set CLASSPATH=%HADOOP_CONF_DIR%;%YARN_CONF_DIR%;%CLASSPATH%
  82. @rem for developers, add Hadoop classes to CLASSPATH
  83. if exist %HADOOP_YARN_HOME%\yarn-api\target\classes (
  84. set CLASSPATH=%CLASSPATH%;%HADOOP_YARN_HOME%\yarn-api\target\classes
  85. )
  86. if exist %HADOOP_YARN_HOME%\yarn-common\target\classes (
  87. set CLASSPATH=%CLASSPATH%;%HADOOP_YARN_HOME%\yarn-common\target\classes
  88. )
  89. if exist %HADOOP_YARN_HOME%\yarn-mapreduce\target\classes (
  90. set CLASSPATH=%CLASSPATH%;%HADOOP_YARN_HOME%\yarn-mapreduce\target\classes
  91. )
  92. if exist %HADOOP_YARN_HOME%\yarn-master-worker\target\classes (
  93. set CLASSPATH=%CLASSPATH%;%HADOOP_YARN_HOME%\yarn-master-worker\target\classes
  94. )
  95. if exist %HADOOP_YARN_HOME%\yarn-server\yarn-server-nodemanager\target\classes (
  96. set CLASSPATH=%CLASSPATH%;%HADOOP_YARN_HOME%\yarn-server\yarn-server-nodemanager\target\classes
  97. )
  98. if exist %HADOOP_YARN_HOME%\yarn-server\yarn-server-common\target\classes (
  99. set CLASSPATH=%CLASSPATH%;%HADOOP_YARN_HOME%\yarn-server\yarn-server-common\target\classes
  100. )
  101. if exist %HADOOP_YARN_HOME%\yarn-server\yarn-server-resourcemanager\target\classes (
  102. set CLASSPATH=%CLASSPATH%;%HADOOP_YARN_HOME%\yarn-server\yarn-server-resourcemanager\target\classes
  103. )
  104. if exist %HADOOP_YARN_HOME%\yarn-server\yarn-server-applicationhistoryservice\target\classes (
  105. set CLASSPATH=%CLASSPATH%;%HADOOP_YARN_HOME%\yarn-server\yarn-server-applicationhistoryservice\target\classes
  106. )
  107. if exist %HADOOP_YARN_HOME%\build\test\classes (
  108. set CLASSPATH=%CLASSPATH%;%HADOOP_YARN_HOME%\build\test\classes
  109. )
  110. if exist %HADOOP_YARN_HOME%\build\tools (
  111. set CLASSPATH=%CLASSPATH%;%HADOOP_YARN_HOME%\build\tools
  112. )
  113. set CLASSPATH=%CLASSPATH%;%HADOOP_YARN_HOME%\%YARN_DIR%\*
  114. set CLASSPATH=%CLASSPATH%;%HADOOP_YARN_HOME%\%YARN_LIB_JARS_DIR%\*
  115. if %yarn-command% == classpath (
  116. @echo %CLASSPATH%
  117. goto :eof
  118. )
  119. set yarncommands=resourcemanager nodemanager proxyserver rmadmin version jar ^
  120. application applicationattempt container node logs daemonlog historyserver ^
  121. timelineserver
  122. for %%i in ( %yarncommands% ) do (
  123. if %yarn-command% == %%i set yarncommand=true
  124. )
  125. if defined yarncommand (
  126. call :%yarn-command%
  127. ) else (
  128. set CLASSPATH=%CLASSPATH%;%CD%
  129. set CLASS=%yarn-command%
  130. )
  131. if defined JAVA_LIBRARY_PATH (
  132. set YARN_OPTS=%YARN_OPTS% -Djava.library.path=%JAVA_LIBRARY_PATH%
  133. )
  134. set java_arguments=%JAVA_HEAP_MAX% %YARN_OPTS% -classpath %CLASSPATH% %CLASS% %yarn-command-arguments%
  135. call %JAVA% %java_arguments%
  136. goto :eof
  137. :classpath
  138. @echo %CLASSPATH%
  139. goto :eof
  140. :rmadmin
  141. set CLASS=org.apache.hadoop.yarn.client.cli.RMAdminCLI
  142. set YARN_OPTS=%YARN_OPTS% %YARN_CLIENT_OPTS%
  143. goto :eof
  144. :application
  145. set CLASS=org.apache.hadoop.yarn.client.cli.ApplicationCLI
  146. set YARN_OPTS=%YARN_OPTS% %YARN_CLIENT_OPTS%
  147. set yarn-command-arguments=%yarn-command% %yarn-command-arguments%
  148. goto :eof
  149. :applicationattempt
  150. set CLASS=org.apache.hadoop.yarn.client.cli.ApplicationCLI
  151. set YARN_OPTS=%YARN_OPTS% %YARN_CLIENT_OPTS%
  152. set yarn-command-arguments=%yarn-command% %yarn-command-arguments%
  153. goto :eof
  154. :container
  155. set CLASS=org.apache.hadoop.yarn.client.cli.ApplicationCLI
  156. set YARN_OPTS=%YARN_OPTS% %YARN_CLIENT_OPTS%
  157. set yarn-command-arguments=%yarn-command% %yarn-command-arguments%
  158. goto :eof
  159. :node
  160. set CLASS=org.apache.hadoop.yarn.client.cli.NodeCLI
  161. set YARN_OPTS=%YARN_OPTS% %YARN_CLIENT_OPTS%
  162. goto :eof
  163. :queue
  164. set CLASS=org.apache.hadoop.yarn.client.cli.QueueCLI
  165. set YARN_OPTS=%YARN_OPTS% %YARN_CLIENT_OPTS%
  166. goto :eof
  167. :resourcemanager
  168. set CLASSPATH=%CLASSPATH%;%YARN_CONF_DIR%\rm-config\log4j.properties
  169. set CLASS=org.apache.hadoop.yarn.server.resourcemanager.ResourceManager
  170. set YARN_OPTS=%YARN_OPTS% %YARN_RESOURCEMANAGER_OPTS%
  171. if defined YARN_RESOURCEMANAGER_HEAPSIZE (
  172. set JAVA_HEAP_MAX=-Xmx%YARN_RESOURCEMANAGER_HEAPSIZE%m
  173. )
  174. goto :eof
  175. :historyserver
  176. @echo DEPRECATED: Use of this command to start the timeline server is deprecated. 1>&2
  177. @echo Instead use the timelineserver command for it. 1>&2
  178. set CLASSPATH=%CLASSPATH%;%YARN_CONF_DIR%\ahs-config\log4j.properties
  179. set CLASS=org.apache.hadoop.yarn.server.applicationhistoryservice.ApplicationHistoryServer
  180. set YARN_OPTS=%YARN_OPTS% %HADOOP_HISTORYSERVER_OPTS%
  181. if defined YARN_HISTORYSERVER_HEAPSIZE (
  182. set JAVA_HEAP_MAX=-Xmx%YARN_HISTORYSERVER_HEAPSIZE%m
  183. )
  184. goto :eof
  185. :timelineserver
  186. set CLASSPATH=%CLASSPATH%;%YARN_CONF_DIR%\timelineserver-config\log4j.properties
  187. set CLASS=org.apache.hadoop.yarn.server.applicationhistoryservice.ApplicationHistoryServer
  188. set YARN_OPTS=%YARN_OPTS% %HADOOP_TIMELINESERVER_OPTS%
  189. if defined YARN_TIMELINESERVER_HEAPSIZE (
  190. set JAVA_HEAP_MAX=-Xmx%YARN_TIMELINESERVER_HEAPSIZE%m
  191. )
  192. goto :eof
  193. :nodemanager
  194. set CLASSPATH=%CLASSPATH%;%YARN_CONF_DIR%\nm-config\log4j.properties
  195. set CLASS=org.apache.hadoop.yarn.server.nodemanager.NodeManager
  196. set YARN_OPTS=%YARN_OPTS% -server %HADOOP_NODEMANAGER_OPTS%
  197. if defined YARN_NODEMANAGER_HEAPSIZE (
  198. set JAVA_HEAP_MAX=-Xmx%YARN_NODEMANAGER_HEAPSIZE%m
  199. )
  200. goto :eof
  201. :proxyserver
  202. set CLASS=org.apache.hadoop.yarn.server.webproxy.WebAppProxyServer
  203. set YARN_OPTS=%YARN_OPTS% %HADOOP_PROXYSERVER_OPTS%
  204. if defined YARN_PROXYSERVER_HEAPSIZE (
  205. set JAVA_HEAP_MAX=-Xmx%YARN_PROXYSERVER_HEAPSIZE%m
  206. )
  207. goto :eof
  208. :version
  209. set CLASS=org.apache.hadoop.util.VersionInfo
  210. set YARN_OPTS=%YARN_OPTS% %YARN_CLIENT_OPTS%
  211. goto :eof
  212. :jar
  213. set CLASS=org.apache.hadoop.util.RunJar
  214. set YARN_OPTS=%YARN_OPTS% %YARN_CLIENT_OPTS%
  215. goto :eof
  216. :logs
  217. set CLASS=org.apache.hadoop.yarn.client.cli.LogsCLI
  218. set YARN_OPTS=%YARN_OPTS% %YARN_CLIENT_OPTS%
  219. goto :eof
  220. :daemonlog
  221. set CLASS=org.apache.hadoop.log.LogLevel
  222. set YARN_OPTS=%YARN_OPTS% %YARN_CLIENT_OPTS%
  223. goto :eof
  224. @rem This changes %1, %2 etc. Hence those cannot be used after calling this.
  225. :make_command_arguments
  226. if "%1" == "--config" (
  227. shift
  228. shift
  229. )
  230. if [%2] == [] goto :eof
  231. shift
  232. set _yarnarguments=
  233. :MakeCmdArgsLoop
  234. if [%1]==[] goto :EndLoop
  235. if not defined _yarnarguments (
  236. set _yarnarguments=%1
  237. ) else (
  238. set _yarnarguments=!_yarnarguments! %1
  239. )
  240. shift
  241. goto :MakeCmdArgsLoop
  242. :EndLoop
  243. set yarn-command-arguments=%_yarnarguments%
  244. goto :eof
  245. :print_usage
  246. @echo Usage: yarn [--config confdir] COMMAND
  247. @echo where COMMAND is one of:
  248. @echo resourcemanager run the ResourceManager
  249. @echo nodemanager run a nodemanager on each slave
  250. @echo timelineserver run the timeline server
  251. @echo rmadmin admin tools
  252. @echo version print the version
  253. @echo jar ^<jar^> run a jar file
  254. @echo application prints application(s) report/kill application
  255. @echo applicationattempt prints applicationattempt(s) report
  256. @echo container prints container(s) report
  257. @echo node prints node report(s)
  258. @echo queue prints queue information
  259. @echo logs dump container logs
  260. @echo classpath prints the class path needed to get the
  261. @echo Hadoop jar and the required libraries
  262. @echo daemonlog get/set the log level for each daemon
  263. @echo or
  264. @echo CLASSNAME run the class named CLASSNAME
  265. @echo Most commands print help when invoked w/o parameters.
  266. endlocal