Index: hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java =================================================================== --- hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java (revision 1381466) +++ hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java (working copy) @@ -24,6 +24,7 @@ import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.ClusterStatus; +import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.HRegionInfo; import org.apache.hadoop.hbase.ServerLoad; import org.apache.hadoop.hbase.RegionLoad; @@ -130,7 +131,7 @@ regionFinder.setConf(conf); maxSteps = conf.getInt(MAX_STEPS_KEY, maxSteps); - maxMoves = conf.getInt(MAX_MOVES_KEY, maxMoves); + maxMoves = conf.getInt(MAX_MOVES_KEY, conf.getInt(HConstants.BALANCER_MAX_REGIONS, maxMoves)); stepsPerRegion = conf.getInt(STEPS_PER_REGION_KEY, stepsPerRegion); // Load multiplier should be the greatest as it is the most general way to balance data. Index: hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java =================================================================== --- hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java (revision 1381466) +++ hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java (working copy) @@ -1239,6 +1239,7 @@ if (!this.balanceSwitch) return false; // Do this call outside of synchronized block. int maximumBalanceTime = getBalancerCutoffTime(); + int maximumRegionCount = getConfiguration().getInt(HConstants.BALANCER_MAX_REGIONS, -1); long cutoffTime = System.currentTimeMillis() + maximumBalanceTime; boolean balancerRan; synchronized (this.balancer) { @@ -1289,6 +1290,10 @@ this.assignmentManager.balance(plan); totalRegPlanExecTime += System.currentTimeMillis()-balStartTime; rpCount++; + if (maximumRegionCount > 0 && rpCount >= maximumRegionCount) { + LOG.debug("Balancer has moved " + rpCount + " regions, reaching limit for this iteration"); + break; + } if (rpCount < plans.size() && // if performing next balance exceeds cutoff time, exit the loop (System.currentTimeMillis() + (totalRegPlanExecTime / rpCount)) > cutoffTime) { Index: hbase-common/src/main/java/org/apache/hadoop/hbase/HConstants.java =================================================================== --- hbase-common/src/main/java/org/apache/hadoop/hbase/HConstants.java (revision 1381466) +++ hbase-common/src/main/java/org/apache/hadoop/hbase/HConstants.java (working copy) @@ -690,6 +690,9 @@ public static final String LOAD_BALANCER_SLOP_KEY = "hbase.regions.slop"; + /** maximum number of region to move in the single iteration of the balancer */ + public static final String BALANCER_MAX_REGIONS = "hbase.balancer.max.regions.periteration"; + /** * The byte array represents for NO_NEXT_INDEXED_KEY; * The actual value is irrelevant because this is always compared by reference.