use of org.apache.storm.generated.KillOptions in project storm by apache.
the class UIHelpers method putTopologyKill.
/**
* putTopologyKill.
* @param client client
* @param id id
* @param waitTime waitTime
* @return putTopologyKill
* @throws TException TException
*/
public static Map<String, Object> putTopologyKill(Nimbus.Iface client, String id, String waitTime) throws TException {
GetInfoOptions getInfoOptions = new GetInfoOptions();
getInfoOptions.set_num_err_choice(NumErrorsChoice.NONE);
TopologyInfo topologyInfo = client.getTopologyInfoWithOpts(id, getInfoOptions);
KillOptions killOptions = new KillOptions();
killOptions.set_wait_secs(Integer.parseInt(waitTime));
client.killTopologyWithOpts(topologyInfo.get_name(), killOptions);
return getTopologyOpResponse(id, "kill");
}
use of org.apache.storm.generated.KillOptions in project storm by apache.
the class KillTopology method main.
public static void main(String[] args) throws Exception {
Map<String, Object> cl = CLI.opt("w", "wait", null, CLI.AS_INT).boolOpt("i", "ignore-errors").arg("TOPO", CLI.INTO_LIST).parse(args);
@SuppressWarnings("unchecked") final List<String> names = (List<String>) cl.get("TOPO");
// if '-i' is set, we'll try to kill every topology listed, even if an error occurs
Boolean continueOnError = (Boolean) cl.get("i");
errorCount = 0;
Iterator<String> iterator = names.iterator();
while (iterator.hasNext()) {
String name = iterator.next();
try {
Utils.validateTopologyName(name);
} catch (IllegalArgumentException e) {
if (!continueOnError) {
throw e;
} else {
iterator.remove();
errorCount += 1;
LOG.error("Format of topology name {} is not valid ", name);
}
}
}
if (names.isEmpty()) {
throw new RuntimeException("Failed to successfully kill " + errorCount + " topologies.");
}
// Wait this many seconds after deactivating topology before killing
Integer wait = (Integer) cl.get("w");
final KillOptions opts = new KillOptions();
if (wait != null) {
opts.set_wait_secs(wait);
}
NimbusClient.withConfiguredClient(new NimbusClient.WithNimbus() {
@Override
public void run(Nimbus.Iface nimbus) throws Exception {
for (String name : names) {
try {
nimbus.killTopologyWithOpts(name, opts);
LOG.info("Killed topology: {}", name);
} catch (Exception e) {
errorCount += 1;
if (!continueOnError) {
throw e;
} else {
LOG.error("Caught error killing topology '{}'; continuing as -i was passed.", name, e);
}
}
}
// If we failed to kill any topology, still exit with failure status
if (errorCount > 0) {
throw new RuntimeException("Failed to successfully kill " + errorCount + " topologies.");
}
}
});
}
use of org.apache.storm.generated.KillOptions in project storm by apache.
the class Helper method kill.
public static void kill(Nimbus.Iface client, String topoName) throws Exception {
KillOptions opts = new KillOptions();
opts.set_wait_secs(0);
client.killTopologyWithOpts(topoName, opts);
}
use of org.apache.storm.generated.KillOptions in project storm by apache.
the class HdfsSpoutTopology method kill.
// main
private static void kill(Nimbus.Iface client, String topologyName) throws Exception {
KillOptions opts = new KillOptions();
opts.set_wait_secs(0);
client.killTopologyWithOpts(topologyName, opts);
}
use of org.apache.storm.generated.KillOptions in project metron by apache.
the class ParserTopologyComponent method killTopology.
protected void killTopology() {
KillOptions ko = new KillOptions();
ko.set_wait_secs(0);
stormCluster.killTopologyWithOpts(getTopologyName(), ko);
try {
// Actually wait for it to die.
Thread.sleep(2000);
} catch (InterruptedException e) {
// Do nothing
}
}
Aggregations