5

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 ?

Matthias J. Sax
  • 59,682
  • 7
  • 117
  • 137
Nitin
  • 165
  • 1
  • 9
  • `activate` and `deactivate` are just methods like `ack` or `nextTuple` in `ISpout` interface. Though I haven't deactivate/reactivate in a spout before, I guess it is possible. – halfelf Aug 04 '14 at 03:36
  • Interesting question, this would be useful for maintenance.. – Kit Menke Aug 04 '14 at 18:22
  • @halfelf activate and deactivate are nice plug ins, on which further implementation strategies can be made. But, i still think activating after deactivating will be quite hard, as reactivating strategy will be required to run even after the spout is deactivated. – Nitin Aug 05 '14 at 13:59

1 Answers1

2

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);
Wadi
  • 29
  • 5