Search in sources :

Example 1 with Nimbus

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);
            }
        }
    });
}
Also used : NimbusClient(org.apache.storm.utils.NimbusClient) List(java.util.List) Nimbus(org.apache.storm.generated.Nimbus) KillOptions(org.apache.storm.generated.KillOptions)

Example 2 with Nimbus

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);
        }
    });
}
Also used : NimbusClient(org.apache.storm.utils.NimbusClient) Nimbus(org.apache.storm.generated.Nimbus) Map(java.util.Map) HashMap(java.util.HashMap) RebalanceOptions(org.apache.storm.generated.RebalanceOptions)

Example 3 with Nimbus

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);
        }
    });
}
Also used : HashMap(java.util.HashMap) NimbusClient(org.apache.storm.utils.NimbusClient) LogLevel(org.apache.storm.generated.LogLevel) Nimbus(org.apache.storm.generated.Nimbus) Map(java.util.Map) HashMap(java.util.HashMap) LogConfig(org.apache.storm.generated.LogConfig)

Aggregations

Nimbus (org.apache.storm.generated.Nimbus)3 NimbusClient (org.apache.storm.utils.NimbusClient)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 List (java.util.List)1 KillOptions (org.apache.storm.generated.KillOptions)1 LogConfig (org.apache.storm.generated.LogConfig)1 LogLevel (org.apache.storm.generated.LogLevel)1 RebalanceOptions (org.apache.storm.generated.RebalanceOptions)1