You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@storm.apache.org by bo...@apache.org on 2015/08/24 15:51:51 UTC
[06/50] [abbrv] storm git commit: STORM-166: adding formConf method
to NimbusInfo.
STORM-166: adding formConf method to NimbusInfo.
Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/c82482d8
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/c82482d8
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/c82482d8
Branch: refs/heads/master
Commit: c82482d845de996515047ee001d61b9a50322a9f
Parents: 9cd52c8
Author: Parth Brahmbhatt <br...@gmail.com>
Authored: Fri Dec 19 13:54:52 2014 -0800
Committer: Parth Brahmbhatt <br...@gmail.com>
Committed: Fri Dec 19 13:54:52 2014 -0800
----------------------------------------------------------------------
.../src/clj/backtype/storm/daemon/nimbus.clj | 2 +-
.../jvm/backtype/storm/nimbus/NimbusInfo.java | 38 ++++++++++++++++++++
.../test/clj/backtype/storm/nimbus_test.clj | 3 +-
3 files changed, 41 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/storm/blob/c82482d8/storm-core/src/clj/backtype/storm/daemon/nimbus.clj
----------------------------------------------------------------------
diff --git a/storm-core/src/clj/backtype/storm/daemon/nimbus.clj b/storm-core/src/clj/backtype/storm/daemon/nimbus.clj
index c652b41..b638e52 100644
--- a/storm-core/src/clj/backtype/storm/daemon/nimbus.clj
+++ b/storm-core/src/clj/backtype/storm/daemon/nimbus.clj
@@ -79,7 +79,7 @@
(defn nimbus-data [conf inimbus]
(let [forced-scheduler (.getForcedScheduler inimbus)]
{:conf conf
- :nimbus-host-port-info (NimbusInfo. (.getCanonicalHostName (InetAddress/getLocalHost)) (conf NIMBUS-THRIFT-PORT) false)
+ :nimbus-host-port-info (NimbusInfo/fromConf conf)
:inimbus inimbus
:authorization-handler (mk-authorization-handler (conf NIMBUS-AUTHORIZER) conf)
:submitted-count (atom 0)
http://git-wip-us.apache.org/repos/asf/storm/blob/c82482d8/storm-core/src/jvm/backtype/storm/nimbus/NimbusInfo.java
----------------------------------------------------------------------
diff --git a/storm-core/src/jvm/backtype/storm/nimbus/NimbusInfo.java b/storm-core/src/jvm/backtype/storm/nimbus/NimbusInfo.java
index e31090f..1b96bbf 100644
--- a/storm-core/src/jvm/backtype/storm/nimbus/NimbusInfo.java
+++ b/storm-core/src/jvm/backtype/storm/nimbus/NimbusInfo.java
@@ -1,6 +1,11 @@
package backtype.storm.nimbus;
+import backtype.storm.Config;
+
import java.io.Serializable;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.Map;
public class NimbusInfo implements Serializable {
private static final String DELIM = ":";
@@ -24,6 +29,17 @@ public class NimbusInfo implements Serializable {
}
}
+ public static NimbusInfo fromConf(Map conf) {
+ try {
+ String host = InetAddress.getLocalHost().getCanonicalHostName();
+ int port = Integer.parseInt(conf.get(Config.NIMBUS_THRIFT_PORT).toString());
+ return new NimbusInfo(host, port, false);
+
+ } catch (UnknownHostException e) {
+ throw new RuntimeException("Something wrong with network/dns config, host cant figure out its name", e);
+ }
+ }
+
public String toHostPortString() {
return String.format("%s%s%s",host,DELIM,port);
}
@@ -41,6 +57,28 @@ public class NimbusInfo implements Serializable {
}
@Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (!(o instanceof NimbusInfo)) return false;
+
+ NimbusInfo that = (NimbusInfo) o;
+
+ if (isLeader != that.isLeader) return false;
+ if (port != that.port) return false;
+ if (!host.equals(that.host)) return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = host.hashCode();
+ result = 31 * result + port;
+ result = 31 * result + (isLeader ? 1 : 0);
+ return result;
+ }
+
+ @Override
public String toString() {
return "NimbusInfo{" +
"host='" + host + '\'' +
http://git-wip-us.apache.org/repos/asf/storm/blob/c82482d8/storm-core/test/clj/backtype/storm/nimbus_test.clj
----------------------------------------------------------------------
diff --git a/storm-core/test/clj/backtype/storm/nimbus_test.clj b/storm-core/test/clj/backtype/storm/nimbus_test.clj
index e408c17..1a94049 100644
--- a/storm-core/test/clj/backtype/storm/nimbus_test.clj
+++ b/storm-core/test/clj/backtype/storm/nimbus_test.clj
@@ -1235,7 +1235,8 @@
(let [scheme "digest"
digest "storm:thisisapoorpassword"
auth-conf {STORM-ZOOKEEPER-AUTH-SCHEME scheme
- STORM-ZOOKEEPER-AUTH-PAYLOAD digest}
+ STORM-ZOOKEEPER-AUTH-PAYLOAD digest
+ NIMBUS-THRIFT-PORT 6666}
expected-acls nimbus/NIMBUS-ZK-ACLS
fake-inimbus (reify INimbus (getForcedScheduler [this] nil))]
(stubbing [mk-authorization-handler nil