add `hostname` util, which checks conf before guessing local-hostname
Project: http://git-wip-us.apache.org/repos/asf/storm/repo Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/04583cfe Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/04583cfe Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/04583cfe Branch: refs/heads/master Commit: 04583cfe70db13d6b916ef34467b7ca1205b03f2 Parents: a370c16 Author: Homer Strong <[email protected]> Authored: Sat Nov 8 13:05:04 2014 -0800 Committer: Homer Strong <[email protected]> Committed: Sat Nov 8 13:05:04 2014 -0800 ---------------------------------------------------------------------- storm-core/src/clj/backtype/storm/util.clj | 6 ++++++ 1 file changed, 6 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/storm/blob/04583cfe/storm-core/src/clj/backtype/storm/util.clj ---------------------------------------------------------------------- diff --git a/storm-core/src/clj/backtype/storm/util.clj b/storm-core/src/clj/backtype/storm/util.clj index 398584f..4dbb101 100644 --- a/storm-core/src/clj/backtype/storm/util.clj +++ b/storm-core/src/clj/backtype/storm/util.clj @@ -206,6 +206,12 @@ (def memoized-local-hostname (memoize local-hostname)) +;; checks conf for STORM-LOCAL-HOSTNAME. +;; when unconfigured, falls back to (memoized) guess by `local-hostname`. +(defn hostname + [conf] + (conf STORM-LOCAL-HOSTNAME (memoized-local-hostname))) + (letfn [(try-port [port] (with-open [socket (java.net.ServerSocket. port)] (.getLocalPort socket)))]
