简体   繁体   中英

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 ?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM