[GitHub] storm pull request: STORM-188: Allow user to specifiy full configu...

2015-10-09 Thread clockfly
Github user clockfly closed the pull request at:

https://github.com/apache/storm/pull/120


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] storm pull request: STORM-188: Allow user to specifiy full configu...

2015-10-09 Thread clockfly
Github user clockfly commented on the pull request:

https://github.com/apache/storm/pull/120#issuecomment-146773478
  
Sure.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] storm pull request: STORM-188: Allow user to specifiy full configu...

2015-10-08 Thread d2r
Github user d2r commented on the pull request:

https://github.com/apache/storm/pull/120#issuecomment-146644953
  
@clockfly , It seems this pull request was superseded by #495, and 
STORM-188 has been resolved.  Would you close this pull request?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] storm pull request: STORM-188. Allow user to specifiy full configu...

2015-04-03 Thread asfgit
Github user asfgit closed the pull request at:

https://github.com/apache/storm/pull/495


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] storm pull request: STORM-188. Allow user to specifiy full configu...

2015-04-03 Thread revans2
Github user revans2 commented on the pull request:

https://github.com/apache/storm/pull/495#issuecomment-89409291
  
I think overall it is good and I am +1.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] storm pull request: STORM-188. Allow user to specifiy full configu...

2015-04-01 Thread lazyval
Github user lazyval commented on a diff in the pull request:

https://github.com/apache/storm/pull/495#discussion_r27562061
  
--- Diff: storm-core/src/jvm/backtype/storm/utils/Utils.java ---
@@ -135,35 +137,68 @@ public static void sleep(long millis) {
 }
 
 public static Map findAndReadConfigFile(String name, boolean 
mustExist) {
+InputStream in = null;
+Boolean confFileEmpty = false;
--- End diff --

no need in boxed value


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] storm pull request: STORM-188. Allow user to specifiy full configu...

2015-04-01 Thread lazyval
Github user lazyval commented on a diff in the pull request:

https://github.com/apache/storm/pull/495#discussion_r27561516
  
