Skip to content

Instantly share code, notes, and snippets.

@ept
Created May 30, 2012 20:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ept/2838935 to your computer and use it in GitHub Desktop.
Save ept/2838935 to your computer and use it in GitHub Desktop.
Make Storm use exec instead of forking a child for the JVM (patch for 0.7.1 release)
--- a/bin/storm 2012-05-30 19:57:54.265944289 +0000
+++ b/bin/storm 2012-05-30 20:36:25.516040172 +0000
@@ -82,12 +82,15 @@
"""
print name + ": " + confvalue(name, [STORM_DIR + "/conf"])
-def exec_storm_class(klass, jvmtype="-server", childopts="", extrajars=[], args=[]):
- nativepath = confvalue("java.library.path", extrajars)
- args_str = " ".join(map(lambda s: "\"" + s + "\"", args))
- command = "java " + jvmtype + " -Dstorm.home=" + STORM_DIR + " " + get_config_opts() + " -Djava.library.path=" + nativepath + " " + childopts + " -cp " + get_classpath(extrajars) + " " + klass + " " + args_str
- print "Running: " + command
- os.system(command)
+def exec_storm_class(klass, jvmtype="-server", jvmopts=[], extrajars=[], args=[]):
+ 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] + args
+ print "Running: " + " ".join(all_args)
+ os.execvp("java", all_args)
def jar(jarfile, klass, *args):
"""Syntax: [storm jar topology-jar-path class ...]
@@ -103,7 +106,7 @@
jvmtype="-client",
extrajars=[jarfile, CONF_DIR, STORM_DIR + "/bin"],
args=args,
- childopts="-Dstorm.jar=" + jarfile)
+ jvmopts=["-Dstorm.jar=" + jarfile])
def kill(*args):
"""Syntax: [storm kill topology-name [-w wait-time-secs]]
@@ -197,12 +200,15 @@
(https://github.com/nathanmarz/storm/wiki/Setting-up-a-Storm-cluster)
"""
cppaths = [STORM_DIR + "/log4j", STORM_DIR + "/conf"]
- childopts = confvalue("nimbus.childopts", cppaths) + " -Dlogfile.name=nimbus.log -Dlog4j.configuration=storm.log.properties"
+ jvmopts = confvalue("nimbus.childopts", cppaths).split() + [
+ "-Dlogfile.name=nimbus.log",
+ "-Dlog4j.configuration=storm.log.properties",
+ ]
exec_storm_class(
"backtype.storm.daemon.nimbus",
jvmtype="-server",
extrajars=cppaths,
- childopts=childopts)
+ jvmopts=jvmopts)
def supervisor():
"""Syntax: [storm supervisor]
@@ -214,12 +220,15 @@
(https://github.com/nathanmarz/storm/wiki/Setting-up-a-Storm-cluster)
"""
cppaths = [STORM_DIR + "/log4j", STORM_DIR + "/conf"]
- childopts = confvalue("supervisor.childopts", cppaths) + " -Dlogfile.name=supervisor.log -Dlog4j.configuration=storm.log.properties"
+ jvmopts = confvalue("supervisor.childopts", cppaths).split() + [
+ "-Dlogfile.name=supervisor.log",
+ "-Dlog4j.configuration=storm.log.properties",
+ ]
exec_storm_class(
"backtype.storm.daemon.supervisor",
jvmtype="-server",
extrajars=cppaths,
- childopts=childopts)
+ jvmopts=jvmopts)
def ui():
"""Syntax: [storm ui]
@@ -232,11 +241,14 @@
(https://github.com/nathanmarz/storm/wiki/Setting-up-a-Storm-cluster)
"""
cppaths = [STORM_DIR + "/log4j", STORM_DIR + "/conf"]
- childopts = confvalue("ui.childopts", cppaths) + " -Dlogfile.name=ui.log -Dlog4j.configuration=storm.log.properties"
+ jvmopts = confvalue("ui.childopts", cppaths).split() + [
+ "-Dlogfile.name=ui.log",
+ "-Dlog4j.configuration=storm.log.properties",
+ ]
exec_storm_class(
"backtype.storm.ui.core",
jvmtype="-server",
- childopts=childopts,
+ jvmopts=jvmopts,
extrajars=[STORM_DIR + "/log4j", STORM_DIR, STORM_DIR + "/conf"])
def drpc():
@@ -248,11 +260,11 @@
See Distributed RPC for more information.
(https://github.com/nathanmarz/storm/wiki/Distributed-RPC)
"""
- childopts = "-Xmx768m -Dlogfile.name=drpc.log -Dlog4j.configuration=storm.log.properties"
+ jvmopts = ["-Xmx768m", "-Dlogfile.name=drpc.log", "-Dlog4j.configuration=storm.log.properties"]
exec_storm_class(
"backtype.storm.daemon.drpc",
jvmtype="-server",
- childopts=childopts,
+ jvmopts=jvmopts,
extrajars=[STORM_DIR + "/log4j", STORM_DIR + "/conf"])
def print_classpath():
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment