yarn.cmd 11 KB

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