Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 936
Kalpesh Avatar asked Aug 20 '15 12:08

Kalpesh


People also ask

Which of the following method of Storm topology is called when a spout is going to shutdown?

close − This method is called when a spout is going to shutdown. declareOutputFields − Declares the output schema of the tuple. fail − Specifies that a specific tuple is not processed and not to be reprocessed.

Which of the following method is used for performing transformation in Bolt Apache Storm?

The main method in bolts is the execute method which takes in as input a new tuple. Bolts emit new tuples using the OutputCollector object.

What is topology in Apache Storm?

Networks of spouts and bolts are packaged into a "topology" which is the top-level abstraction that you submit to Storm clusters for execution. A topology is a graph of stream transformations where each node is a spout or bolt. Edges in the graph indicate which bolts are subscribing to which streams.


1 Answers

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.

like image 89
Matthias J. Sax Avatar answered Sep 29 '22 20:09

Matthias J. Sax