yarn.cmd 11 KB

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