Advertisement
Guest User

storm-cmd

a guest
Jan 30th, 2015
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.79 KB | None | 0 0
  1. @echo off
  2.  
  3. @rem Licensed to the Apache Software Foundation (ASF) under one
  4. @rem or more contributor license agreements. See the NOTICE file
  5. @rem distributed with this work for additional information
  6. @rem regarding copyright ownership. The ASF licenses this file
  7. @rem to you under the Apache License, Version 2.0 (the
  8. @rem "License"); you may not use this file except in compliance
  9. @rem with the License. You may obtain a copy of the License at
  10. @rem
  11. @rem http://www.apache.org/licenses/LICENSE-2.0
  12. @rem
  13. @rem Unless required by applicable law or agreed to in writing, software
  14. @rem distributed under the License is distributed on an "AS IS" BASIS,
  15. @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. @rem See the License for the specific language governing permissions and
  17. @rem limitations under the License.
  18.  
  19. @rem The storm command script
  20. @rem
  21. @rem Environment Variables
  22. @rem
  23. @rem JAVA_HOME The java implementation to use. Overrides JAVA_HOME.
  24. @rem
  25. @rem STORM_CLASSPATH Extra Java CLASSPATH entries.
  26. @rem
  27. @rem STORM_HEAPSIZE The maximum amount of heap to use, in MB.
  28. @rem Default is 1000.
  29. @rem
  30. @rem STORM_OPTS Extra Java runtime options.
  31. @rem
  32. @rem STORM_CONF_DIR Alternate conf dir. Default is ${STORM_HOME}/conf.
  33. @rem
  34. @rem STORM_ROOT_LOGGER The root appender. Default is INFO,console
  35. @rem
  36.  
  37. :main
  38. setlocal enabledelayedexpansion
  39.  
  40. call %~dp0storm-config.cmd
  41.  
  42. set storm-command=%1
  43. if not defined storm-command (
  44. goto print_usage
  45. )
  46.  
  47. call :make_command_arguments %*
  48.  
  49. set shellcommands=classpath help version
  50. for %%i in ( %shellcommands% ) do (
  51. if %storm-command% == %%i set shellcommand=true
  52. )
  53. if defined shellcommand (
  54. call :%storm-command% %*
  55. goto :eof
  56. )
  57.  
  58. set corecommands=activate deactivate dev-zookeeper drpc kill list nimbus logviewer rebalance remoteconfvalue repl shell supervisor ui
  59. for %%i in ( %corecommands% ) do (
  60. if %storm-command% == %%i set corecommand=true
  61. )
  62. if defined corecommand (
  63. call :%storm-command% %storm-command-arguments%
  64. ) else (
  65. set CLASS=%storm-command%
  66. )
  67.  
  68. if %storm-command% == jar (
  69. set STORM_OPTS=%STORM_CLIENT_OPTS% %STORM_OPTS% -Dstorm.jar=%2
  70. set CLASSPATH=%CLASSPATH%;%2
  71. set CLASS=%3
  72. set args=%4
  73. shift
  74. :start
  75. if [%4] == [] goto done
  76. set args=%args% %4
  77. shift
  78. goto start
  79.  
  80. :done
  81. set storm-command-arguments=%args%
  82. )
  83.  
  84. if not defined STORM_LOG_FILE (
  85. set STORM_LOG_FILE=-Dlogfile.name=%storm-command%.log
  86. )
  87.  
  88. if defined STORM_DEBUG (
  89. %JAVA% %JAVA_HEAP_MAX% %STORM_OPTS% %STORM_LOG_FILE% %CLASS% %storm-command-arguments%
  90. )
  91. set path=%PATH%;%STORM_BIN_DIR%;%STORM_SBIN_DIR%
  92. call start /b %JAVA% %JAVA_HEAP_MAX% %STORM_OPTS% %STORM_LOG_FILE% %CLASS% %storm-command-arguments%
  93. goto :eof
  94.  
  95.  
  96. :activate
  97. set CLASS=backtype.storm.command.activate
  98. set STORM_OPTS=%STORM_CLIENT_OPTS% %STORM_OPTS%
  99. goto :eof
  100.  
  101. :classpath
  102. echo %CLASSPATH%
  103. goto :eof
  104.  
  105. :deactivate
  106. set CLASS=backtype.storm.command.deactivate
  107. set STORM_OPTS=%STORM_CLIENT_OPTS% %STORM_OPTS%
  108. goto :eof
  109.  
  110. :dev-zookeeper
  111. set CLASS=backtype.storm.command.dev_zookeeper
  112. set STORM_OPTS=%STORM_SERVER_OPTS% %STORM_OPTS%
  113. goto :eof
  114.  
  115. :drpc
  116. set CLASS=backtype.storm.daemon.drpc
  117. %JAVA% -client -Dstorm.options= -Dstorm.conf.file= -cp %CLASSPATH% backtype.storm.command.config_value drpc.childopts > temp.txt
  118. FOR /F "delims=" %%i in (temp.txt) do (
  119. FOR /F "tokens=1,* delims= " %%a in ("%%i") do (
  120. if %%a == VALUE: (
  121. set CHILDOPTS=%%b
  122. call :set_childopts)
  123. )
  124. )
  125. goto :eof
  126.  
  127. :help
  128. call :print_usage
  129. goto :eof
  130.  
  131. :kill
  132. set CLASS=backtype.storm.command.kill_topology
  133. set STORM_OPTS=%STORM_CLIENT_OPTS% %STORM_OPTS%
  134. goto :eof
  135.  
  136. :list
  137. set CLASS=backtype.storm.command.list
  138. set STORM_OPTS=%STORM_CLIENT_OPTS% %STORM_OPTS%
  139. goto :eof
  140.  
  141. :logviewer
  142. set CLASS=backtype.storm.daemon.logviewer
  143. %JAVA% -client -Dstorm.options= -Dstorm.conf.file= -cp %CLASSPATH% backtype.storm.command.config_value logviewer.childopts > temp.txt
  144. FOR /F "delims=" %%i in (temp.txt) do (
  145. FOR /F "tokens=1,* delims= " %%a in ("%%i") do (
  146. if %%a == VALUE: (
  147. set CHILDOPTS=%%b
  148. call :set_childopts)
  149. )
  150. )
  151. goto :eof
  152.  
  153. :nimbus
  154. set CLASS=backtype.storm.daemon.nimbus
  155. %JAVA% -client -Dstorm.options= -Dstorm.conf.file= -cp %CLASSPATH% backtype.storm.command.config_value nimbus.childopts > temp.txt
  156. FOR /F "delims=" %%i in (temp.txt) do (
  157. FOR /F "tokens=1,* delims= " %%a in ("%%i") do (
  158. if %%a == VALUE: (
  159. set CHILDOPTS=%%b
  160. call :set_childopts)
  161. )
  162. )
  163. goto :eof
  164.  
  165. :rebalance
  166. set CLASS=backtype.storm.command.rebalance
  167. set STORM_OPTS=%STORM_CLIENT_OPTS% %STORM_OPTS%
  168. goto :eof
  169.  
  170. :remoteconfvalue
  171. set CLASS=backtype.storm.command.config_value
  172. set STORM_OPTS=%STORM_CLIENT_OPTS% %STORM_OPTS%
  173. goto :eof
  174.  
  175. :repl
  176. set CLASS=clojure.main
  177. set STORM_OPTS=%STORM_CLIENT_OPTS% %STORM_OPTS%
  178. goto :eof
  179.  
  180. :shell
  181. set CLASS=backtype.storm.command.shell_submission
  182. set STORM_OPTS=%STORM_CLIENT_OPTS% %STORM_OPTS%
  183. goto :eof
  184.  
  185. :supervisor
  186. set CLASS=backtype.storm.daemon.supervisor
  187. %JAVA% -client -Dstorm.options= -Dstorm.conf.file= -cp %CLASSPATH% backtype.storm.command.config_value supervisor.childopts > temp.txt
  188. FOR /F "delims=" %%i in (temp.txt) do (
  189. FOR /F "tokens=1,* delims= " %%a in ("%%i") do (
  190. if %%a == VALUE: (
  191. set CHILDOPTS=%%b
  192. call :set_childopts)
  193. )
  194. )
  195. goto :eof
  196.  
  197. :ui
  198. set CLASS=backtype.storm.ui.core
  199. set CLASSPATH=%CLASSPATH%;%STORM_HOME%
  200. %JAVA% -client -Dstorm.options= -Dstorm.conf.file= -cp %CLASSPATH% backtype.storm.command.config_value ui.childopts > temp.txt
  201. FOR /F "delims=" %%i in (temp.txt) do (
  202. FOR /F "tokens=1,* delims= " %%a in ("%%i") do (
  203. if %%a == VALUE: (
  204. set CHILDOPTS=%%b
  205. call :set_childopts)
  206. )
  207. )
  208. goto :eof
  209.  
  210. :version
  211. type %STORM_HOME%\RELEASE
  212. goto :eof
  213.  
  214. :make_command_arguments
  215. if "%2" == "" goto :eof
  216. set _count=0
  217. set _shift=1
  218. for %%i in (%*) do (
  219. set /a _count=!_count!+1
  220. if !_count! GTR %_shift% (
  221. if not defined _arguments (
  222. set _arguments=%%i
  223. ) else (
  224. set _arguments=!_arguments! %%i
  225. )
  226. )
  227. )
  228. set storm-command-arguments=%_arguments%
  229. goto :eof
  230.  
  231. :set_childopts
  232. set STORM_OPTS=%STORM_SERVER_OPTS% %STORM_OPTS% %CHILDOPTS%
  233. del /F temp.txt
  234. goto :eof
  235.  
  236. :print_usage
  237. @echo Usage: storm COMMAND
  238. @echo where COMMAND is one of:
  239. @echo activate activates the specified topology's spouts
  240. @echo classpath prints the classpath used by the storm client when running commands
  241. @echo deactivate deactivates the specified topology's spouts
  242. @echo dev-zookeeper launches a fresh dev/test Zookeeper server
  243. @echo drpc launches a DRPC daemon
  244. @echo help
  245. @echo jar ^<jar^> run a jar file
  246. @echo kill kills the topology with the name topology-name
  247. @echo list list the running topologies and their statuses
  248. @echo nimbus launches the nimbus daemon
  249. @echo rebalance redistribute or change the parallelism of a running topology
  250. @echo repl opens up a Clojure REPL
  251. @echo remoteconfvalue prints value for conf-name from cluster config ../conf/storm.yaml merged with defaults.yaml
  252. @echo shell storm shell
  253. @echo supervisor launches the supervisor daemon
  254. @echo ui launches the UI daemon
  255. @echo version print the version
  256. @echo.
  257. @echo or
  258. @echo CLASSNAME run the class named CLASSNAME
  259. @echo Most commands print help when invoked w/o parameters.
  260.  
  261. endlocal
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement