You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@storm.apache.org by zh...@apache.org on 2016/01/28 18:49:42 UTC
[06/23] storm git commit: updated to nimbus-topo-history-state
updated to nimbus-topo-history-state
Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/310128d9
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/310128d9
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/310128d9
Branch: refs/heads/master
Commit: 310128d9469f2151851d4e44710593b6ebcbac59
Parents: 99189a6
Author: zhuol <zh...@yahoo-inc.com>
Authored: Fri Jan 15 13:33:52 2016 -0600
Committer: zhuol <zh...@yahoo-inc.com>
Committed: Wed Jan 20 09:55:24 2016 -0600
----------------------------------------------------------------------
.../src/clj/org/apache/storm/daemon/nimbus.clj | 2 +-
.../clj/org/apache/storm/daemon/supervisor.clj | 2 +-
storm-core/src/clj/org/apache/storm/testing.clj | 4 +-
.../jvm/org/apache/storm/utils/ConfigUtils.java | 44 ++++++++++++++++++++
.../test/clj/org/apache/storm/nimbus_test.clj | 11 ++---
.../clj/org/apache/storm/supervisor_test.clj | 12 +++---
6 files changed, 60 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/storm/blob/310128d9/storm-core/src/clj/org/apache/storm/daemon/nimbus.clj
----------------------------------------------------------------------
diff --git a/storm-core/src/clj/org/apache/storm/daemon/nimbus.clj b/storm-core/src/clj/org/apache/storm/daemon/nimbus.clj
index 9f4423a..9d978ae 100644
--- a/storm-core/src/clj/org/apache/storm/daemon/nimbus.clj
+++ b/storm-core/src/clj/org/apache/storm/daemon/nimbus.clj
@@ -200,7 +200,7 @@
:id->resources (atom {}) ;;resources of topologies
:cred-renewers (AuthUtils/GetCredentialRenewers conf)
:topology-history-lock (Object.)
- :topo-history-state (nimbus-topo-history-state conf)
+ :topo-history-state (ConfigUtils/nimbusTopoHistoryState conf)
:nimbus-autocred-plugins (AuthUtils/getNimbusAutoCredPlugins conf)
:nimbus-topology-action-notifier (create-tology-action-notifier conf)
}))
http://git-wip-us.apache.org/repos/asf/storm/blob/310128d9/storm-core/src/clj/org/apache/storm/daemon/supervisor.clj
----------------------------------------------------------------------
diff --git a/storm-core/src/clj/org/apache/storm/daemon/supervisor.clj b/storm-core/src/clj/org/apache/storm/daemon/supervisor.clj
index 5f3abf2..76af578 100644
--- a/storm-core/src/clj/org/apache/storm/daemon/supervisor.clj
+++ b/storm-core/src/clj/org/apache/storm/daemon/supervisor.clj
@@ -324,7 +324,7 @@
conf)
SUPERVISOR-ZK-ACLS)
:context (ClusterStateContext. DaemonType/SUPERVISOR))
- :local-state (supervisor-state conf)
+ :local-state (ConfigUtils/supervisorState conf)
:supervisor-id (.getSupervisorId isupervisor)
:assignment-id (.getAssignmentId isupervisor)
:my-hostname (hostname conf)
http://git-wip-us.apache.org/repos/asf/storm/blob/310128d9/storm-core/src/clj/org/apache/storm/testing.clj
----------------------------------------------------------------------
diff --git a/storm-core/src/clj/org/apache/storm/testing.clj b/storm-core/src/clj/org/apache/storm/testing.clj
index 48d63aa..08752c5 100644
--- a/storm-core/src/clj/org/apache/storm/testing.clj
+++ b/storm-core/src/clj/org/apache/storm/testing.clj
@@ -350,13 +350,13 @@
(defn find-worker-id
[supervisor-conf port]
- (let [supervisor-state (supervisor-state supervisor-conf)
+ (let [supervisor-state (ConfigUtils/supervisorState supervisor-conf)
worker->port (ls-approved-workers supervisor-state)]
(first ((reverse-map worker->port) port))))
(defn find-worker-port
[supervisor-conf worker-id]
- (let [supervisor-state (supervisor-state supervisor-conf)
+ (let [supervisor-state (ConfigUtils/supervisorState supervisor-conf)
worker->port (ls-approved-workers supervisor-state)]
(worker->port worker-id)))
http://git-wip-us.apache.org/repos/asf/storm/blob/310128d9/storm-core/src/jvm/org/apache/storm/utils/ConfigUtils.java
----------------------------------------------------------------------
diff --git a/storm-core/src/jvm/org/apache/storm/utils/ConfigUtils.java b/storm-core/src/jvm/org/apache/storm/utils/ConfigUtils.java
index 35f2249..b657ec4 100644
--- a/storm-core/src/jvm/org/apache/storm/utils/ConfigUtils.java
+++ b/storm-core/src/jvm/org/apache/storm/utils/ConfigUtils.java
@@ -378,11 +378,55 @@ public class ConfigUtils {
return (ret + FILE_SEPARATOR + RESOURCES_SUBDIR);
}
+ //For testing only
+ // for java
+ // try (SetMockedSupervisorState mocked = new SetMockedSupervisorState(conf)) {
+ // run test ...
+ // }
+ //
+ // for clojure
+ // (with-open [mock (SetMockedSupervisorState. conf)]
+ // run test ...)
+ public static class SetMockedSupervisorState implements Closeable {
+ public SetMockedSupervisorState(Map conf) {
+ mockedSupervisorState = conf;
+ }
+ @Override
+ public void close() {
+ mockedSupervisorState = null;
+ }
+ }
+ private static Map mockedSupervisorState = null;
public static LocalState supervisorState(Map conf) throws IOException {
+ if (mockedSupervisorState != null) {
+ return null;
+ }
return new LocalState((supervisorLocalDir(conf) + FILE_SEPARATOR + "localstate"));
}
+ //For testing only
+ // for java
+ // try (SetMockedNimbusTopoHistoryState mocked = new SetMockedNimbusTopoHistoryState(conf)) {
+ // run test ...
+ // }
+ //
+ // for clojure
+ // (with-open [mock (SetMockedNimbusTopoHistoryState. conf)]
+ // run test ...)
+ public static class SetMockedNimbusTopoHistoryState implements Closeable {
+ public SetMockedNimbusTopoHistoryState(Map conf) {
+ mockedNimbusTopoHistoryState = conf;
+ }
+ @Override
+ public void close() {
+ mockedNimbusTopoHistoryState = null;
+ }
+ }
+ private static Map mockedNimbusTopoHistoryState = null;
public static LocalState nimbusTopoHistoryState(Map conf) throws IOException {
+ if (mockedNimbusTopoHistoryState != null) {
+ return null;
+ }
return new LocalState((masterLocalDir(conf) + FILE_SEPARATOR + "history"));
}
http://git-wip-us.apache.org/repos/asf/storm/blob/310128d9/storm-core/test/clj/org/apache/storm/nimbus_test.clj
----------------------------------------------------------------------
diff --git a/storm-core/test/clj/org/apache/storm/nimbus_test.clj b/storm-core/test/clj/org/apache/storm/nimbus_test.clj
index 9d68bc8..4633088 100644
--- a/storm-core/test/clj/org/apache/storm/nimbus_test.clj
+++ b/storm-core/test/clj/org/apache/storm/nimbus_test.clj
@@ -1341,7 +1341,8 @@
NIMBUS-THRIFT-PORT 6666})
expected-acls nimbus/NIMBUS-ZK-ACLS
fake-inimbus (reify INimbus (getForcedScheduler [this] nil))]
- (stubbing [nimbus-topo-history-state nil
+ (with-open [mock (org.apache.storm.utils.ConfigUtils$SetMockedNimbusTopoHistoryState. {})]
+ (stubbing [nimbus-topo-history-state nil
mk-authorization-handler nil
cluster/mk-storm-cluster-state nil
nimbus/file-cache-map nil
@@ -1352,10 +1353,10 @@
mk-timer nil
zk-leader-elector nil
nimbus/mk-scheduler nil]
- (nimbus/nimbus-data auth-conf fake-inimbus)
- (verify-call-times-for cluster/mk-storm-cluster-state 1)
- (verify-first-call-args-for-indices cluster/mk-storm-cluster-state [2]
- expected-acls)))))
+ (nimbus/nimbus-data auth-conf fake-inimbus)
+ (verify-call-times-for cluster/mk-storm-cluster-state 1)
+ (verify-first-call-args-for-indices cluster/mk-storm-cluster-state [2]
+ expected-acls))))))
(deftest test-file-bogus-download
(with-local-cluster [cluster :daemon-conf {SUPERVISOR-ENABLE false TOPOLOGY-ACKER-EXECUTORS 0 TOPOLOGY-EVENTLOGGER-EXECUTORS 0}]
http://git-wip-us.apache.org/repos/asf/storm/blob/310128d9/storm-core/test/clj/org/apache/storm/supervisor_test.clj
----------------------------------------------------------------------
diff --git a/storm-core/test/clj/org/apache/storm/supervisor_test.clj b/storm-core/test/clj/org/apache/storm/supervisor_test.clj
index 5be2059..3b5877c 100644
--- a/storm-core/test/clj/org/apache/storm/supervisor_test.clj
+++ b/storm-core/test/clj/org/apache/storm/supervisor_test.clj
@@ -552,16 +552,16 @@
fake-isupervisor (reify ISupervisor
(getSupervisorId [this] nil)
(getAssignmentId [this] nil))]
- (stubbing [uptime-computer nil
+ (with-open [mock (org.apache.storm.utils.ConfigUtils$SetMockedSupervisorState. {})]
+ (stubbing [uptime-computer nil
cluster/mk-storm-cluster-state nil
- supervisor-state nil
local-hostname nil
mk-timer nil
supervisor-local-dir nil]
- (supervisor/supervisor-data auth-conf nil fake-isupervisor)
- (verify-call-times-for cluster/mk-storm-cluster-state 1)
- (verify-first-call-args-for-indices cluster/mk-storm-cluster-state [2]
- expected-acls)))))
+ (supervisor/supervisor-data auth-conf nil fake-isupervisor)
+ (verify-call-times-for cluster/mk-storm-cluster-state 1)
+ (verify-first-call-args-for-indices cluster/mk-storm-cluster-state [2]
+ expected-acls))))))
(deftest test-write-log-metadata
(testing "supervisor writes correct data to logs metadata file"