use of org.apache.storm.generated.Nimbus 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).arg("TOPO", CLI.INTO_LIST).parse(args);
final List<String> names = (List<String>) cl.get("TOPO");
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.Client nimbus) throws Exception {
for (String name : names) {
nimbus.killTopologyWithOpts(name, opts);
LOG.info("Killed topology: {}", name);
}
}
});
}
use of org.apache.storm.generated.Nimbus in project storm by apache.
the class Rebalance method main.
public static void main(String[] args) throws Exception {
Map<String, Object> cl = CLI.opt("w", "wait", null, CLI.AS_INT).opt("n", "num-workers", null, CLI.AS_INT).opt("e", "executor", null, new ExecutorParser(), CLI.INTO_MAP).arg("topologyName", CLI.FIRST_WINS).parse(args);
final String name = (String) cl.get("topologyName");
final RebalanceOptions rebalanceOptions = new RebalanceOptions();
Integer wait = (Integer) cl.get("w");
Integer numWorkers = (Integer) cl.get("n");
Map<String, Integer> numExecutors = (Map<String, Integer>) cl.get("e");
if (null != wait) {
rebalanceOptions.set_wait_secs(wait);
}
if (null != numWorkers) {
rebalanceOptions.set_num_workers(numWorkers);
}
if (null != numExecutors) {
rebalanceOptions.set_num_executors(numExecutors);
}
NimbusClient.withConfiguredClient(new NimbusClient.WithNimbus() {
@Override
public void run(Nimbus.Client nimbus) throws Exception {
nimbus.rebalance(name, rebalanceOptions);
LOG.info("Topology {} is rebalancing", name);
}
});
}
use of org.apache.storm.generated.Nimbus in project storm by apache.
the class SetLogLevel method main.
public static void main(String[] args) throws Exception {
Map<String, Object> cl = CLI.opt("l", "log-setting", null, new LogLevelsParser(LogLevelAction.UPDATE), CLI.INTO_MAP).opt("r", "remove-log-setting", null, new LogLevelsParser(LogLevelAction.REMOVE), CLI.INTO_MAP).arg("topologyName", CLI.FIRST_WINS).parse(args);
final String topologyName = (String) cl.get("topologyName");
final LogConfig logConfig = new LogConfig();
Map<String, LogLevel> logLevelMap = new HashMap<>();
Map<String, LogLevel> updateLogLevel = (Map<String, LogLevel>) cl.get("l");
if (null != updateLogLevel) {
logLevelMap.putAll(updateLogLevel);
}
Map<String, LogLevel> removeLogLevel = (Map<String, LogLevel>) cl.get("r");
if (null != removeLogLevel) {
logLevelMap.putAll(removeLogLevel);
}
for (Map.Entry<String, LogLevel> entry : logLevelMap.entrySet()) {
logConfig.put_to_named_logger_level(entry.getKey(), entry.getValue());
}
NimbusClient.withConfiguredClient(new NimbusClient.WithNimbus() {
@Override
public void run(Nimbus.Client nimbus) throws Exception {
String topologyId = Utils.getTopologyId(topologyName, nimbus);
if (null == topologyId) {
throw new IllegalArgumentException(topologyName + " is not a running topology");
}
nimbus.setLogConfig(topologyId, logConfig);
LOG.info("Log config {} is sent for topology {}", logConfig, topologyName);
}
});
}
Aggregations