public List<RegionPlan> executeRegionPlansWithThrottling(List<RegionPlan> plans) {
    List<RegionPlan> successRegionPlans = new ArrayList<>();
    int maxRegionsInTransition = getMaxRegionsInTransition();
    long balanceStartTime = EnvironmentEdgeManager.currentTime();
    long cutoffTime = balanceStartTime + this.maxBalancingTime;
    int rpCount = 0; // number of RegionPlans balanced so far
    if (plans != null && !plans.isEmpty()) {
      int balanceInterval = this.maxBalancingTime / plans.size();
      LOG.info(
        "Balancer plans size is " + plans.size() + ", the balance interval is " + balanceInterval
          + " ms, and the max number regions in transition is " + maxRegionsInTransition);

      for (RegionPlan plan : plans) {
        LOG.info("balance " + plan);
        // TODO: bulk assign
        try {
          this.assignmentManager.balance(plan);
          this.balancer.updateClusterMetrics(getClusterMetricsWithoutCoprocessor());
          this.balancer.throttle(plan);
        } catch (HBaseIOException hioe) {
          // should ignore failed plans here, avoiding the whole balance plans be aborted
          // later calls of balance() can fetch up the failed and skipped plans
          LOG.warn("Failed balance plan {}, skipping...", plan, hioe);
        } catch (Exception e) {
          LOG.warn("Failed throttling assigning a new plan.", e);
        }
        // rpCount records balance plans processed, does not care if a plan succeeds
        rpCount++;
        successRegionPlans.add(plan);

        if (this.maxBalancingTime > 0) {
          balanceThrottling(balanceStartTime + rpCount * balanceInterval, maxRegionsInTransition,
            cutoffTime);
        }

        // if performing next balance exceeds cutoff time, exit the loop
        if (
          this.maxBalancingTime > 0 && rpCount < plans.size()
            && EnvironmentEdgeManager.currentTime() > cutoffTime
        ) {
          // TODO: After balance, there should not be a cutoff time (keeping it as
          // a security net for now)
          LOG.debug(
            "No more balancing till next balance run; maxBalanceTime=" + this.maxBalancingTime);
          break;
        }
      }
    }
    LOG.debug("Balancer is going into sleep until next period in {}ms", getConfiguration()
      .getInt(HConstants.HBASE_BALANCER_PERIOD, HConstants.DEFAULT_HBASE_BALANCER_PERIOD));
    return successRegionPlans;
  }
Execute region plans with throttling
@param plans to execute
@return succeeded plans
hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java