Twitter Storm中Topology的状态
Twitter Storm中Topology的状态
状态转换如下,Topology 的持久化状态包括: active, inactive, killed, rebalancing 四个状态。
代码上看到每种状态都可以转换成一些持久化 ( 写入到 zk 中的状态 ) 或者中间状态。
- (defn state-transitions [nimbus storm-id status]
- {:active {:monitor (reassign-transition nimbus storm-id)
- :inactivate :inactive
- :activate nil
- :rebalance (rebalance-transition nimbus storm-id status)
- :kill (kill-transition nimbus storm-id)
- }
- :inactive {:monitor (reassign-transition nimbus storm-id)
- :activate :active
- :inactivate nil
- :rebalance (rebalance-transition nimbus storm-id status)
- :kill (kill-transition nimbus storm-id)
- }
- :killed {:startup (fn [] (delay-event nimbus
- storm-id
- (:kill-time-secs status)
- :remove))
- :kill (kill-transition nimbus storm-id)
- :remove (fn []
- (log-message "Killing topology: " storm-id)
- (.remove-storm! (:storm-cluster-state nimbus)
- storm-id)
- nil)
- }
- :rebalancing {:startup (fn [] (delay-event nimbus
- storm-id
- (:delay-secs status)
- :do-rebalance))
- :kill (kill-transition nimbus storm-id)
- :do-rebalance (fn []
- (do-rebalance nimbus storm-id status)
- (:old-status status))
- }})
1. active
active 状态的时候可以转换成 monitor, inactivate, activate, rebalance, kill 。
(1) monitor: 转换成 monitor 实际上是执行了 reassign-transition 操作:
- (defn reassign-transition [nimbus storm-id]
- (fn []
- (reassign-topology nimbus storm-id)
- nil
- ))
可以看出,实际上是为这个 topology 重新分配任务,返回值为 nil , 说明在 zk 中不会更改 topology 的持久化状态。
(2)inactivate: 返回值是 inactive, 状态转换的时候会将 zk 中 topology 的状态转换成 inactive 。
(3)activate: nil 说明什么操作都不做
(4)rebalance: 实际上是调用了 rebalance-transition 函数,从代码可以看出,会将状态改成 rebalancing, 然后再转换成 do-rebalance 。 do-rebalance 其实也是重新分配任务,具体看4 。
- (defn rebalance-transition [nimbus storm-id status]
- (fn [time num-workers executor-overrides]
- (let [delay (if time
- time
- (get (read-storm-conf (:conf nimbus) storm-id)
- TOPOLOGY-MESSAGE-TIMEOUT-SECS))]
- (delay-event nimbus
- storm-id
- delay
- :do-rebalance)
- {:type :rebalancing
- :delay-secs delay
- :old-status status
- :num-workers num-workers
- :executor-overrides executor-overrides
- })))
(5)kill: 实际上执行的是 kill-transition 方法,将 topology 的状态先改为 killed, 然后经过 kill-time 的时间,将topology remove, 详见3
- (defn kill-transition [nimbus storm-id]
- (fn [kill-time]
- (let [delay (if kill-time
- kill-time
- (get (read-storm-conf (:conf nimbus) storm-id)
- TOPOLOGY-MESSAGE-TIMEOUT-SECS))]
- (delay-event nimbus
- storm-id
- delay
- :remove)
- {:type :killed
- :kill-time-secs delay})
- ))
2. inactvie
(1) monitor: 与1中相同
(2) activate: 返回值是 active, 状态转换的时候会将 zk 中 topology 的状态转换成 active 。
(3) inactivate: nil 说明什么操作都不做
(4) rebalance: 与1中相同
3. killed
(1) startup:将状态转换成remove
(2) kill: 与1中相同
(3) remove: 实际上是调用了 remove-storm!函数, 清楚topology在zk上的相关目录。
- (remove-storm! [this storm-id]
- (delete-node cluster-state (storm-task-root storm-id))
- (delete-node cluster-state (assignment-path storm-id))
- (remove-storm-base! this storm-id))
4. rebalancing
(1) startup:将状态转换成do-rebalance
(2) kill: 与1中相同
(3) do-rebalance: 实际上是重新将任务分配,与初始分配任务不同,它假设所有的任务都是活跃的,所有的端口都不要判断是否需要保留,也就是说所有的任务重新分配,无论某些端口上的任务分配已经满足均衡要求。
Twitter Storm中Topology的状态的更多相关文章
- 关于Storm 中Topology的并发度的理解
来自:https://storm.apache.org/documentation/Understanding-the-parallelism-of-a-Storm-topology.html htt ...
- Twitter Storm中Bolt消息传递路径之源码解读
本文初次发表于storm-cn的google groups中,现以blog的方式再次发表,表明本人徽沪一郎确实读过这些代码,:). Bolt作为task被executor执行,而executor是一个 ...
- Twitter Storm源代码分析之ZooKeeper中的目录结构
徐明明博客:Twitter Storm源代码分析之ZooKeeper中的目录结构 我们知道Twitter Storm的所有的状态信息都是保存在Zookeeper里面,nimbus通过在zookeepe ...
- 在archlinux上搭建twitter storm cluster
本文详细描述如何在archlinux上搭建twitter storm cluster,转载请注明出处,谢谢. 有关archlinux基本系统安装,请参照archlinux简明安装指南一文,下面以上述为 ...
- twitter storm源码走读之1 -- nimbus启动场景分析
欢迎转载,转载时请注明作者徽沪一郎及出处,谢谢. 本文详细介绍了twitter storm中的nimbus节点的启动场景,分析nimbus是如何一步步实现定义于storm.thrift中的servic ...
- 【转】Twitter Storm: 在生产集群上运行topology
Twitter Storm: 在生产集群上运行topology 发表于 2011 年 10 月 07 日 由 xumingming 作者: xumingming | 可以转载, 但必须以超链接形式标明 ...
- Twitter Storm如何保证消息不丢失
storm保证从spout发出的每个tuple都会被完全处理.这篇文章介绍storm是怎么做到这个保证的,以及我们使用者怎么做才能充分利用storm的可靠性特点. 一个tuple被”完全处理”是什么意 ...
- Twitter Storm:单机环境的安装与配置
Twitter Storm:单机环境的安装与配置 好久没写博客了,这一段时间一直被导师push着做毕业设计.由于目前的方向偏向于图像识别检索,毕设打算做一个基于分布式计算平台的图像检索系统,查阅相关资 ...
- Storm入门(五)Twitter Storm如何保证消息不丢失
转自:http://xumingming.sinaapp.com/127/twitter-storm如何保证消息不丢失/ storm保证从spout发出的每个tuple都会被完全处理.这篇文章介绍st ...
随机推荐
- Git初次使用,记录自己看
Git官网下载:https://git-scm.com/downloads 官网如果太慢,可以去这下载:http://www.wmzhe.com/soft-38801.html,注意选择如下图地址下载 ...
- CentOS7-Minimal安装MySQL服务
CentOS7默认安装的是Mariadb而不是mysql,而Mariadb是mysql的一个分支, 安装mysql会覆盖Mariadb 一.下载MySQL官方的 Yum Repository [roo ...
- matlab之原始处理图像几何变换
(一)图像几何变换理论知识 (1)图像的平移与比例 图像的平移很简单,平移前后的坐标分别为(x,y)和(x',y'),则满足的关系式为 x'= x +Tx: y'= y +Ty: 其中Tx与Ty分别为 ...
- Leetcode166. Fraction to Recurring Decimal分数到小数
给定两个整数,分别表示分数的分子 numerator 和分母 denominator,以字符串形式返回小数. 如果小数部分为循环小数,则将循环的部分括在括号内. 示例 1: 输入: numerator ...
- openSUSE 安装compass,mkmf.rb can't find,checking for ffi.h...extconf.rb failed
安装compass时,提示 Fetching: sass-.gem (%) Successfully installed sass- Fetching: ffi-.gem (%) Building n ...
- AMPQ
AMPQ AMQP,即Advanced Message Queuing Protocol,高级消息队列协议, 是`应用层协议的一个开放标准,为面向消息的中间件设计`. 由于AMQP是一个网络协议,所以 ...
- Python3基础笔记_字典
# Python3 字典 dict = {'} # 1.访问字典里的值 ,字典中没有key会报错 # 2.修改字典 print("修改之前:", dict['Beth']) dic ...
- csps模拟68d,e,f题解
题面:https://www.cnblogs.com/Juve/articles/11655531.html 三道数据结构? d: 贪心,先按a排序,然后枚举删了前i个a值比较小的,然后在剩下的里面删 ...
- splay区间翻转
原题P3391 [模板]文艺平衡树(Splay) 题目背景 这是一道经典的Splay模板题——文艺平衡树. 题目描述 您需要写一种数据结构(可参考题目标题),来维护一个有序数列,其中需要提供以下操作: ...
- 杂项-公司:Apple
ylbtech-杂项-公司:Apple 苹果公司(Apple Inc. )是美国的一家高科技公司.由史蒂夫·乔布斯.斯蒂夫·沃兹尼亚克和罗·韦恩(Ron Wayne)等人于1976年4月1日创立,并命 ...