@InterfaceAudience.LimitedPrivate(value="Configuration") public class SimpleLoadBalancer extends BaseLoadBalancer
Cluster-wide load balancing will occur only when there are no regions in
 transition and according to a fixed period of a time using balanceCluster(Map).
 
On cluster startup, bulk assignment can be used to determine locations for all Regions in a cluster.
This classes produces plans for the
 AssignmentManager to execute.
| Modifier and Type | Class and Description | 
|---|---|
| (package private) static class  | SimpleLoadBalancer.BalanceInfoStores additional per-server information about the regions added/removed
 during the run of the balancing algorithm. | 
BaseLoadBalancer.Cluster| Modifier and Type | Field and Description | 
|---|---|
| private float | avgLoadOverall | 
| private static org.slf4j.Logger | LOG | 
| private static Random | RANDOM | 
| private RegionInfoComparator | riComparator | 
| private RegionPlan.RegionPlanComparator | rpComparator | 
| private List<ServerAndLoad> | serverLoadList | 
BALANCER_DECISION_BUFFER_ENABLED, clusterStatus, config, DEFAULT_BALANCER_DECISION_BUFFER_ENABLED, IDLE_SERVER_PREDICATOR, isByTable, maintenanceMode, masterServerName, metricsBalancer, MIN_SERVER_BALANCE, namedQueueRecorder, onlySystemTablesOnMaster, overallSlop, rackManager, regionFinder, services, slop, useRegionFinderBOGUS_SERVER_NAME, SYSTEM_TABLES_ON_MASTER, TABLES_ON_MASTER| Constructor and Description | 
|---|
| SimpleLoadBalancer() | 
| Modifier and Type | Method and Description | 
|---|---|
| private void | addRegionPlan(org.apache.hbase.thirdparty.com.google.common.collect.MinMaxPriorityQueue<RegionPlan> regionsToMove,
             boolean fetchFromTail,
             ServerName sn,
             List<RegionPlan> regionsToReturn)Add a region from the head or tail to the List of regions to return. | 
| List<RegionPlan> | balanceCluster(Map<TableName,Map<ServerName,List<RegionInfo>>> loadOfAllTable)Override to invoke  setClusterLoad(java.util.Map<org.apache.hadoop.hbase.TableName, java.util.Map<org.apache.hadoop.hbase.ServerName, java.util.List<org.apache.hadoop.hbase.client.RegionInfo>>>)before balance, We need clusterLoad of all regions
 on every server to achieve overall balanced | 
| void | balanceOverall(List<RegionPlan> regionsToReturn,
              Map<ServerName,SimpleLoadBalancer.BalanceInfo> serverBalanceInfo,
              boolean fetchFromTail,
              org.apache.hbase.thirdparty.com.google.common.collect.MinMaxPriorityQueue<RegionPlan> regionsToMove,
              int max,
              int min)If we need to balanceoverall, we need to add one more round to peel off one region from each max. | 
| List<RegionPlan> | balanceTable(TableName tableName,
            Map<ServerName,List<RegionInfo>> loadOfOneTable)Generate a global load balancing plan according to the specified map of
 server information to the most loaded regions of each server. | 
| void | onConfigurationChange(org.apache.hadoop.conf.Configuration conf)This method would be called by the  ConfigurationManagerobject when theConfigurationobject is reloaded from disk. | 
| private boolean | overallNeedsBalance()A checker function to decide when we want balance overall and certain table has been balanced,
 do we still need to re-distribute regions of this table to achieve the state of overall-balance | 
| (package private) void | setClusterLoad(Map<TableName,Map<ServerName,List<RegionInfo>>> clusterLoad)Pass RegionStates and allow balancer to set the current cluster load. | 
| private void | setLoad(List<ServerAndLoad> slList,
       int i,
       int loadChange) | 
areSomeRegionReplicasColocated, assignMasterSystemRegions, balanceMasterRegions, createCluster, getConf, getRegionAssignmentsByServer, idleRegionServerExist, initialize, isStopped, needsBalance, postMasterStartupInitialize, randomAssignment, regionOffline, regionOnline, retainAssignment, roundRobinAssignment, setClusterMetrics, setConf, setMasterServices, setRackManager, setSlop, shouldBeOnMaster, stop, updateBalancerStatusclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitisMasterCanHostUserRegions, isSystemTablesOnlyOnMaster, isTablesOnMasterprivate static final org.slf4j.Logger LOG
private RegionInfoComparator riComparator
private RegionPlan.RegionPlanComparator rpComparator
private float avgLoadOverall
private List<ServerAndLoad> serverLoadList
public SimpleLoadBalancer()
void setClusterLoad(Map<TableName,Map<ServerName,List<RegionInfo>>> clusterLoad)
public void onConfigurationChange(org.apache.hadoop.conf.Configuration conf)
ConfigurationObserverConfigurationManager
 object when the Configuration object is reloaded from disk.onConfigurationChange in interface ConfigurationObserveronConfigurationChange in interface LoadBalanceronConfigurationChange in class BaseLoadBalancerprivate void setLoad(List<ServerAndLoad> slList, int i, int loadChange)
private boolean overallNeedsBalance()
public List<RegionPlan> balanceTable(TableName tableName, Map<ServerName,List<RegionInfo>> loadOfOneTable)
Order the regions to move from most recent to least.
balanceTable in interface LoadBalancerbalanceTable in class BaseLoadBalancerloadOfOneTable - Map of regionservers and their load/region information to
                   a list of their most loaded regionstableName - the table to be balancedpublic void balanceOverall(List<RegionPlan> regionsToReturn, Map<ServerName,SimpleLoadBalancer.BalanceInfo> serverBalanceInfo, boolean fetchFromTail, org.apache.hbase.thirdparty.com.google.common.collect.MinMaxPriorityQueue<RegionPlan> regionsToMove, int max, int min)
private void addRegionPlan(org.apache.hbase.thirdparty.com.google.common.collect.MinMaxPriorityQueue<RegionPlan> regionsToMove, boolean fetchFromTail, ServerName sn, List<RegionPlan> regionsToReturn)
public List<RegionPlan> balanceCluster(Map<TableName,Map<ServerName,List<RegionInfo>>> loadOfAllTable)
setClusterLoad(java.util.Map<org.apache.hadoop.hbase.TableName, java.util.Map<org.apache.hadoop.hbase.ServerName, java.util.List<org.apache.hadoop.hbase.client.RegionInfo>>>) before balance, We need clusterLoad of all regions
 on every server to achieve overall balancedbalanceCluster in interface LoadBalancerbalanceCluster in class BaseLoadBalancerloadOfAllTable - region load of servers for all tableCopyright © 2007–2021 The Apache Software Foundation. All rights reserved.