如何以编程方式杀死风暴拓扑? [英] How to programmatically kill a storm topology?

查看:130
本文介绍了如何以编程方式杀死风暴拓扑?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用java类向Storm集群提交拓扑,我还计划使用java类来终止拓扑。但是根据风暴文档,以下命令用于终止拓扑并且没有Java方法(这有正当理由)

I am using a java class to submit a topology to the storm cluster and I also plan to use java class to kill the topology. But as per storm documentation, the following command is used to kill a topology and there is no Java method (and this has valid reasons)

storm kill {stormname}

那么从java类调用shell脚本来终止拓扑是没关系的吗?什么是杀死拓扑的其他方法?

So is it fine to call a shell script from java class to kill the topology? What are the other ways to kill topology?

此外,如何获得在风暴群集中运行拓扑的状态?

Also, how to get the status of running topologies in storm cluster?

推荐答案

对于查杀拓扑,你可以试试这个

For killing topology you can try this

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

Map conf = Utils.readStormConfig();
Client client = NimbusClient.getConfiguredClient(conf).getClient();
KillOptions killOpts = new KillOptions();
//killOpts.set_wait_secs(waitSeconds); // time to wait before killing
client.killTopologyWithOpts(topology_name, killOpts); //provide topology name

获取拓扑运行状态

Client client = NimbusClient.getConfiguredClient(conf).getClient();
List<TopologySummary> topologyList = client.getClusterInfo.get_topologies();
// loop through the list and check if the required topology name is present in the list
// if not it's not running

这篇关于如何以编程方式杀死风暴拓扑?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