@InterfaceAudience.Private public class RSGroupBasedLoadBalancer extends Object implements RSGroupableBalancer
| Modifier and Type | Field and Description | 
|---|---|
| private ClusterMetrics | clusterStatus | 
| private org.apache.hadoop.conf.Configuration | config | 
| private LoadBalancer | internalBalancer | 
| private static org.slf4j.Logger | LOG | 
| private MasterServices | masterServices | 
| private RSGroupInfoManager | rsGroupInfoManager | 
HBASE_RSGROUP_LOADBALANCER_CLASSBOGUS_SERVER_NAME, SYSTEM_TABLES_ON_MASTER, TABLES_ON_MASTER| Constructor and Description | 
|---|
| RSGroupBasedLoadBalancer()Used by reflection in  LoadBalancerFactory. | 
| Modifier and Type | Method and Description | 
|---|---|
| List<RegionPlan> | balanceCluster(Map<ServerName,List<RegionInfo>> clusterState)Perform the major balance operation | 
| List<RegionPlan> | balanceCluster(TableName tableName,
              Map<ServerName,List<RegionInfo>> clusterState)Perform the major balance operation | 
| private Map<ServerName,List<RegionInfo>> | correctAssignments(Map<ServerName,List<RegionInfo>> existingAssignments) | 
| private List<ServerName> | filterOfflineServers(RSGroupInfo RSGroupInfo,
                    List<ServerName> onlineServers) | 
| private List<ServerName> | filterServers(Set<Address> servers,
             List<ServerName> onlineServers)Filter servers based on the online servers. | 
| private ServerName | findServerForRegion(Map<ServerName,List<RegionInfo>> existingAssignments,
                   RegionInfo region) | 
| private void | generateGroupMaps(List<RegionInfo> regions,
                 List<ServerName> servers,
                 org.apache.hbase.thirdparty.com.google.common.collect.ListMultimap<String,RegionInfo> regionMap,
                 org.apache.hbase.thirdparty.com.google.common.collect.ListMultimap<String,ServerName> serverMap) | 
| org.apache.hadoop.conf.Configuration | getConf() | 
| void | initialize()Initialize the load balancer. | 
| boolean | isOnline() | 
| boolean | isStopped() | 
| void | onConfigurationChange(org.apache.hadoop.conf.Configuration conf)This method would be called by the  ConfigurationManagerobject when theConfigurationobject is reloaded from disk. | 
| void | postMasterStartupInitialize()If balancer needs to do initialization after Master has started up, lets do that here. | 
| ServerName | randomAssignment(RegionInfo region,
                List<ServerName> servers)Get a random region server from the list | 
| void | regionOffline(RegionInfo regionInfo)Marks the region as offline at balancer. | 
| void | regionOnline(RegionInfo regionInfo,
            ServerName sn)Marks the region as online at balancer. | 
| Map<ServerName,List<RegionInfo>> | retainAssignment(Map<RegionInfo,ServerName> regions,
                List<ServerName> servers)Assign regions to the previously hosting region server | 
| Map<ServerName,List<RegionInfo>> | roundRobinAssignment(List<RegionInfo> regions,
                    List<ServerName> servers)Perform a Round Robin assignment of regions. | 
