Storm source Profiling (1): Storm script

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.