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

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

问题描述

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

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

我在 Storm 中创建了一个拓扑,我想在拓扑被杀死之前调用特定的方法.

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

在storm框架中是否有任何预定义的覆盖或任何方法可以做到这一点.

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

提前致谢:)

推荐答案

没有这样的东西...

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

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

如果你需要在 bolts 调用一个方法,使用 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.

此外,这个通知元组"必须由bolt转发给它的所有前辈.您需要确保将通知元组"发送到每个螺栓的所有并行执行器.为此,请使用专用的通知流"并通过 allGrouping() 将每个 Bolt 订阅到此流(除了常规输入流).在每个 bolt 中,您需要检查元组是否是通知元组(例如通过 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天全站免登陆