@InterfaceAudience.Private public abstract class BaseLoadBalancer extends Object implements LoadBalancer
AssignmentManager to assign regions
in the edge cases. It doesn't provide an implementation of the
actual balancing algorithm.| 限定符和类型 | 类和说明 |
|---|---|
protected static class |
BaseLoadBalancer.Cluster
An efficient array based implementation similar to ClusterState for keeping
the status of the cluster in terms of region assignment and distribution.
|
| 限定符和类型 | 字段和说明 |
|---|---|
protected ClusterMetrics |
clusterStatus |
protected org.apache.hadoop.conf.Configuration |
config |
protected boolean |
maintenanceMode |
protected ServerName |
masterServerName |
protected MetricsBalancer |
metricsBalancer |
protected static int |
MIN_SERVER_BALANCE |
protected boolean |
onlySystemTablesOnMaster |
protected float |
overallSlop |
protected RackManager |
rackManager |
protected org.apache.hadoop.hbase.master.balancer.RegionLocationFinder |
regionFinder |
protected MasterServices |
services |
protected float |
slop |
protected boolean |
useRegionFinder |
BOGUS_SERVER_NAME, SYSTEM_TABLES_ON_MASTER, TABLES_ON_MASTER| 限定符 | 构造器和说明 |
|---|---|
protected |
BaseLoadBalancer()
The constructor that uses the basic MetricsBalancer
|
protected |
BaseLoadBalancer(MetricsBalancer metricsBalancer)
This Constructor accepts an instance of MetricsBalancer,
which will be used instead of creating a new one
|
| 限定符和类型 | 方法和说明 |
|---|---|
protected boolean |
areSomeRegionReplicasColocated(BaseLoadBalancer.Cluster c)
Subclasses should implement this to return true if the cluster has nodes that hosts
multiple replicas for the same region, or, if there are multiple racks and the same
rack hosts replicas of the same region
|
protected Map<ServerName,List<RegionInfo>> |
assignMasterSystemRegions(Collection<RegionInfo> regions,
List<ServerName> servers)
If master is configured to carry system tables only, in here is
where we figure what to assign it.
|
protected List<RegionPlan> |
balanceMasterRegions(Map<ServerName,List<RegionInfo>> clusterMap)
Balance the regions that should be on master regionserver.
|
protected BaseLoadBalancer.Cluster |
createCluster(List<ServerName> servers,
Collection<RegionInfo> regions,
boolean hasRegionReplica) |
org.apache.hadoop.conf.Configuration |
getConf() |
protected Map<ServerName,List<RegionInfo>> |
getRegionAssignmentsByServer(Collection<RegionInfo> regions) |
void |
initialize()
Initialize the load balancer.
|
boolean |
isStopped() |
protected boolean |
needsBalance(BaseLoadBalancer.Cluster c) |
void |
onConfigurationChange(org.apache.hadoop.conf.Configuration conf)
This method would be called by the
ConfigurationManager
object when the Configuration object is reloaded from disk. |
void |
postMasterStartupInitialize()
If balancer needs to do initialization after Master has started up, lets do that here.
|
ServerName |
randomAssignment(RegionInfo regionInfo,
List<ServerName> servers)
Used to assign a single region to a random server.
|
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)
Generates a bulk assignment startup plan, attempting to reuse the existing
assignment information from META, but adjusting for the specified list of
available/online servers available for assignment.
|
Map<ServerName,List<RegionInfo>> |
roundRobinAssignment(List<RegionInfo> regions,
List<ServerName> servers)
Generates a bulk assignment plan to be used on cluster startup using a
simple round-robin assignment.
|
void |
setClusterLoad(Map<TableName,Map<ServerName,List<RegionInfo>>> clusterLoad)
Pass RegionStates and allow balancer to set the current cluster load.
|
void |
setClusterMetrics(ClusterMetrics st)
Set the current cluster status.
|
void |
setConf(org.apache.hadoop.conf.Configuration conf) |
void |
setMasterServices(MasterServices masterServices)
Set the master service.
|
void |
setRackManager(RackManager rackManager) |
protected void |
setSlop(org.apache.hadoop.conf.Configuration conf) |
boolean |
shouldBeOnMaster(RegionInfo region)
Check if a region belongs to some system table.
|
void |
stop(String why) |
void |
updateBalancerStatus(boolean status)
Updates the balancer status tag reported to JMX
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitbalanceCluster, balanceCluster, isMasterCanHostUserRegions, isSystemTablesOnlyOnMaster, isTablesOnMasterprotected static final int MIN_SERVER_BALANCE
protected org.apache.hadoop.hbase.master.balancer.RegionLocationFinder regionFinder
protected boolean useRegionFinder
protected float slop
protected float overallSlop
protected org.apache.hadoop.conf.Configuration config
protected RackManager rackManager
protected MetricsBalancer metricsBalancer
protected ClusterMetrics clusterStatus
protected ServerName masterServerName
protected MasterServices services
protected boolean onlySystemTablesOnMaster
protected boolean maintenanceMode
protected BaseLoadBalancer()
protected BaseLoadBalancer(MetricsBalancer metricsBalancer)
public void setConf(org.apache.hadoop.conf.Configuration conf)
setConf 在接口中 org.apache.hadoop.conf.Configurableprotected void setSlop(org.apache.hadoop.conf.Configuration conf)
public boolean shouldBeOnMaster(RegionInfo region)
protected List<RegionPlan> balanceMasterRegions(Map<ServerName,List<RegionInfo>> clusterMap)
protected Map<ServerName,List<RegionInfo>> assignMasterSystemRegions(Collection<RegionInfo> regions, List<ServerName> servers)
public org.apache.hadoop.conf.Configuration getConf()
getConf 在接口中 org.apache.hadoop.conf.Configurablepublic void setClusterMetrics(ClusterMetrics st)
LoadBalancersetClusterMetrics 在接口中 LoadBalancerpublic void setClusterLoad(Map<TableName,Map<ServerName,List<RegionInfo>>> clusterLoad)
LoadBalancersetClusterLoad 在接口中 LoadBalancerpublic void setMasterServices(MasterServices masterServices)
LoadBalancersetMasterServices 在接口中 LoadBalancerpublic void postMasterStartupInitialize()
LoadBalancerpostMasterStartupInitialize 在接口中 LoadBalancerpublic void setRackManager(RackManager rackManager)
protected boolean needsBalance(BaseLoadBalancer.Cluster c)
protected boolean areSomeRegionReplicasColocated(BaseLoadBalancer.Cluster c)
c - Cluster informationpublic Map<ServerName,List<RegionInfo>> roundRobinAssignment(List<RegionInfo> regions, List<ServerName> servers) throws HBaseIOException
Takes a list of all the regions and all the servers in the cluster and returns a map of each server to the regions that it should be assigned.
Currently implemented as a round-robin assignment. Same invariant as load balancing, all servers holding floor(avg) or ceiling(avg). TODO: Use block locations from HDFS to place regions with their blocks
roundRobinAssignment 在接口中 LoadBalancerregions - all regionsservers - all serversHBaseIOExceptionprotected BaseLoadBalancer.Cluster createCluster(List<ServerName> servers, Collection<RegionInfo> regions, boolean hasRegionReplica)
public ServerName randomAssignment(RegionInfo regionInfo, List<ServerName> servers) throws HBaseIOException
randomAssignment 在接口中 LoadBalancerregionInfo - Region for which this selection is being done.HBaseIOExceptionpublic Map<ServerName,List<RegionInfo>> retainAssignment(Map<RegionInfo,ServerName> regions, List<ServerName> servers) throws HBaseIOException
Takes a map of all regions to their existing assignment from META. Also takes a list of online servers for regions to be assigned to. Attempts to retain all assignment, so in some instances initial assignment will not be completely balanced.
Any leftover regions without an existing server to be assigned to will be assigned randomly to available servers.
retainAssignment 在接口中 LoadBalancerregions - regions and existing assignment from metaservers - available serversHBaseIOExceptionpublic void initialize()
throws HBaseIOException
LoadBalancerinitialize 在接口中 LoadBalancerHBaseIOExceptionpublic void regionOnline(RegionInfo regionInfo, ServerName sn)
LoadBalancerregionOnline 在接口中 LoadBalancerpublic void regionOffline(RegionInfo regionInfo)
LoadBalancerregionOffline 在接口中 LoadBalancerpublic void updateBalancerStatus(boolean status)
updateBalancerStatus 在接口中 LoadBalancerprotected Map<ServerName,List<RegionInfo>> getRegionAssignmentsByServer(Collection<RegionInfo> regions)
public void onConfigurationChange(org.apache.hadoop.conf.Configuration conf)
ConfigurationObserverConfigurationManager
object when the Configuration object is reloaded from disk.onConfigurationChange 在接口中 ConfigurationObserveronConfigurationChange 在接口中 LoadBalancerCopyright © 2007–2019 The Apache Software Foundation. All rights reserved.