yarn.cmd 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  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. if "%1" == "--service" (
  62. set service_entry=true
  63. if not defined YARN_ROOT_LOGGER (
  64. set YARN_ROOT_LOGGER=INFO,DRFA
  65. )
  66. set YARN_LOGFILE=yarn-%2-%computername%.log
  67. shift
  68. )
  69. :main
  70. if exist %YARN_CONF_DIR%\yarn-env.cmd (
  71. call %YARN_CONF_DIR%\yarn-env.cmd
  72. )
  73. set yarn-command=%1
  74. call :make_command_arguments %*
  75. if not defined yarn-command (
  76. goto print_usage
  77. )
  78. @rem JAVA and JAVA_HEAP_MAX and set in hadoop-config.cmd
  79. if defined YARN_HEAPSIZE (
  80. @rem echo run with Java heapsize %YARN_HEAPSIZE%
  81. set JAVA_HEAP_MAX=-Xmx%YARN_HEAPSIZE%m
  82. )
  83. @rem CLASSPATH initially contains HADOOP_CONF_DIR & YARN_CONF_DIR
  84. if not defined HADOOP_CONF_DIR (
  85. echo No HADOOP_CONF_DIR set.
  86. echo Please specify it either in yarn-env.cmd or in the environment.
  87. goto :eof
  88. )
  89. set CLASSPATH=%HADOOP_CONF_DIR%;%YARN_CONF_DIR%;%CLASSPATH%
  90. @rem for developers, add Hadoop classes to CLASSPATH
  91. if exist %HADOOP_YARN_HOME%\yarn-api\target\classes (
  92. set CLASSPATH=%CLASSPATH%;%HADOOP_YARN_HOME%\yarn-api\target\classes
  93. )
  94. if exist %HADOOP_YARN_HOME%\yarn-common\target\classes (
  95. set CLASSPATH=%CLASSPATH%;%HADOOP_YARN_HOME%\yarn-common\target\classes
  96. )
  97. if exist %HADOOP_YARN_HOME%\yarn-mapreduce\target\classes (
  98. set CLASSPATH=%CLASSPATH%;%HADOOP_YARN_HOME%\yarn-mapreduce\target\classes
  99. )
  100. if exist %HADOOP_YARN_HOME%\yarn-master-worker\target\classes (
  101. set CLASSPATH=%CLASSPATH%;%HADOOP_YARN_HOME%\yarn-master-worker\target\classes
  102. )
  103. if exist %HADOOP_YARN_HOME%\yarn-server\yarn-server-nodemanager\target\classes (
  104. set CLASSPATH=%CLASSPATH%;%HADOOP_YARN_HOME%\yarn-server\yarn-server-nodemanager\target\classes
  105. )
  106. if exist %HADOOP_YARN_HOME%\yarn-server\yarn-server-common\target\classes (
  107. set CLASSPATH=%CLASSPATH%;%HADOOP_YARN_HOME%\yarn-server\yarn-server-common\target\classes
  108. )
  109. if exist %HADOOP_YARN_HOME%\yarn-server\yarn-server-resourcemanager\target\classes (
  110. set CLASSPATH=%CLASSPATH%;%HADOOP_YARN_HOME%\yarn-server\yarn-server-resourcemanager\target\classes
  111. )
  112. if exist %HADOOP_YARN_HOME%\yarn-server\yarn-server-applicationhistoryservice\target\classes (
  113. set CLASSPATH=%CLASSPATH%;%HADOOP_YARN_HOME%\yarn-server\yarn-server-applicationhistoryservice\target\classes
  114. )
  115. if exist %HADOOP_YARN_HOME%\build\test\classes (
  116. set CLASSPATH=%CLASSPATH%;%HADOOP_YARN_HOME%\build\test\classes
  117. )
  118. if exist %HADOOP_YARN_HOME%\build\tools (
  119. set CLASSPATH=%CLASSPATH%;%HADOOP_YARN_HOME%\build\tools
  120. )
  121. set CLASSPATH=%CLASSPATH%;%HADOOP_YARN_HOME%\%YARN_DIR%\*
  122. set CLASSPATH=%CLASSPATH%;%HADOOP_YARN_HOME%\%YARN_LIB_JARS_DIR%\*
  123. if %yarn-command% == classpath (
  124. @echo %CLASSPATH%
  125. goto :eof
  126. )
  127. set yarncommands=resourcemanager nodemanager proxyserver rmadmin version jar ^
  128. application applicationattempt container node logs daemonlog historyserver ^
  129. timelineserver cluster queue
  130. for %%i in ( %yarncommands% ) do (
  131. if %yarn-command% == %%i set yarncommand=true
  132. )
  133. if defined yarncommand (
  134. call :%yarn-command%
  135. ) else (
  136. set CLASSPATH=%CLASSPATH%;%CD%
  137. set CLASS=%yarn-command%
  138. )
  139. if defined JAVA_LIBRARY_PATH (
  140. set YARN_OPTS=%YARN_OPTS% -Djava.library.path=%JAVA_LIBRARY_PATH%
  141. )
  142. set java_arguments=%JAVA_HEAP_MAX% %YARN_OPTS% -classpath %CLASSPATH% %CLASS% %yarn-command-arguments%
  143. if defined service_entry (
  144. call :makeServiceXml %java_arguments%
  145. ) else (
  146. call %JAVA% %java_arguments%
  147. )
  148. goto :eof
  149. :classpath
  150. @echo %CLASSPATH%
  151. goto :eof
  152. :rmadmin
  153. set CLASS=org.apache.hadoop.yarn.client.cli.RMAdminCLI
  154. set YARN_OPTS=%YARN_OPTS% %YARN_CLIENT_OPTS%
  155. goto :eof
  156. :application
  157. set CLASS=org.apache.hadoop.yarn.client.cli.ApplicationCLI
  158. set YARN_OPTS=%YARN_OPTS% %YARN_CLIENT_OPTS%
  159. set yarn-command-arguments=%yarn-command% %yarn-command-arguments%
  160. goto :eof
  161. :applicationattempt
  162. set CLASS=org.apache.hadoop.yarn.client.cli.ApplicationCLI
  163. set YARN_OPTS=%YARN_OPTS% %YARN_CLIENT_OPTS%
  164. set yarn-command-arguments=%yarn-command% %yarn-command-arguments%
  165. goto :eof
  166. :container
  167. set CLASS=org.apache.hadoop.yarn.client.cli.ApplicationCLI
  168. set YARN_OPTS=%YARN_OPTS% %YARN_CLIENT_OPTS%
  169. set yarn-command-arguments=%yarn-command% %yarn-command-arguments%
  170. goto :eof
  171. :node
  172. set CLASS=org.apache.hadoop.yarn.client.cli.NodeCLI
  173. set YARN_OPTS=%YARN_OPTS% %YARN_CLIENT_OPTS%
  174. goto :eof
  175. :cluster
  176. set CLASS=org.apache.hadoop.yarn.client.cli.ClusterCLI
  177. set YARN_OPTS=%YARN_OPTS% %YARN_CLIENT_OPTS%
  178. goto :eof
  179. :queue
  180. set CLASS=org.apache.hadoop.yarn.client.cli.QueueCLI
  181. set YARN_OPTS=%YARN_OPTS% %YARN_CLIENT_OPTS%
  182. goto :eof
  183. :historyserver
  184. @echo DEPRECATED: Use of this command to start the timeline server is deprecated. 1>&2
  185. @echo Instead use the timelineserver command for it. 1>&2
  186. set CLASSPATH=%CLASSPATH%;%YARN_CONF_DIR%\ahs-config\log4j.properties
  187. set CLASS=org.apache.hadoop.yarn.server.applicationhistoryservice.ApplicationHistoryServer
  188. set YARN_OPTS=%YARN_OPTS% %HADOOP_HISTORYSERVER_OPTS%
  189. if defined YARN_HISTORYSERVER_HEAPSIZE (
  190. set JAVA_HEAP_MAX=-Xmx%YARN_HISTORYSERVER_HEAPSIZE%m
  191. )
  192. goto :eof
  193. :timelineserver
  194. set CLASSPATH=%CLASSPATH%;%YARN_CONF_DIR%\timelineserver-config\log4j.properties
  195. set CLASS=org.apache.hadoop.yarn.server.applicationhistoryservice.ApplicationHistoryServer
  196. set YARN_OPTS=%YARN_OPTS% %HADOOP_TIMELINESERVER_OPTS%
  197. if defined YARN_TIMELINESERVER_HEAPSIZE (
  198. set JAVA_HEAP_MAX=-Xmx%YARN_TIMELINESERVER_HEAPSIZE%m
  199. )
  200. goto :eof
  201. :nodemanager
  202. set CLASSPATH=%CLASSPATH%;%YARN_CONF_DIR%\nm-config\log4j.properties
  203. set CLASS=org.apache.hadoop.yarn.server.nodemanager.NodeManager
  204. set YARN_OPTS=%YARN_OPTS% -server %HADOOP_NODEMANAGER_OPTS%
  205. if defined YARN_NODEMANAGER_HEAPSIZE (
  206. set JAVA_HEAP_MAX=-Xmx%YARN_NODEMANAGER_HEAPSIZE%m
  207. )
  208. goto :eof
  209. :resourcemanager
  210. set CLASSPATH=%CLASSPATH%;%YARN_CONF_DIR%\rm-config\log4j.properties
  211. set CLASS=org.apache.hadoop.yarn.server.resourcemanager.ResourceManager
  212. set YARN_OPTS=%YARN_OPTS% %YARN_RESOURCEMANAGER_OPTS%
  213. if defined YARN_RESOURCEMANAGER_HEAPSIZE (
  214. set JAVA_HEAP_MAX=-Xmx%YARN_RESOURCEMANAGER_HEAPSIZE%m
  215. )
  216. goto :eof
  217. :proxyserver
  218. set CLASS=org.apache.hadoop.yarn.server.webproxy.WebAppProxyServer
  219. set YARN_OPTS=%YARN_OPTS% %HADOOP_PROXYSERVER_OPTS%
  220. if defined YARN_PROXYSERVER_HEAPSIZE (
  221. set JAVA_HEAP_MAX=-Xmx%YARN_PROXYSERVER_HEAPSIZE%m
  222. )
  223. goto :eof
  224. :version
  225. set CLASS=org.apache.hadoop.util.VersionInfo
  226. set YARN_OPTS=%YARN_OPTS% %YARN_CLIENT_OPTS%
  227. goto :eof
  228. :jar
  229. set CLASS=org.apache.hadoop.util.RunJar
  230. set YARN_OPTS=%YARN_OPTS% %YARN_CLIENT_OPTS%
  231. goto :eof
  232. :logs
  233. set CLASS=org.apache.hadoop.yarn.client.cli.LogsCLI
  234. set YARN_OPTS=%YARN_OPTS% %YARN_CLIENT_OPTS%
  235. goto :eof
  236. :daemonlog
  237. set CLASS=org.apache.hadoop.log.LogLevel
  238. set YARN_OPTS=%YARN_OPTS% %YARN_CLIENT_OPTS%
  239. goto :eof
  240. :makeServiceXml
  241. set arguments=%*
  242. @echo ^<service^>
  243. @echo ^<id^>%yarn-command%^</id^>
  244. @echo ^<name^>%yarn-command%^</name^>
  245. @echo ^<description^>This service runs Hadoop %yarn-command%^</description^>
  246. @echo ^<executable^>%JAVA%^</executable^>
  247. @echo ^<arguments^>%arguments%^</arguments^>
  248. @echo ^</service^>
  249. goto :eof
  250. @rem This changes %1, %2 etc. Hence those cannot be used after calling this.
  251. :make_command_arguments
  252. if [%2] == [] goto :eof
  253. if "%1" == "--config" (
  254. shift
  255. shift
  256. )
  257. if "%1" == "--service" (
  258. shift
  259. )
  260. shift
  261. set _yarnarguments=
  262. :MakeCmdArgsLoop
  263. if [%1]==[] goto :EndLoop
  264. if not defined _yarnarguments (
  265. set _yarnarguments=%1
  266. ) else (
  267. set _yarnarguments=!_yarnarguments! %1
  268. )
  269. shift
  270. goto :MakeCmdArgsLoop
  271. :EndLoop
  272. set yarn-command-arguments=%_yarnarguments%
  273. goto :eof
  274. :print_usage
  275. @echo Usage: yarn [--config confdir] COMMAND
  276. @echo where COMMAND is one of:
  277. @echo resourcemanager run the ResourceManager
  278. @echo nodemanager run a nodemanager on each slave
  279. @echo timelineserver run the timeline server
  280. @echo rmadmin admin tools
  281. @echo version print the version
  282. @echo jar ^<jar^> run a jar file
  283. @echo application prints application(s) report/kill application
  284. @echo applicationattempt prints applicationattempt(s) report
  285. @echo container prints container(s) report
  286. @echo node prints node report(s)
  287. @echo cluster print cluster information
  288. @echo queue prints queue information
  289. @echo logs dump container logs
  290. @echo classpath prints the class path needed to get the
  291. @echo Hadoop jar and the required libraries
  292. @echo daemonlog get/set the log level for each daemon
  293. @echo or
  294. @echo CLASSNAME run the class named CLASSNAME
  295. @echo Most commands print help when invoked w/o parameters.
  296. endlocal