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

add NimbusCloudStorage to support muti nimbus nodes #1

Open
wants to merge 3 commits into
base: nimbus-ha
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
6 changes: 6 additions & 0 deletions src/clj/backtype/storm/cluster.clj
Original file line number Diff line number Diff line change
Expand Up @@ -131,19 +131,24 @@
(def SUPERVISORS-ROOT "supervisors")
(def WORKERBEATS-ROOT "workerbeats")
(def ERRORS-ROOT "errors")
(def CUSTOMERCONTEXT-ROOT "customercontext")

(def ASSIGNMENTS-SUBTREE (str "/" ASSIGNMENTS-ROOT))
(def STORMS-SUBTREE (str "/" STORMS-ROOT))
(def SUPERVISORS-SUBTREE (str "/" SUPERVISORS-ROOT))
(def WORKERBEATS-SUBTREE (str "/" WORKERBEATS-ROOT))
(def ERRORS-SUBTREE (str "/" ERRORS-ROOT))
(def CUSTOMERCONTEXT-SUBTREE (str "/" CUSTOMERCONTEXT-ROOT))

(defn supervisor-path [id]
(str SUPERVISORS-SUBTREE "/" id))

(defn assignment-path [id]
(str ASSIGNMENTS-SUBTREE "/" id))

(defn customercontext-path [id]
(str CUSTOMERCONTEXT-SUBTREE "/" id))

(defn storm-path [id]
(str STORMS-SUBTREE "/" id))

Expand Down Expand Up @@ -329,6 +334,7 @@

(remove-storm! [this storm-id]
(delete-node cluster-state (assignment-path storm-id))
(delete-node cluster-state (customercontext-path storm-id))
(remove-storm-base! this storm-id))

(report-error [this storm-id component-id error]
Expand Down
4 changes: 3 additions & 1 deletion src/clj/backtype/storm/daemon/worker.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
(:use [backtype.storm bootstrap])
(:require [backtype.storm.daemon [executor :as executor]])
(:import [java.util.concurrent Executors])
(:import [backtype.storm.task CustomerContext])
(:gen-class))

(bootstrap)
Expand Down Expand Up @@ -430,4 +431,5 @@
(defn -main [storm-id assignment-id port-str worker-id]
(let [conf (read-storm-config)]
(validate-distributed-mode! conf)
(mk-worker conf nil (java.net.URLDecoder/decode storm-id) assignment-id (Integer/parseInt port-str) worker-id)))
(mk-worker conf nil (java.net.URLDecoder/decode storm-id) assignment-id (Integer/parseInt port-str) worker-id)
(CustomerContext/start conf)))
41 changes: 35 additions & 6 deletions src/clj/backtype/storm/ui/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@
Nimbus$Client StormTopology GlobalStreamId RebalanceOptions
KillOptions])
(:import [java.io File])
(:import [backtype.storm.utils Utils])
(:import [backtype.storm.task CustomerContext])
(:require [compojure.route :as route]
[compojure.handler :as handler]
[ring.util.response :as resp]
[backtype.storm [thrift :as thrift]])
(:require [backtype.storm [zookeeper :as zk]])
(:gen-class))

(def ^:dynamic *STORM-CONF* (read-storm-config))
Expand Down Expand Up @@ -558,7 +561,7 @@
(nil-to-zero (:failed stats))])
)))

