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

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

问题描述

我正在使用 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?

另外,如何获取storm集群中运行拓扑的状态?

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

推荐答案

杀拓扑可以试试这个

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天全站免登陆