淺談Storm在zookeeper上的目錄結(jié)構(gòu)
Storm的所有的狀態(tài)信息都保存在Zookeeper里面,nimbus通過(guò)在zookeeper上面寫(xiě)狀態(tài)信息來(lái)分配任務(wù):
使得nimbus可以監(jiān)控整個(gè)storm集群的狀態(tài),從而可以重啟一些掛掉的task。 ZooKeeper使得整個(gè)storm集群十分的健壯-—任何一臺(tái)工作機(jī)器掛掉都沒(méi)有關(guān)系,只要重啟然后從zookeeper上面重新獲取狀態(tài)信息就可以了。那Storm在zookeeper里面存儲(chǔ)了哪些狀態(tài)呢?在James Xu的文章中有所涉及,但是該文章講述的已經(jīng)過(guò)時(shí)了。本文主要介紹Storm在ZooKeeper中保存的數(shù)據(jù)目錄結(jié)構(gòu),源代碼主要是:backtype.storm.cluster。
關(guān)于storm操作zookeeper的詳細(xì)分析請(qǐng)參見(jiàn):源碼閱讀之storm操作zookeeper-cluster.clj
Zookeeper的操作
(defprotocol ClusterState (set-ephemeral-node [this path data]) (delete-node [this path]) (create-sequential [this path data]) (set-data [this path data]) ;; if node does not exist, create persistent with this data (get-data [this path watch?]) (get-children [this path watch?]) (mkdirs [this path]) (close [this]) (register [this callback]) (unregister [this id]) )
Storm使用Zookeeper的操作
(defprotocol StormClusterState (assignments [this callback]) (assignment-info [this storm-id callback]) (active-storms [this]) (storm-base [this storm-id callback]) (get-worker-heartbeat [this storm-id node port]) (executor-beats [this storm-id executor->node+port]) (supervisors [this callback]) (supervisor-info [this supervisor-id]) ;; returns nil if doesn't exist (setup-heartbeats! [this storm-id]) (teardown-heartbeats! [this storm-id]) (teardown-topology-errors! [this storm-id]) (heartbeat-storms [this]) (error-topologies [this]) (worker-heartbeat! [this storm-id node port info]) (remove-worker-heartbeat! [this storm-id node port]) (supervisor-heartbeat! [this supervisor-id info]) (activate-storm! [this storm-id storm-base]) (update-storm! [this storm-id new-elems]) (remove-storm-base! [this storm-id]) (set-assignment! [this storm-id info]) (remove-storm! [this storm-id]) (report-error [this storm-id task-id error]) (errors [this storm-id task-id]) (disconnect [this]) )
Storm中在Zookeeper中存儲(chǔ)的目錄
(def ASSIGNMENTS-ROOT "assignments") (def CODE-ROOT "code") (def STORMS-ROOT "storms") (def SUPERVISORS-ROOT "supervisors") (def WORKERBEATS-ROOT "workerbeats") (def ERRORS-ROOT "errors") (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))
1./assignments -> 任務(wù)分配信息
2./storms -> 正在運(yùn)行的topology的ID
3./supervisors -> 所有的Supervisors的心跳信息
4./workerbeats -> 所有的Worker的心跳
5./errors -> 產(chǎn)生的出錯(cuò)信息
結(jié)構(gòu)圖
/-{storm-zk-root} -- storm在zookeeper上的根目錄(默認(rèn)為/storm) | |-/assignments -- topology的任務(wù)分配信息 | | | |-/{topology-id} -- 這個(gè)目錄保存的是每個(gè)topology的assignments信息包括:對(duì)應(yīng)的nimbus上 | -- 的代碼目錄,所有task的啟動(dòng)時(shí)間,每個(gè)task與機(jī)器、端口的映射。操作為 | -- (assignments)來(lái)獲取所有assignments的值;以及(assignment-info storm-id) | -- 來(lái)得到給定的storm-id對(duì)應(yīng)的AssignmentInfo信息 | -- 在A(yíng)ssignmentInfo中存儲(chǔ)的內(nèi)容有: | -- :executor->node+port :executor->start-time-secs :node->host | -- 具體定義在common.clj中的 | -- (defrecord Assignment[master-code-dir node->host executor->node+port executor->start-time-secs]) | |-/storms -- 這個(gè)目錄保存所有正在運(yùn)行的topology的id | | | | | |-/{topology-id} -- 這個(gè)文件保存這個(gè)topology的一些信息,包括topology的名字,topology開(kāi)始運(yùn)行 | -- 的時(shí)間以及這個(gè)topology的狀態(tài)。操作(active-storms),獲得當(dāng)前路徑活躍的下 | -- topology數(shù)據(jù)。保存的內(nèi)容參考類(lèi)StormBase;(storm-base storm-id)得到給定的 | -- storm-id下的StormBase數(shù)據(jù),具體定義在common.clj中的 | -- (defrecord StormBase [storm-name launch-time-secs status num-workers component->executors]) | |-/supervisors -- 這個(gè)目錄保存所有的supervisor的心跳信息 | | | | | |-/{supervisor-id} -- 這個(gè)文件保存supervisor的心跳信息包括:心跳時(shí)間,主機(jī)名,這個(gè)supervisor上 | -- worker的端口號(hào),運(yùn)行時(shí)間(具體看SupervisorInfo類(lèi))。操作(supervisors)得到 | -- 所有的supervisors節(jié)點(diǎn);(supervisor-info supervisor-id)得到給定的 | -- supervisor-id對(duì)應(yīng)的SupervisorInfo信息;具體定義在common.clj中的 | | -- (defrecord SupervisorInfo [time-secs hostname assignment-id used-ports meta scheduler-meta uptime-secs]) | |-/workerbeats -- 所有worker的心跳 | | | |-/{topology-id} -- 這個(gè)目錄保存這個(gè)topology的所有的worker的心跳信息 | | | |-/{supervisorId-port} -- worker的心跳信息,包括心跳的時(shí)間,worker運(yùn)行時(shí)間以及一些統(tǒng)計(jì)信息 | | -- 操作(heartbeat-storms)得到所有有心跳數(shù)據(jù)的topology, | -- (get-worker-heartbeat storm-id node port)得到具體一個(gè)topology下 | -- 的某個(gè)worker(node:port)的心跳狀況, | -- (executor-beats storm-id executor->node+port)得到一個(gè)executor的心跳狀況 | |-/errors -- 所有產(chǎn)生的error信息 | |-/{topology-id} -- 這個(gè)目錄保存這個(gè)topology下面的錯(cuò)誤信息。操作(error-topologies)得到出錯(cuò) | -- 的topology;(errors storm-id component-id)得到 | -- 給定的storm-id component-id下的出錯(cuò)信息 |-/{component-id}
總結(jié)
以上就是本文關(guān)于淺談Storm在zookeeper上的目錄結(jié)構(gòu)的全部?jī)?nèi)容,感興趣的朋友可以參閱:apache zookeeper使用方法實(shí)例詳解、為zookeeper配置相應(yīng)的acl權(quán)限、zookeeper watch機(jī)制的理解等,如有不足之處,歡迎留言指出,希望對(duì)大家有所幫助。感謝朋友們對(duì)本站的支持!
相關(guān)文章
詳解SpringBoot 多線(xiàn)程處理任務(wù) 無(wú)法@Autowired注入bean問(wèn)題解決
這篇文章主要介紹了詳解SpringBoot 多線(xiàn)程處理任務(wù) 無(wú)法@Autowired注入bean問(wèn)題解決,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2019-06-06解決子線(xiàn)程無(wú)法訪(fǎng)問(wèn)父線(xiàn)程中通過(guò)ThreadLocal設(shè)置的變量問(wèn)題
這篇文章主要介紹了解決子線(xiàn)程無(wú)法訪(fǎng)問(wèn)父線(xiàn)程中通過(guò)ThreadLocal設(shè)置的變量問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2024-07-07詳解java如何實(shí)現(xiàn)帶RequestBody傳Json參數(shù)的GET請(qǐng)求
在調(diào)試Fate平臺(tái)時(shí),遇到了一個(gè)奇葩的接口類(lèi)型,該接口為Get方式,入?yún)⑹且粋€(gè)json類(lèi)型在body中傳遞,使用body中傳參的話(huà)為什么不用POST請(qǐng)求而使用了GET請(qǐng)求,下面我們就來(lái)深入研究一下2024-02-02SpringBoot Jpa企業(yè)開(kāi)發(fā)示例詳細(xì)講解
這篇文章主要介紹了SpringBoot Jpa企業(yè)開(kāi)發(fā)示例,Jpa可以通過(guò)實(shí)體類(lèi)生成數(shù)據(jù)庫(kù)的表,同時(shí)自帶很多增刪改查方法,大部分sql語(yǔ)句不需要我們自己寫(xiě),配置完成后直接調(diào)用方法即可,很方便2022-11-11Java中的Random()函數(shù)及兩種構(gòu)造方法
Java中存在著兩種Random函數(shù)分別是java.lang.Math.Random和java.util.Random,文中給大家介紹了random()的兩種構(gòu)造方法,感興趣的朋友跟隨小編一起看看吧2018-11-11解決Weblogic部署war找不到spring配置文件的問(wèn)題
這篇文章主要介紹了解決Weblogic部署war找不到spring配置文件的問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。2021-07-07java實(shí)現(xiàn)微信支付(服務(wù)端)
這篇文章主要介紹了java實(shí)現(xiàn)微信支付,針對(duì)服務(wù)端進(jìn)行代碼編寫(xiě),感興趣的小伙伴們可以參考一下2015-12-12