Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can a storm topology be deactivated and reactivated by a spout or a bolt?

When certain conditions are met, like encountering a special type of tuple, I want to deactivate the topology . Is this can be done in spout/bolt ? And if yes, is there any way to reactivate the topology from spout/bolt too ?

like image 928
Nitin Avatar asked Nov 01 '22 19:11

Nitin


1 Answers

I have added all three actions in bolow code to activate/deactivate/kill. This can be called from independent java code (outside spout/bolt).

Deactivate from spout or bolt is straight forward but reactivating would be tricky as your spout/bolt is not actively running java program once deactivated.

import backtype.storm.generated.KillOptions;
import backtype.storm.generated.Nimbus.Client;
import backtype.storm.utils.NimbusClient;
import backtype.storm.utils.Utils;

Client client = NimbusClient.getConfiguredClient(Utils.readStormConfig()).getClient();

client.activate(topologyName);
client.deactivate(topologyName);

KillOptions killOpts = new KillOptions();
killOpts.set_wait_secs(30);
client.killTopologyWithOpts(topologyName, killOpts);
like image 126
Wadi Avatar answered Nov 08 '22 09:11

Wadi