Esempio n. 1
0
  public void rebalance() {
    int rebalanceDelay = 20;
    int activateDelay = 10;

    save();

    // deactivate();
    // timer.schedule(new ActivateTask(this), (rebalanceDelay + activateDelay) * 1000);

    // prevent nimbus from getting confused
    // if (localCluster != null) {
    // 	deactivate();
    // 	timer.schedule(new ActivateTask(this), (rebalanceDelay + activateDelay) * 1000);
    // }

    LOG.info("parallelism rebalance " + System.currentTimeMillis());
    for (String component : parallelism.keySet()) {
      LOG.info("parallelism " + component + " " + parallelism.get(component));
    }

    RebalanceOptions options = new RebalanceOptions();
    options.set_num_executors(parallelism);
    options.set_wait_secs(rebalanceDelay);
    try {
      System.out.println("REBALANCING: " + parallelism);
      if (localCluster != null) {
        localCluster.rebalance(topologyName, options);
      } else {
        NimbusClient client = NimbusClient.getConfiguredClient(stormConf);
        client.getClient().rebalance(topologyName, options);
      }
    } catch (Exception e) {
      System.out.println("rebalance() exception: " + e.toString());
    }
  }
Esempio n. 2
0
  /**
   * rebalance one topology @@@ rebalance options hasn't implements
   *
   * <p>It is used to let workers wait several seconds to finish jobs
   *
   * @param topologyname String
   * @param options RebalanceOptions
   */
  @Override
  public void rebalance(String topologyName, RebalanceOptions options)
      throws NotAliveException, TException, InvalidTopologyException {

    try {

      checkTopologyActive(data, topologyName, true);
      Integer wait_amt = null;
      if (options != null && options.is_set_wait_secs()) {
        wait_amt = options.get_wait_secs();
      }

      NimbusUtils.transitionName(data, topologyName, true, StatusType.rebalance, wait_amt);
    } catch (NotAliveException e) {
      String errMsg = "Rebalance Error, no this topology " + topologyName;
      LOG.error(errMsg, e);
      throw new NotAliveException(errMsg);
    } catch (Exception e) {
      String errMsg = "Failed to rebalance topology " + topologyName;
      LOG.error(errMsg, e);
      throw new TException(errMsg);
    }
  }