How to call a particular method before killing a storm topology

江枫思渺然 提交于 2019-11-28 04:21:25

问题


How to call a particular method before killing a storm topology.

I have created a topology in storm, I wanted to call particular method, just before topology gets killed.

is there any predefined overridden or any method available to do this in storm framework.

Thanks in advance:)


回答1:


There is no such thing...

As a workaround, you can deactivate the topology before killing it. This ensures, that Spout.deactivate() is called.

If you need to call a method at bolts, use Spout.deactivate() to sent a "notification tuple" (that does not contain data to be processed) through the whole topology. And in each bolt, call your special method if a "notification tuple" is received.

Furthermore, this "notification tuple" must be forwarded by the bolt to all its predecessors. You need to make sure, that the "notification tuples" is sent to all parallel executors of each bolt. For this, use a dedicated "notification stream" and subscribe each bolt via allGrouping() to this steam (in addition to the regular input streams). Within each bolt, you need to check if the tuple is a notification tuple or not (for example via Tuple.getSourceStreamId())

After clean up is finished, you can kill the topology finally.



来源:https://stackoverflow.com/questions/32117845/how-to-call-a-particular-method-before-killing-a-storm-topology

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!