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 Funcion: Save storm version to ZooKeeper #653

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
9 changes: 9 additions & 0 deletions storm-core/src/clj/backtype/storm/cluster.clj
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
(remove-worker-heartbeat! [this storm-id node port])
(supervisor-heartbeat! [this supervisor-id info])
(activate-storm! [this storm-id storm-base])
(initialize-version! [this])
(update-storm! [this storm-id new-elems])
(remove-storm-base! [this storm-id])
(set-assignment! [this storm-id info])
Expand All @@ -131,6 +132,7 @@
(def SUPERVISORS-ROOT "supervisors")
(def WORKERBEATS-ROOT "workerbeats")
(def ERRORS-ROOT "errors")
(def VERSION-PATH "version")

(def ASSIGNMENTS-SUBTREE (str "/" ASSIGNMENTS-ROOT))
(def STORMS-SUBTREE (str "/" STORMS-ROOT))
Expand Down Expand Up @@ -159,6 +161,9 @@
(defn error-path [storm-id component-id]
(str (error-storm-root storm-id) "/" (url-encode component-id)))

(defn version-path []
(str "/" VERSION-PATH))

(defn- issue-callback! [cb-atom]
(let [cb @cb-atom]
(reset! cb-atom nil)
Expand Down Expand Up @@ -304,6 +309,10 @@
(set-data cluster-state (storm-path storm-id) (Utils/serialize storm-base))
)

(initialize-version! [this]
(set-data cluster-state (version-path) (Utils/serialize (read-storm-version)))
)

(update-storm! [this storm-id new-elems]
(let [base (storm-base this storm-id nil)
executors (:component->executors base)
Expand Down
9 changes: 9 additions & 0 deletions storm-core/src/clj/backtype/storm/config.clj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
(:import [org.apache.commons.io FileUtils])
(:require [clojure [string :as str]])
(:use [backtype.storm util])
(:use [clojure.string :only [trim]])
)

(def RESOURCES-SUBDIR "resources")
Expand Down Expand Up @@ -183,6 +184,14 @@
(Utils/deserialize (FileUtils/readFileToByteArray (File. topology-path)))
))

(defn read-storm-version []
(let [storm-home (System/getProperty "storm.home")
release-path (format "%s/RELEASE" storm-home)
release-file (File. release-path)]
(if (and (.exists release-file) (.isFile release-file))
(trim (slurp release-path))
"Unknown")))

(defn worker-root
([conf]
(str (conf STORM-LOCAL-DIR) "/workers"))
Expand Down
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 @@ -878,6 +878,7 @@
(log-message "Starting Nimbus with conf " conf)
(let [nimbus (nimbus-data conf inimbus)]
(.prepare ^backtype.storm.nimbus.ITopologyValidator (:validator nimbus) conf)
(.initialize-version! (:storm-cluster-state nimbus))
(cleanup-corrupt-topologies! nimbus)
(doseq [storm-id (.active-storms (:storm-cluster-state nimbus))]
(transition! nimbus storm-id :startup))
Expand Down
9 changes: 0 additions & 9 deletions storm-core/src/clj/backtype/storm/ui/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
(:use [backtype.storm.ui helpers])
(:use [backtype.storm.daemon [common :only [ACKER-COMPONENT-ID system-id?]]])
(:use [ring.adapter.jetty :only [run-jetty]])
(:use [clojure.string :only [trim]])
(:import [backtype.storm.generated ExecutorSpecificStats
ExecutorStats ExecutorSummary TopologyInfo SpoutStats BoltStats
ErrorInfo ClusterSummary SupervisorSummary TopologySummary
Expand Down Expand Up @@ -54,14 +53,6 @@
(seq body)
]))

(defn read-storm-version []
(let [storm-home (System/getProperty "storm.home")
release-path (format "%s/RELEASE" storm-home)
release-file (File. release-path)]
(if (and (.exists release-file) (.isFile release-file))
(trim (slurp release-path))
"Unknown")))

(defn cluster-summary-table [^ClusterSummary summ]
(let [sups (.get_supervisors summ)
used-slots (reduce + (map #(.get_num_used_workers ^SupervisorSummary %) sups))
Expand Down