| void | setClusterLoad(Map<TableName,Map<ServerName,List<RegionInfo>>> clusterLoad)Pass RegionStates and allow balancer to set the current cluster load. | 
| void | setClusterMetrics(ClusterMetrics sm)Set the current cluster status. | 
| void | setConf(org.apache.hadoop.conf.Configuration conf) | 
| void | setMasterServices(MasterServices masterServices)Set the master service. | 
| void | setRsGroupInfoManager(RSGroupInfoManager rsGroupInfoManager) | 
| void | stop(String why)Stop this service. | 
| void | updateBalancerStatus(boolean status) | 
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitisMasterCanHostUserRegions, isSystemTablesOnlyOnMaster, isTablesOnMasterprivate static final org.slf4j.Logger LOG
private org.apache.hadoop.conf.Configuration config
private ClusterMetrics clusterStatus
private MasterServices masterServices
private volatile RSGroupInfoManager rsGroupInfoManager
private LoadBalancer internalBalancer
@InterfaceAudience.Private public RSGroupBasedLoadBalancer()
LoadBalancerFactory.public org.apache.hadoop.conf.Configuration getConf()
getConf in interface org.apache.hadoop.conf.Configurablepublic void setConf(org.apache.hadoop.conf.Configuration conf)
setConf in interface org.apache.hadoop.conf.Configurablepublic void setClusterMetrics(ClusterMetrics sm)
LoadBalancersetClusterMetrics in interface LoadBalancerpublic void setMasterServices(MasterServices masterServices)
LoadBalancersetMasterServices in interface LoadBalancerpublic List<RegionPlan> balanceCluster(TableName tableName, Map<ServerName,List<RegionInfo>> clusterState) throws HBaseIOException
LoadBalancerbalanceCluster in interface LoadBalancerHBaseIOExceptionpublic List<RegionPlan> balanceCluster(Map<ServerName,List<RegionInfo>> clusterState) throws HBaseIOException
LoadBalancerbalanceCluster in interface LoadBalancerHBaseIOExceptionpublic Map<ServerName,List<RegionInfo>> roundRobinAssignment(List<RegionInfo> regions, List<ServerName> servers) throws HBaseIOException
LoadBalancerroundRobinAssignment in interface LoadBalancerHBaseIOExceptionpublic Map<ServerName,List<RegionInfo>> retainAssignment(Map<RegionInfo,ServerName> regions, List<ServerName> servers) throws HBaseIOException
LoadBalancerretainAssignment in interface LoadBalancerHBaseIOExceptionpublic ServerName randomAssignment(RegionInfo region, List<ServerName> servers) throws HBaseIOException
LoadBalancerrandomAssignment in interface LoadBalancerregion - Region for which this selection is being done.HBaseIOExceptionprivate void generateGroupMaps(List<RegionInfo> regions, List<ServerName> servers, org.apache.hbase.thirdparty.com.google.common.collect.ListMultimap<String,RegionInfo> regionMap, org.apache.hbase.thirdparty.com.google.common.collect.ListMultimap<String,ServerName> serverMap) throws HBaseIOException
HBaseIOExceptionprivate List<ServerName> filterOfflineServers(RSGroupInfo RSGroupInfo, List<ServerName> onlineServers)
private List<ServerName> filterServers(Set<Address> servers, List<ServerName> onlineServers)
RSGroupInfo), having
 its contains()'s time complexity as O(logn), which is good enough.
 
 TODO: consider using HashSet to pursue O(1) for contains() throughout the calling chain if
 needed.servers - the serversonlineServers - List of servers which are online.private ServerName findServerForRegion(Map<ServerName,List<RegionInfo>> existingAssignments, RegionInfo region)
private Map<ServerName,List<RegionInfo>> correctAssignments(Map<ServerName,List<RegionInfo>> existingAssignments) throws HBaseIOException
HBaseIOExceptionpublic void initialize() throws HBaseIOException
LoadBalancerinitialize in interface LoadBalancerHBaseIOExceptionpublic boolean isOnline()
public void setClusterLoad(Map<TableName,Map<ServerName,List<RegionInfo>>> clusterLoad)
LoadBalancersetClusterLoad in interface LoadBalancerpublic void regionOnline(RegionInfo regionInfo, ServerName sn)
LoadBalancerregionOnline in interface LoadBalancerpublic void regionOffline(RegionInfo regionInfo)
LoadBalancerregionOffline in interface LoadBalancerpublic void onConfigurationChange(org.apache.hadoop.conf.Configuration conf)
ConfigurationObserverConfigurationManager
 object when the Configuration object is reloaded from disk.onConfigurationChange in interface ConfigurationObserveronConfigurationChange in interface LoadBalancerpublic void stop(String why)
Stoppablepublic boolean isStopped()
isStopped in interface StoppableStoppable.stop(String) has been closed.public void setRsGroupInfoManager(RSGroupInfoManager rsGroupInfoManager)
public void postMasterStartupInitialize()
LoadBalancerpostMasterStartupInitialize in interface LoadBalancerpublic void updateBalancerStatus(boolean status)
updateBalancerStatus in interface LoadBalancerCopyright © 2007–2020 The Apache Software Foundation. All rights reserved.