如何在杀死风暴拓扑之前调用特定方法 [英] How to call a particular method before killing a storm topology

查看:175
本文介绍了如何在杀死风暴拓扑之前调用特定方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在杀死风暴拓扑之前调用特定方法。

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.

提前致谢:)

推荐答案

没有这样的事情......

There is no such thing...

作为解决方法,您可以在杀死拓扑之前停用拓扑。这确保调用 Spout.deactivate()

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

如果需要在螺栓上调用方法,使用 Spout.deactivate()通过整个拓扑发送通知元组(不包含要处理的数据)。如果收到通知元组,则在每个螺栓中调用您的特殊方法。

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.

此外,此通知元组必须通过螺栓转发给其所有前辈。您需要确保将通知元组发送到每个螺栓的所有并行执行器。为此,使用专用的通知流并通过 allGrouping()订阅每个螺栓到此steam(除了常规输入流)。在每个螺栓中,您需要检查元组是否是通知元组(例如通过 Tuple.getSourceStreamId()

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.

这篇关于如何在杀死风暴拓扑之前调用特定方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