Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When scheduling make sure to clean up empty assignments in zookeeper. #680

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions storm-core/src/clj/backtype/storm/daemon/nimbus.clj
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,7 @@
topologies
scratch-topology-id)

topology->executor->node+port (merge (into {} (for [id assigned-topology-ids] {id nil})) topology->executor->node+port)

now-secs (current-time-secs)

Expand Down
2 changes: 1 addition & 1 deletion storm-core/src/clj/backtype/storm/daemon/supervisor.clj
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"Returns map from port to struct containing :storm-id and :executors"
[assignments-snapshot assignment-id]
(->> (dofor [sid (keys assignments-snapshot)] (read-my-executors assignments-snapshot sid assignment-id))
(apply merge-with (fn [& ignored] (throw-runtime "Should not have multiple topologies assigned to one port")))))
(apply merge-with (fn [& params] (throw-runtime (str "Should not have multiple topologies assigned to one port " params))))))

(defn- read-storm-code-locations
[assignments-snapshot]
Expand Down
65 changes: 65 additions & 0 deletions storm-core/test/clj/backtype/storm/nimbus_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,71 @@

)))


(defn check-for-collisions [state]
(log-message "Checking for collision")
(let [assignments (.assignments state nil)]
(log-message "Assignemts: " assignments)
(let [id->node->ports (into {} (for [id assignments
:let [executor->node+port (:executor->node+port (.assignment-info state id nil))
node+ports (set (.values executor->node+port))
node->ports (apply merge-with (fn [a b] (distinct (concat a b))) (for [[node port] node+ports] {node [port]}))]]
{id node->ports}))
_ (log-message "id->node->ports: " id->node->ports)
all-nodes (apply merge-with (fn [a b]
(let [ret (concat a b)]
(log-message "Can we combine " (pr-str a) " and " (pr-str b) " without collisions? " (apply distinct? ret) " => " (pr-str ret))
(is (apply distinct? ret))
(distinct ret)))
(.values id->node->ports))]
)))

(deftest test-rebalance-constrained-cluster
(with-simulated-time-local-cluster [cluster :supervisors 1 :ports-per-supervisor 4
:daemon-conf {SUPERVISOR-ENABLE false
NIMBUS-MONITOR-FREQ-SECS 10
TOPOLOGY-MESSAGE-TIMEOUT-SECS 30
TOPOLOGY-ACKER-EXECUTORS 0}]
(letlocals
(bind topology (thrift/mk-topology
{"1" (thrift/mk-spout-spec (TestPlannerSpout. true) :parallelism-hint 3)}
{}))
(bind topology2 (thrift/mk-topology
{"1" (thrift/mk-spout-spec (TestPlannerSpout. true) :parallelism-hint 3)}
{}))
(bind topology3 (thrift/mk-topology
{"1" (thrift/mk-spout-spec (TestPlannerSpout. true) :parallelism-hint 3)}
{}))
(bind state (:storm-cluster-state cluster))
(submit-local-topology (:nimbus cluster)
"test"
{TOPOLOGY-WORKERS 3
TOPOLOGY-MESSAGE-TIMEOUT-SECS 90} topology)
(submit-local-topology (:nimbus cluster)
"test2"
{TOPOLOGY-WORKERS 3
TOPOLOGY-MESSAGE-TIMEOUT-SECS 90} topology2)
(submit-local-topology (:nimbus cluster)
"test3"
{TOPOLOGY-WORKERS 3
TOPOLOGY-MESSAGE-TIMEOUT-SECS 90} topology3)

(advance-cluster-time cluster 31)

(check-for-collisions state)
(.rebalance (:nimbus cluster) "test" (doto (RebalanceOptions.)
(.set_num_workers 4)
(.set_wait_secs 0)
))

(advance-cluster-time cluster 11)
(check-for-collisions state)

(advance-cluster-time cluster 30)
(check-for-collisions state)
)))


(deftest test-submit-invalid
(with-simulated-time-local-cluster [cluster
:daemon-conf {SUPERVISOR-ENABLE false
Expand Down