diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/HConstants.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/HConstants.java index 10a38f63c3a1..5320f5cc046c 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/HConstants.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/HConstants.java @@ -133,6 +133,9 @@ public enum OperationStatusCode { /** Cluster is in distributed mode or not */ public static final String CLUSTER_DISTRIBUTED = "hbase.cluster.distributed"; + /** Config for balancing the cluster parallel*/ + public static final String BALANCE_PARALLEL_REGIONS = "hbase.master.balance.parallel.regions"; + /** Config for pluggable load balancers */ public static final String HBASE_MASTER_LOADBALANCER_CLASS = "hbase.master.loadbalancer.class"; diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java index 1791ce4c4a55..dcfdd7b482e5 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java @@ -409,6 +409,7 @@ public class HMaster extends HRegionServer implements MasterServices { // Cached clusterId on stand by masters to serve clusterID requests from clients. private final CachedClusterId cachedClusterId; + private int balanceParallelRegions; /** * Initializes the HMaster. The steps are as follows: @@ -484,6 +485,7 @@ public HMaster(final Configuration conf) throws IOException { this.activeMasterManager = createActiveMasterManager(zooKeeper, serverName, this); cachedClusterId = new CachedClusterId(this, conf); + this.balanceParallelRegions = conf.getInt(HConstants.BALANCE_PARALLEL_REGIONS, 5); } catch (Throwable t) { // Make sure we log the exception. HMaster is often started via reflection and the // cause of failed startup is lost. @@ -1763,10 +1765,9 @@ public boolean balance(boolean force) throws IOException { // ignore the force flag in that case boolean metaInTransition = assignmentManager.isMetaRegionInTransition(); List toPrint = regionsInTransition; - int max = 5; boolean truncated = false; - if (regionsInTransition.size() > max) { - toPrint = regionsInTransition.subList(0, max); + if (regionsInTransition.size() > this.balanceParallelRegions) { + toPrint = regionsInTransition.subList(0, this.balanceParallelRegions); truncated = true; } if (!force || metaInTransition) {