d2r commented on a change in pull request #2930: STORM-3274: Migrates storm CLI
to using argparse making documentation…
URL: https://github.com/apache/storm/pull/2930#discussion_r253920643
##########
File path: bin/storm.py
##########
@@ -296,787 +251,1090 @@ def exec_storm_class(klass, jvmtype="-server",
jvmopts=[], extrajars=[], args=[]
elif is_windows():
# handling whitespaces in JAVA_CMD
try:
- ret = sub.check_output(all_args, stderr=sub.STDOUT)
+ ret = subprocess.check_output(all_args, stderr=subprocess.STDOUT)
print(ret)
- except sub.CalledProcessError as e:
+ except subprocess.CalledProcessError as e:
print(e.output)
sys.exit(e.returncode)
else:
os.execvp(JAVA_CMD, all_args)
return exit_code
-def run_client_jar(jarfile, klass, args, daemon=False, client=True,
extrajvmopts=[]):
- global DEP_JARS_OPTS, DEP_ARTIFACTS_OPTS, DEP_ARTIFACTS_REPOSITORIES_OPTS,
DEP_MAVEN_LOCAL_REPOSITORY_DIRECTORY, DEP_PROXY_URL, DEP_PROXY_USERNAME,
DEP_PROXY_PASSWORD
- local_jars = DEP_JARS_OPTS
- artifact_to_file_jars = resolve_dependencies(DEP_ARTIFACTS_OPTS,
DEP_ARTIFACTS_REPOSITORIES_OPTS, DEP_MAVEN_LOCAL_REPOSITORY_DIRECTORY,
DEP_PROXY_URL, DEP_PROXY_USERNAME, DEP_PROXY_PASSWORD)
+def run_client_jar(klass, args, daemon=False, client=True, extrajvmopts=[]):
+ local_jars = args.jars.split(",")
+ jarfile = args.topology_jar_path
- extra_jars=[jarfile, USER_CONF_DIR, STORM_BIN_DIR]
+ artifact_to_file_jars = resolve_dependencies(
+ args.artifacts, args.artifactRepositories,
+ args.mavenLocalRepositoryDirectory, args.proxyUrl,
+ args.proxyUsername, args.proxyPassword
+ )
+
+ extra_jars = [jarfile, USER_CONF_DIR, STORM_BIN_DIR]
extra_jars.extend(local_jars)
extra_jars.extend(artifact_to_file_jars.values())
exec_storm_class(
- klass,
+ klass, args.storm_config_opts,
jvmtype="-client",
extrajars=extra_jars,
- args=args,
+ args=args.topology_main_args,
daemon=False,
jvmopts=JAR_JVM_OPTS + extrajvmopts + ["-Dstorm.jar=" + jarfile] +
["-Dstorm.dependency.jars=" + ",".join(local_jars)] +
["-Dstorm.dependency.artifacts=" +
json.dumps(artifact_to_file_jars)])
-def local(jarfile, klass, *args):
- """Syntax: [storm local topology-jar-path class ...]
- Runs the main method of class with the specified arguments but pointing to
a local cluster
- The storm jars and configs in ~/.storm are put on the classpath.
- The process is configured so that StormSubmitter
-
(http://storm.apache.org/releases/current/javadocs/org/apache/storm/StormSubmitter.html)
- and others will interact with a local cluster instead of the one
configured by default.
+def print_localconfvalue(args):
+ print(args.conf_name + ": " + confvalue(args.conf_name,
args.storm_config_opts, [USER_CONF_DIR]))
+
+
+def print_remoteconfvalue(args):
+ print(args.conf_name + ": " + confvalue(args.conf_name,
args.storm_config_opts, [CLUSTER_CONF_DIR]))
+
+
+def initialize_main_command():
+ main_parser = argparse.ArgumentParser(prog="storm",
formatter_class=SortingHelpFormatter)
+ add_common_options(main_parser)
+
+ subparsers = main_parser.add_subparsers(help="")
+
+ initialize_jar_subcommand(subparsers)
+ initialize_localconfvalue_subcommand(subparsers)
+ initialize_remoteconfvalue_subcommand(subparsers)
+ initialize_local_subcommand(subparsers)
+ initialize_sql_subcommand(subparsers)
+ initialize_kill_subcommand(subparsers)
+ initialize_upload_credentials_subcommand(subparsers)
+ initialize_blobstore_subcommand(subparsers)
+ initialize_heartbeats_subcommand(subparsers)
+ initialize_activate_subcommand(subparsers)
+ initialize_listtopos_subcommand(subparsers)
+ initialize_deactivate_subcommand(subparsers)
+ initialize_rebalance_subcommand(subparsers)
+ initialize_get_errors_subcommand(subparsers)
+ initialize_healthcheck_subcommand(subparsers)
+ initialize_kill_workers_subcommand(subparsers)
+ initialize_admin_subcommand(subparsers)
+ initialize_shell_subcommand(subparsers)
+ initialize_repl_subcommand(subparsers)
+ initialize_nimbus_subcommand(subparsers)
+ initialize_pacemaker_subcommand(subparsers)
+ initialize_supervisor_subcommand(subparsers)
+ initialize_ui_subcommand(subparsers)
+ initialize_logviewer_subcommand(subparsers)
+ initialize_drpc_client_subcommand(subparsers)
+ initialize_drpc_subcommand(subparsers)
+ initialize_dev_zookeeper_subcommand(subparsers)
+ initialize_version_subcommand(subparsers)
+ initialize_classpath_subcommand(subparsers)
+ initialize_server_classpath_subcommand(subparsers)
+ initialize_monitor_subcommand(subparsers)
+
+ return main_parser
+
+
+def initialize_localconfvalue_subcommand(subparsers):
+ command_help = '''Prints out the value for conf-name in the local Storm
configs.
+ The local Storm configs are the ones in ~/.storm/storm.yaml merged
+ in with the configs in defaults.yaml.'''
- Most options should work just like with the storm jar command.
+ sub_parser = subparsers.add_parser("localconfvalue", help=command_help,
formatter_class=SortingHelpFormatter)
+ sub_parser.add_argument("conf_name")
+ sub_parser.set_defaults(func=print_localconfvalue)
+ add_common_options(sub_parser)
- local also adds in the option --local-ttl which sets the number of seconds
the
- local cluster will run for before it shuts down.
- --local-zookeeper if using an external zookeeper sets the connection
string to use for it.
- --java-debug lets you turn on java debugging and set the parameters passed
to -agentlib:jdwp on the JDK
- --java-debug transport=dt_socket,address=localhost:8000
- will open up a debugging server on port 8000.
- """
- [ttl, lzk, debug_args, args] = parse_local_opts(args)
- extrajvmopts = ["-Dstorm.local.sleeptime=" + ttl]
- if lzk != None:
- extrajvmopts = extrajvmopts + ["-Dstorm.local.zookeeper=" + lzk]
- if debug_args != None:
- extrajvmopts = extrajvmopts + ["-agentlib:jdwp=" + debug_args]
- run_client_jar(jarfile, "org.apache.storm.LocalCluster", [klass] +
list(args), client=False, daemon=False, extrajvmopts=extrajvmopts)
-
-def jar(jarfile, klass, *args):
- """Syntax: [storm jar topology-jar-path class ...]
-
- Runs the main method of class with the specified arguments.
- The storm worker dependencies and configs in ~/.storm are put on the
classpath.
- The process is configured so that StormSubmitter
-
(http://storm.apache.org/releases/current/javadocs/org/apache/storm/StormSubmitter.html)
- will upload the jar at topology-jar-path when the topology is submitted.
+def initialize_remoteconfvalue_subcommand(subparsers):
+ command_help = '''Prints out the value for conf-name in the cluster's
Storm configs.
+ The cluster's Storm configs are the ones in $STORM-PATH/conf/storm.yaml
+ merged in with the configs in defaults.yaml.
+
+ This command must be run on a cluster machine.'''
+
+ sub_parser = subparsers.add_parser("remoteconfvalue", help=command_help,
formatter_class=SortingHelpFormatter)
+ sub_parser.add_argument("conf_name")
+ sub_parser.set_defaults(func=print_remoteconfvalue)
+ add_common_options(sub_parser)
- When you want to ship other jars which is not included to application jar,
you can pass them to --jars option with comma-separated string.
+
+def add_common_options(parser):
+ parser.add_argument("--config", default=None, help="Override default storm
conf file")
+ parser.add_argument(
+ "-storm_config_opts", "-c", action="append", default=[],
+ help="Override storm conf properties , e.g. nimbus.ui.port=4443"
+ )
+
+def add_topology_jar_options(parser):
+ parser.add_argument("topology_jar_path", help="will upload the jar at
topology-jar-path when the topology is submitted.")
Review comment:
Yes this was fixed.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services