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 ?
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With