I am using a Java class to submit a topology to a Storm cluster and I also plan to use a 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}
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
To get the status of topology running
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