--- Diff: storm-core/src/jvm/backtype/storm/utils/Utils.java ---
@@ -135,35 +137,68 @@ public static void sleep(long millis) {
 }
 
 public static Map findAndReadConfigFile(String name, boolean 
mustExist) {
+InputStream in = null;
+Boolean confFileEmpty = false;
 try {
-HashSetURL resources = new HashSetURL(findResources(name));
-if(resources.isEmpty()) {
-if(mustExist) throw new RuntimeException(Could not find 
config file on classpath  + name);
-else return new HashMap();
-}
-if(resources.size()  1) {
-throw new RuntimeException(Found multiple  + name +  
resources. You're probably bundling the Storm jars with your topology jar. 
-  + resources);
-}
-URL resource = resources.iterator().next();
-Yaml yaml = new Yaml(new SafeConstructor());
-Map ret = null;
-InputStream input = resource.openStream();
-try {
-ret = (Map) yaml.load(new InputStreamReader(input));
-} finally {
-input.close();
+in = getConfigFileInputStream(name);
+if (null != in) {
+Yaml yaml = new Yaml(new SafeConstructor());
+Map ret = (Map) yaml.load(new InputStreamReader(in));
+if (null != ret) {
+return new HashMap(ret);
+} else {
+confFileEmpty = true;
+}
 }
-if(ret==null) ret = new HashMap();
-
 
-return new HashMap(ret);
-
+if (mustExist) {
+if(confFileEmpty)
+throw new RuntimeException(Config file  + name +  
doesn't have any valid storm configs);
+else
+throw new RuntimeException(Could not find config file 
on classpath  + name);
+} else {
+return new HashMap();
+}
 } catch (IOException e) {
 throw new RuntimeException(e);
+} finally {
+if (null != in) {
+try {
+in.close();
+} catch (IOException e) {
+throw new RuntimeException(e);
+}
+}
 }
 }
 
+private static InputStream getConfigFileInputStream(String 
configFilePath)
+throws IOException {
+if (null == configFilePath) {
+throw new IOException(
+Could not find config file, name not specified);
+}
+
+HashSetURL resources = new 
HashSetURL(findResources(configFilePath));
+if (resources.isEmpty()) {
+File configFile = new File(configFilePath);
+if (configFile.exists()) {
+return new FileInputStream(configFile);
+}
--- End diff --

Why not throw IOException, when path contains no actual file? 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] storm pull request: STORM-188. Allow user to specifiy full configu...

2015-04-01 Thread lazyval
Github user lazyval commented on a diff in the pull request:

https://github.com/apache/storm/pull/495#discussion_r27562802
  
--- Diff: storm-core/src/jvm/backtype/storm/utils/Utils.java ---
@@ -135,35 +137,68 @@ public static void sleep(long millis) {
 }
 
 public static Map findAndReadConfigFile(String name, boolean 
mustExist) {
+InputStream in = null;
+Boolean confFileEmpty = false;
 try {
-HashSetURL resources = new HashSetURL(findResources(name));
-if(resources.isEmpty()) {
-if(mustExist) throw new RuntimeException(Could not find 
config file on classpath  + name);
-else return new HashMap();
-}
-if(resources.size()  1) {
-throw new RuntimeException(Found multiple  + name +  
resources. You're probably bundling the Storm jars with your topology jar. 
-  + resources);
-}
-URL resource = resources.iterator().next();
-Yaml yaml = new Yaml(new SafeConstructor());
-Map ret = null;
-InputStream input = resource.openStream();
-try {
-ret = (Map) yaml.load(new InputStreamReader(input));
-} finally {
-input.close();
+in = getConfigFileInputStream(name);
+if (null != in) {
+Yaml yaml = new Yaml(new SafeConstructor());
+Map ret = (Map) yaml.load(new InputStreamReader(in));
+if (null != ret) {
+return new HashMap(ret);
+} else {
+confFileEmpty = true;
+}
 }
-if(ret==null) ret = new HashMap();
-
 
-return new HashMap(ret);
-
+if (mustExist) {
+if(confFileEmpty)
+throw new RuntimeException(Config file  + name +  
doesn't have any valid storm configs);
+else
+throw new RuntimeException(Could not find config file 
on classpath  + name);
+} else {
+return new HashMap();
+}
 } catch (IOException e) {
 throw new RuntimeException(e);
+} finally {
+if (null != in) {
+try {
+in.close();
+} catch (IOException e) {
+throw new RuntimeException(e);
+}
+}
 }
 }
 
+private static InputStream getConfigFileInputStream(String 
configFilePath)
+throws IOException {
+if (null == configFilePath) {
+throw new IOException(
+Could not find config file, name not specified);
+}
+
+HashSetURL resources = new 
HashSetURL(findResources(configFilePath));
+if (resources.isEmpty()) {
+File configFile = new File(configFilePath);
+if (configFile.exists()) {
+return new FileInputStream(configFile);
+}
--- End diff --

Yeah, I just a bit concerned that flow is driven by both exceptions and 
flag/null.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] storm pull request: STORM-188. Allow user to specifiy full configu...

2015-04-01 Thread clockfly
Github user clockfly commented on a diff in the pull request:

https://github.com/apache/storm/pull/495#discussion_r27561927
  
--- Diff: storm-core/src/jvm/backtype/storm/utils/Utils.java ---
@@ -135,35 +137,68 @@ public static void sleep(long millis) {
 }
 
 public static Map findAndReadConfigFile(String name, boolean 
mustExist) {
+InputStream in = null;
+Boolean confFileEmpty = false;
 try {
-HashSetURL resources = new HashSetURL(findResources(name));
-if(resources.isEmpty()) {
-if(mustExist) throw new RuntimeException(Could not find 
config file on classpath  + name);
-else return new HashMap();
-}
-if(resources.size()  1) {
-throw new RuntimeException(Found multiple  + name +  
resources. You're probably bundling the Storm jars with your topology jar. 
-  + resources);
-}
-URL resource = resources.iterator().next();
-Yaml yaml = new Yaml(new SafeConstructor());
-Map ret = null;
-InputStream input = resource.openStream();
-try {
-ret = (Map) yaml.load(new InputStreamReader(input));
-} finally {
-input.close();
+in = getConfigFileInputStream(name);
+if (null != in) {
+Yaml yaml = new Yaml(new SafeConstructor());
+Map ret = (Map) yaml.load(new InputStreamReader(in));
+if (null != ret) {
+return new HashMap(ret);
+} else {
+confFileEmpty = true;
+}
 }
-if(ret==null) ret = new HashMap();
-
 
-return new HashMap(ret);
-
+if (mustExist) {
+if(confFileEmpty)
+throw new RuntimeException(Config file  + name +  
doesn't have any valid storm configs);
+else
+throw new RuntimeException(Could not find config file 
on classpath  + name);
+} else {
+return new HashMap();
+}
 } catch (IOException e) {
 throw new RuntimeException(e);
+} finally {
+if (null != in) {
+try {
+in.close();
+} catch (IOException e) {
+throw new RuntimeException(e);
+}
+}
 }
 }
 
+private static InputStream getConfigFileInputStream(String 
configFilePath)
+throws IOException {
+if (null == configFilePath) {
+throw new IOException(
+Could not find config file, name not specified);
+}
+
+HashSetURL resources = new 
HashSetURL(findResources(configFilePath));
+if (resources.isEmpty()) {
+File configFile = new File(configFilePath);
+if (configFile.exists()) {
+return new FileInputStream(configFile);
+}
--- End diff --

@lazyval 

mustExist flag will control whether we should fail the method.
···public static Map findAndReadConfigFile(String name, boolean 
mustExist) ···

When we cannot find a resource, we will return null; then we check whether 
mustExist flag is enabled to determine whether we should throw RuntimeException.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] storm pull request: STORM-188. Allow user to specifiy full configu...

2015-04-01 Thread lazyval
Github user lazyval commented on a diff in the pull request:

https://github.com/apache/storm/pull/495#discussion_r27571878
  
--- Diff: storm-core/src/jvm/backtype/storm/utils/Utils.java ---
@@ -135,35 +137,68 @@ public static void sleep(long millis) {
 }
 
 public static Map findAndReadConfigFile(String name, boolean 
mustExist) {
+InputStream in = null;
+Boolean confFileEmpty = false;
--- End diff --

There are two variables types in Java: primitive (like boolean, int, long, 
short and so on), and their boxed counterparts (Boolean, Integer, Long, ...), 
which are seen as reference types. It's minor, but unless you're working with 
collections, there is no need to use later one.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] storm pull request: STORM-188. Allow user to specifiy full configu...

2015-04-01 Thread harshach
Github user harshach commented on a diff in the pull request:

https://github.com/apache/storm/pull/495#discussion_r27571219
  
--- Diff: storm-core/src/jvm/backtype/storm/utils/Utils.java ---
@@ -135,35 +137,68 @@ public static void sleep(long millis) {
 }
 
 public static Map findAndReadConfigFile(String name, boolean 
mustExist) {
+InputStream in = null;
+Boolean confFileEmpty = false;
--- End diff --

@lazyval  what you mean by boxed value?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] storm pull request: STORM-188. Allow user to specifiy full configu...

2015-04-01 Thread harshach
Github user harshach commented on a diff in the pull request:

https://github.com/apache/storm/pull/495#discussion_r27572921
  
--- Diff: storm-core/src/jvm/backtype/storm/utils/Utils.java ---
@@ -135,35 +137,68 @@ public static void sleep(long millis) {
 }
 
 public static Map findAndReadConfigFile(String name, boolean 
mustExist) {
+InputStream in = null;
+Boolean confFileEmpty = false;
--- End diff --

@lazyval  I know about primitives and objects in java . Yes makes sense to 
use a boolean.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] storm pull request: STORM-188. Allow user to specifiy full configu...

2015-04-01 Thread harshach
Github user harshach commented on the pull request:

https://github.com/apache/storm/pull/495#issuecomment-88537973
  
@clockfly @lazyval updated the patch for fixing the last comment. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] storm pull request: STORM-188. Allow user to specifiy full configu...

2015-04-01 Thread harshach
Github user harshach commented on a diff in the pull request:

https://github.com/apache/storm/pull/495#discussion_r27584483
  
--- Diff: storm-core/src/jvm/backtype/storm/utils/Utils.java ---
@@ -135,35 +137,68 @@ public static void sleep(long millis) {
 }
 
 public static Map findAndReadConfigFile(String name, boolean 
mustExist) {
+InputStream in = null;
+Boolean confFileEmpty = false;
 try {
-HashSetURL resources = new HashSetURL(findResources(name));
-if(resources.isEmpty()) {
-if(mustExist) throw new RuntimeException(Could not find 
config file on classpath  + name);
-else return new HashMap();
-}
-if(resources.size()  1) {
-throw new RuntimeException(Found multiple  + name +  
resources. You're probably bundling the Storm jars with your topology jar. 
-  + resources);
-}
-URL resource = resources.iterator().next();
-Yaml yaml = new Yaml(new SafeConstructor());
-Map ret = null;
-InputStream input = resource.openStream();
-try {
-ret = (Map) yaml.load(new InputStreamReader(input));
-} finally {
-input.close();
+in = getConfigFileInputStream(name);
+if (null != in) {
+Yaml yaml = new Yaml(new SafeConstructor());
+Map ret = (Map) yaml.load(new InputStreamReader(in));
+if (null != ret) {
+return new HashMap(ret);
+} else {
+confFileEmpty = true;
+}
 }
-if(ret==null) ret = new HashMap();
-
 
-return new HashMap(ret);
-
+if (mustExist) {
+if(confFileEmpty)
+throw new RuntimeException(Config file  + name +  
doesn't have any valid storm configs);
+else
+throw new RuntimeException(Could not find config file 
on classpath  + name);
+} else {
+return new HashMap();
+}
 } catch (IOException e) {
 throw new RuntimeException(e);
+} finally {
+if (null != in) {
+try {
+in.close();
+} catch (IOException e) {
+throw new RuntimeException(e);
+}
+}
 }
 }
 
+private static InputStream getConfigFileInputStream(String 
configFilePath)
+throws IOException {
+if (null == configFilePath) {
+throw new IOException(
+Could not find config file, name not specified);
+}
+
+HashSetURL resources = new 
HashSetURL(findResources(configFilePath));
+if (resources.isEmpty()) {
+File configFile = new File(configFilePath);
+if (configFile.exists()) {
+return new FileInputStream(configFile);
+}
--- End diff --

@lazyval there are cases where storm wants to use defaults.yaml if there is 
not storm.yaml. If one wants to do a quick test they can just run the storm 
cluster by not having any storm.yaml . Hence the reason we have mustexist as a 
flag to indicate if we want to throw an error or not.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] storm pull request: STORM-188. Allow user to specifiy full configu...

2015-04-01 Thread lazyval
Github user lazyval commented on the pull request:

https://github.com/apache/storm/pull/495#issuecomment-88550651
  
:+1: 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] storm pull request: STORM-188: Allow user to specifiy full configu...

2015-03-31 Thread manuzhang
Github user manuzhang commented on the pull request:

https://github.com/apache/storm/pull/120#issuecomment-88018456
  
guys, any updates on issue ?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] storm pull request: STORM-188. Allow user to specifiy full configu...

2015-03-31 Thread harshach
Github user harshach commented on the pull request:

https://github.com/apache/storm/pull/495#issuecomment-88204014
  
This PR is taken from 
https://github.com/apache/storm/pull/120#issuecomment-69435220

@clockfly @revans2 can you please take a look.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] storm pull request: STORM-188. Allow user to specifiy full configu...

2015-03-31 Thread harshach
GitHub user harshach opened a pull request:

https://github.com/apache/storm/pull/495

STORM-188. Allow user to specifiy full configuration path when running 
storm command



You can merge this pull request into a Git repository by running:

$ git pull https://github.com/harshach/incubator-storm STORM-188

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/storm/pull/495.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #495


commit 9a2c4129b145b901f320238ea36a282ff7f44d0c
Author: Sriharsha Chintalapani m...@harsha.io
Date:   2015-03-31T18:37:30Z

STORM-188. Allow user to specifiy full configuration path when running 
storm command.




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] storm pull request: STORM-188. Allow user to specifiy full configu...

2015-03-31 Thread clockfly
Github user clockfly commented on the pull request:

https://github.com/apache/storm/pull/495#issuecomment-88295467
  
+1


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] storm pull request: STORM-188: Allow user to specifiy full configu...

2015-01-09 Thread clockfly
Github user clockfly commented on the pull request:

https://github.com/apache/storm/pull/120#issuecomment-69435220
  
@revans,

Feel free to do what you want, change it, or replace it.:)


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] storm pull request: STORM-188: Allow user to specifiy full configu...

2014-11-18 Thread revans2
Github user revans2 commented on a diff in the pull request:

https://github.com/apache/storm/pull/120#discussion_r20513760
  
--- Diff: storm-core/src/jvm/backtype/storm/utils/Utils.java ---
@@ -122,36 +124,64 @@ public static void sleep(long millis) {
 }
 }
 
+// Will try to locate the config file in class path first, then will 
search local path
+// For example, we can use temporary config path like this: storm jar 
job.jar --config /tmp/xx.yaml
 public static Map findAndReadConfigFile(String name, boolean 
mustExist) {
+InputStream in = null;
 try {
-HashSetURL resources = new HashSetURL(findResources(name));
-if(resources.isEmpty()) {
-if(mustExist) throw new RuntimeException(Could not find 
config file on classpath  + name);
-else return new HashMap();
-}
-if(resources.size()  1) {
-throw new RuntimeException(Found multiple  + name +  
resources. You're probably bundling the Storm jars with your topology jar. 
-  + resources);
-}
-URL resource = resources.iterator().next();
-Yaml yaml = new Yaml(new SafeConstructor());
-Map ret = null;
-InputStream input = resource.openStream();
-try {
-ret = (Map) yaml.load(new InputStreamReader(input));
-} finally {
-input.close();
+in = getConfigFileInputStream(name);
+if (null != in) {
+Yaml yaml = new Yaml();
--- End diff --

Can we change this to ```Yaml yaml = new Yaml(new SafeConstructor());```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] storm pull request: STORM-188: Allow user to specifiy full configu...

2014-11-18 Thread revans2
Github user revans2 commented on the pull request:

https://github.com/apache/storm/pull/120#issuecomment-63492543
  
I just had one comment, to avoid YAML doing some potentially unsafe things, 
but it is not that critical, because placing a --config on the command line is 
going to use a file the user probably supplied.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] storm pull request: STORM-188: Allow user to specifiy full configu...

2014-11-18 Thread revans2
Github user revans2 commented on a diff in the pull request:

https://github.com/apache/storm/pull/120#discussion_r20514725
  
--- Diff: storm-core/src/jvm/backtype/storm/utils/Utils.java ---
@@ -122,36 +124,64 @@ public static void sleep(long millis) {
 }
 }
 
+// Will try to locate the config file in class path first, then will 
search local path
+// For example, we can use temporary config path like this: storm jar 
job.jar --config /tmp/xx.yaml
 public static Map findAndReadConfigFile(String name, boolean 
mustExist) {
+InputStream in = null;
 try {
-HashSetURL resources = new HashSetURL(findResources(name));
-if(resources.isEmpty()) {
-if(mustExist) throw new RuntimeException(Could not find 
config file on classpath  + name);
-else return new HashMap();
-}
-if(resources.size()  1) {
-throw new RuntimeException(Found multiple  + name +  
resources. You're probably bundling the Storm jars with your topology jar. 
-  + resources);
-}
-URL resource = resources.iterator().next();
-Yaml yaml = new Yaml(new SafeConstructor());
-Map ret = null;
-InputStream input = resource.openStream();
-try {
-ret = (Map) yaml.load(new InputStreamReader(input));
-} finally {
-input.close();
+in = getConfigFileInputStream(name);
+if (null != in) {
+Yaml yaml = new Yaml();
+Map ret = (Map) yaml.load(new InputStreamReader(in));
+if (null != ret) {
+return new HashMap(ret);
+}
 }
-if(ret==null) ret = new HashMap();
-
 
-return new HashMap(ret);
-
+if (mustExist) {
+throw new RuntimeException(Could not find config file on 
classpath  + name);
+} else {
+return new HashMap();
+}
 } catch (IOException e) {
 throw new RuntimeException(e);
+} finally {
+if (null != in) {
+try {
+in.close();
+} catch (IOException e) {
+throw new RuntimeException(e);
+}
+}
+}
+}
+
+private static InputStream getConfigFileInputStream(String 
configFilePath)
+throws IOException {
+if (null == configFilePath) {
+throw new IOException(
+Could not find config file, name not specified);
+}
+
+HashSetURL resources = new 
HashSetURL(findResources(configFilePath));
+if (resources.isEmpty()) {
+File configFile = new File(configFilePath);
+if (configFile.exists()) {
+return new FileInputStream(configFile);
+}
+} else if (resources.size()  1) {
+throw new IOException(
+Found multiple  + configFilePath
++  resources. You're probably bundling the 
Storm jars with your topology jar. 
++ resources);
+} else {
+URL resource = resources.iterator().next();
--- End diff --

It might be nice to log something here, so that the user knows that we are 
using a config file from the classpath.  I just thought about the case where 
someone creates a ./storm.yaml file and passes it in with --config.  They will 
get the storm.yaml from the classpath without knowing it, because the classpath 
is searched prior to the absolute path being searched, and this would be really 
confusing.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] storm pull request: STORM-188: Allow user to specifiy full configu...

2014-11-17 Thread clockfly
Github user clockfly commented on the pull request:

https://github.com/apache/storm/pull/120#issuecomment-63431309
  
The original behavior of findAndReadConfigFile() is to locate config file 
on classpath.

findResources(name) will not be empty when name exists on classpath.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] storm pull request: STORM-188: Allow user to specifiy full configu...

2014-11-03 Thread clockfly
Github user clockfly commented on the pull request:

https://github.com/apache/storm/pull/120#issuecomment-61599764
  
@d2r , sorry it takes so long.

Now, the patch is synced with upstream.




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---