Search in sources :

Example 1 with RebalanceOptions

use of org.apache.storm.generated.RebalanceOptions 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 2 with RebalanceOptions

use of org.apache.storm.generated.RebalanceOptions in project storm by apache.

the class Nimbus method doRebalance.

void doRebalance(String topoId, StormBase stormBase) throws Exception {
    RebalanceOptions rbo = stormBase.get_topology_action_options().get_rebalance_options();
    StormBase updated = new StormBase();
    updated.set_topology_action_options(null);
    updated.set_component_debug(Collections.emptyMap());
    if (rbo.is_set_num_executors()) {
        updated.set_component_executors(rbo.get_num_executors());
    }
    if (rbo.is_set_num_workers()) {
        updated.set_num_workers(rbo.get_num_workers());
    }
    stormClusterState.updateStorm(topoId, updated);
    mkAssignments(topoId);
}
Also used : StormBase(org.apache.storm.generated.StormBase) RebalanceOptions(org.apache.storm.generated.RebalanceOptions)

Aggregations

RebalanceOptions (org.apache.storm.generated.RebalanceOptions)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Nimbus (org.apache.storm.generated.Nimbus)1 StormBase (org.apache.storm.generated.StormBase)1 NimbusClient (org.apache.storm.utils.NimbusClient)1