Java – how to programmatically kill a storm topology?
•
Java
I'm using a Java class to submit a topology to the storm cluster, and I'm also going to use a Java class to kill the topology However, according to the storm documentation, the following command is used to kill the topology, and there is no Java method (for a legitimate reason)
storm kill {stormname}
So can you call a shell script from a Java class to kill the topology? What are the other ways to kill the topology?
In addition, how to get the status of running topology in storm cluster?
Solution
To kill the 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
Get topology status run
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
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码