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);
}
});
}
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);
}
Aggregations