Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Duplicate
-
0.9.3-rc2
-
None
-
None
Description
Utils.java
Index: src/jvm/backtype/storm/utils/Utils.java =================================================================== --- src/jvm/backtype/storm/utils/Utils.java (revision 4021) +++ src/jvm/backtype/storm/utils/Utils.java (working copy) @@ -19,7 +19,10 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileNotFoundException; import java.io.FileOutputStream; +import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; @@ -31,6 +34,7 @@ import java.nio.channels.Channels; import java.nio.channels.WritableByteChannel; import java.util.ArrayList; +import java.util.Collections; import java.util.Enumeration; import java.util.HashMap; import java.util.HashSet; @@ -44,6 +48,7 @@ import backtype.storm.serialization.DefaultSerializationDelegate; import backtype.storm.serialization.SerializationDelegate; + import org.apache.curator.framework.CuratorFramework; import org.apache.curator.framework.CuratorFrameworkFactory; import org.apache.commons.lang.StringUtils; @@ -121,6 +126,27 @@ throw new RuntimeException(e); } } + + @SuppressWarnings("unchecked") + public static Map<String, Object> loadConfigFile(String file) { + Map<String, Object> result = new HashMap<String, Object>(); + if (file == null) { + return result; + } + Yaml yaml = new Yaml(); + InputStream in; + try { + in = new FileInputStream(new File(file)); + Object obj = yaml.load(in); + if (!(obj instanceof Map)) { + return Collections.<String, Object> emptyMap(); + } + result = (Map<String, Object>) obj; + } catch (FileNotFoundException e) { + throw new RuntimeException(e); + } + return result; + } public static Map findAndReadConfigFile(String name, boolean mustExist) { try { @@ -187,7 +213,7 @@ if (confFile==null || confFile.equals("")) { storm = findAndReadConfigFile("storm.yaml", false); } else { - storm = findAndReadConfigFile(confFile, true); + storm = loadConfigFile(confFile); } ret.putAll(storm); ret.putAll(readCommandLineOpts());
bin/storm --config ~/deploy/storm-conf/storm.yaml supervisor
Could not find config file on classpath
Exception in thread "main" java.lang.ExceptionInInitializerError at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:171) at backtype.storm.config$loading__4910__auto__.invoke(config.clj:17) at backtype.storm.config__init.load(Unknown Source) at backtype.storm.config__init.<clinit>(Unknown Source) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:249) at clojure.lang.RT.loadClassForName(RT.java:2098) at clojure.lang.RT.load(RT.java:430) at clojure.lang.RT.load(RT.java:411) at clojure.core$load$fn__5018.invoke(core.clj:5530) at clojure.core$load.doInvoke(core.clj:5529) at clojure.lang.RestFn.invoke(RestFn.java:408) at clojure.core$load_one.invoke(core.clj:5336) at clojure.core$load_lib$fn__4967.invoke(core.clj:5375) at clojure.core$load_lib.doInvoke(core.clj:5374) at clojure.lang.RestFn.applyTo(RestFn.java:142) at clojure.core$apply.invoke(core.clj:619) at clojure.core$load_libs.doInvoke(core.clj:5417) at clojure.lang.RestFn.applyTo(RestFn.java:137) at clojure.core$apply.invoke(core.clj:621) at clojure.core$use.doInvoke(core.clj:5507) at clojure.lang.RestFn.invoke(RestFn.java:408) at backtype.storm.daemon.common$loading__4910__auto__.invoke(common.clj:16) at backtype.storm.daemon.common__init.load(Unknown Source) at backtype.storm.daemon.common__init.<clinit>(Unknown Source) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:249) at clojure.lang.RT.loadClassForName(RT.java:2098) at clojure.lang.RT.load(RT.java:430) at clojure.lang.RT.load(RT.java:411) at clojure.core$load$fn__5018.invoke(core.clj:5530) at clojure.core$load.doInvoke(core.clj:5529) at clojure.lang.RestFn.invoke(RestFn.java:408) at clojure.core$load_one.invoke(core.clj:5336) at clojure.core$load_lib$fn__4967.invoke(core.clj:5375) at clojure.core$load_lib.doInvoke(core.clj:5374) at clojure.lang.RestFn.applyTo(RestFn.java:142) at clojure.core$apply.invoke(core.clj:619) at clojure.core$load_libs.doInvoke(core.clj:5417) at clojure.lang.RestFn.applyTo(RestFn.java:137) at clojure.core$apply.invoke(core.clj:621) at clojure.core$use.doInvoke(core.clj:5507) at clojure.lang.RestFn.invoke(RestFn.java:408) at backtype.storm.daemon.supervisor$loading__4910__auto__.invoke(supervisor.clj:16) at backtype.storm.daemon.supervisor__init.load(Unknown Source) at backtype.storm.daemon.supervisor__init.<clinit>(Unknown Source) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:249) at clojure.lang.RT.loadClassForName(RT.java:2098) at clojure.lang.RT.load(RT.java:430) at clojure.lang.RT.load(RT.java:411) at clojure.core$load$fn__5018.invoke(core.clj:5530) at clojure.core$load.doInvoke(core.clj:5529) at clojure.lang.RestFn.invoke(RestFn.java:408) at clojure.lang.Var.invoke(Var.java:415) at backtype.storm.daemon.supervisor.<clinit>(Unknown Source) Caused by: java.lang.RuntimeException: Could not find config file on classpath /home/caokun/deploy/storm-conf/storm.yaml at backtype.storm.utils.Utils.findAndReadConfigFile(Utils.java:129) at backtype.storm.utils.Utils.readStormConfig(Utils.java:190) at backtype.storm.utils.Utils.<clinit>(Utils.java:71) ... 57 more Could not find the main class: backtype.storm.daemon.supervisor. Program will exit.
Attachments
Issue Links
- is duplicated by
-
STORM-188 Allow user to specify full configuration path when running storm command
- Resolved