简体   繁体   English

风暴拓扑是否可以通过喷口或螺栓停用并重新激活?

[英]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 ? 如果是,有没有办法从spout / bolt重新激活拓扑?

I have added all three actions in bolow code to activate/deactivate/kill. 我在bolow代码中添加了所有三个动作来激活/停用/终止。 This can be called from independent java code (outside spout/bolt). 这可以从独立的java代码(外部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. 从喷口或螺栓停用是直接的,但重新激活将是棘手的,因为你的喷口/螺栓一旦停用就没有主动运行java程序。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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