(defn spout-executor-table [topology-id executors window include-sys?]
(defn spout-executor-table [topology-id component executors window include-sys?]
(sorted-table
["Id" "Uptime" "Host" "Port" "Emitted" "Transferred"
"Complete latency (ms)" "Acked" "Failed"]
Expand All @@ -570,7 +573,8 @@
aggregate-spout-streams
swap-map-order
(get window)))]]
[(pretty-executor-info (.get_executor_info e))
[(let [pretty-executor-info (pretty-executor-info (.get_executor_info e))]
(link-to (url-format "/topology/%s/component/%s/executor/%s" topology-id component pretty-executor-info) pretty-executor-info))
(pretty-uptime-sec (.get_uptime_secs e))
(.get_host e)
(.get_port e)
Expand All @@ -595,7 +599,7 @@
[[:h2 "Output stats" window-hint]]
(spout-output-summary-table stream-summary window)
[[:h2 "Executors" window-hint]]
(spout-executor-table (.get_id topology-info) executors window include-sys?)
(spout-executor-table (.get_id topology-info) component executors window include-sys?)
;; task id, task uptime, stream aggregated stats, last error
)))

Expand Down Expand Up @@ -633,7 +637,7 @@
])
)))

(defn bolt-executor-table [topology-id executors window include-sys?]
(defn bolt-executor-table [topology-id component executors window include-sys?]
(sorted-table
["Id" "Uptime" "Host" "Port" "Emitted" "Transferred" "Capacity (last 10m)"
"Execute latency (ms)" "Executed" "Process latency (ms)" "Acked" "Failed"]
Expand All @@ -645,7 +649,8 @@
(aggregate-bolt-streams)
swap-map-order
(get window)))]]
[(pretty-executor-info (.get_executor_info e))
[(let [pretty-executor-info (pretty-executor-info (.get_executor_info e))]
(link-to (url-format "/topology/%s/component/%s/executor/%s" topology-id component pretty-executor-info) pretty-executor-info))
(pretty-uptime-sec (.get_uptime_secs e))
(.get_host e)
(.get_port e)
Expand Down Expand Up @@ -699,7 +704,7 @@
(bolt-output-summary-table stream-summary window)

[[:h2 "Executors"]]
(bolt-executor-table (.get_id topology-info) executors window include-sys?)
(bolt-executor-table (.get_id topology-info) component executors window include-sys?)
)))

(defn errors-table [errors-list]
Expand Down Expand Up @@ -736,6 +741,25 @@
(errors-table (get (.get_errors summ) component))]
))))

(defn executor-page [topology-id component executor window include-sys?]
(let [conf *STORM-CONF*
split-result (clojure.string/split executor #"-")
left-part (first split-result)
right-part (last split-result)
start-taskid (subs left-part 1)
end-taskid (subs right-part 0 (- (count right-part) 1))
taskids (range (Integer/parseInt start-taskid) (+ (Integer/parseInt end-taskid) 1))]
(for [taskid taskids]
(let [path (str (conf STORM-ZOOKEEPER-ROOT) "/" CustomerContext/CUSTOMERCONTEXT_ROOT "/" topology-id "/" taskid)
zk (zk/mk-client conf (conf STORM-ZOOKEEPER-SERVERS) (conf STORM-ZOOKEEPER-PORT) :auth-conf conf)
task-context-data (zk/get-data zk path false)
task-context-map (when task-context-data (Utils/deserialize task-context-data))
task-context-table-content (concat
[[:h2 (link-to (url-format "/topology/%s/component/%s" topology-id component) (str "TaskID:" taskid))]]
(configuration-table task-context-map))]
(.close zk)
task-context-table-content))))

(defn get-include-sys? [cookies]
(let [sys? (get cookies "sys")
sys? (if (or (nil? sys?) (= "false" (:value sys?))) false true)]
Expand All @@ -755,6 +779,11 @@
(-> (component-page id component (:window m) include-sys?)
(concat [(mk-system-toggle-button include-sys?)])
ui-template)))
(GET "/topology/:id/component/:component/executor/:executor" [:as {cookies :cookies} id component executor & m]
(let [include-sys? (get-include-sys? cookies)]
(-> (executor-page id component executor (:window m) include-sys?)
(concat [(mk-system-toggle-button include-sys?)])
ui-template)))
(POST "/topology/:id/activate" [id]
(with-nimbus nimbus
(let [tplg (.getTopologyInfo ^Nimbus$Client nimbus id)
Expand Down
Loading