Today, I looked at STORM's command-line script ${storm_home}/bin/storm, and now we'll tidy up the anatomy as a record. Note: The storm version used is 0.8.0.
The ${storm_home}/bin/storm file is written in Python, and the file is still fairly streamlined and clear.
First, the command runs from the main () method, and the main () method is primarily to parse the parameters of the input commands and commands and to read the default configuration and configuration file configuration.
if __name__ = = "__main__":
Main ()
def Main ():
if len (sys.argv) <= 1:
Print_usage ()
Sys.exit (-1) global config_opts = parse_config_opts (sys.argv[1
start
=
= Args[1
" Help ")) (*args)//query command dictionary, get the method that corresponds to the command to execute, call the method
Take the command storm jar Xxx.jar MAINCLASS arg1 arg2 As an example, the above command executes the jar (Xxx.jar, MAINCLASS, Arg1, arg2) method
The following is an analysis of the command execution method, or the jar () method as an example bar
defJar (Jarfile, Klass, *args):"""Syntax: [Storm jar Topology-jar-path class ...] Runs the main method of class with the specified arguments. The storm jars and Configs in ~/.storm is put on the classpath. The process is configured so Stormsubmitter (Http://nathanmarz.github.com/storm/doc/backtype/storm/StormSubmitte r.html) would upload the jar at Topology-jar-path when the topology is submitted. """Exec_storm_class (Klass, Jvmtype="-client", Extrajars=[jarfile, Conf_dir, Storm_dir +"/bin"], args=args, jvmopts=["-dstorm.jar="+Jarfile]) defExec_storm_class (Klass, jvmtype="-server", jvmopts=[], extrajars=[], args=[], fork=False): All_args= [ "Java", Jvmtype, get_config_opts (),"-dstorm.home="+Storm_dir,"-djava.library.path="+ Confvalue ("Java.library.path", Extrajars),"-CP", Get_classpath (Extrajars),]+ Jvmopts + [Klass] +list (args)Print "Running:"+" ". Join (All_args)iffork:os.spawnvp (OS. P_wait,"Java", All_args)Else: OS.EXECVP ("Java", All_args)#replaces the current process and never returns
Storm source Profiling (1): Storm script