Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
963 views
in Technique[技术] by (71.8m points)

java - How to call a particular method before killing a storm topology

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:)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...