@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.| Modifier and Type | Field and Description |
|---|---|
static String |
BALANCER_DECISION_BUFFER_ENABLED |
static String |
BALANCER_REJECTION_BUFFER_ENABLED |
protected ClusterMetrics |
clusterStatus |
static boolean |
DEFAULT_BALANCER_DECISION_BUFFER_ENABLED |
static boolean |
DEFAULT_BALANCER_REJECTION_BUFFER_ENABLED |
static boolean |
DEFAULT_HBASE_MASTER_LOADBALANCE_BYTABLE |
protected boolean |
isByTable |
protected ServerName |
masterServerName |
protected MetricsBalancer |
metricsBalancer |
protected static int |
MIN_SERVER_BALANCE |
protected boolean |
onlySystemTablesOnMaster
Deprecated.
since 2.4.0, will be removed in 3.0.0.
|
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| Modifier | Constructor and Description |
|---|---|
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
|
| Modifier and Type | Method and Description |
|---|---|
protected Map<ServerName,List<RegionInfo>> |
assignMasterSystemRegions(Collection<RegionInfo> regions,
List<ServerName> servers)
Deprecated.
since 2.4.0, will be removed in 3.0.0.
|
List<RegionPlan> |
balanceCluster(Map<TableName,Map<ServerName,List<RegionInfo>>> loadOfAllTable)
Perform the major balance operation for cluster, will invoke
balanceTable(TableName, Map) to do actual balance. |
protected List<RegionPlan> |
balanceMasterRegions(Map<ServerName,List<RegionInfo>> clusterMap)
Deprecated.
since 2.4.0, will be removed in 3.0.0.
|
protected abstract List<RegionPlan> |
balanceTable(TableName tableName,
Map<ServerName,List<RegionInfo>> loadOfOneTable)
Perform the major balance operation for table, all sub classes should override this method.
|
protected org.apache.hadoop.conf.Configuration |
getConf() |
protected float |
getDefaultSlop() |
protected boolean |
idleRegionServerExist(org.apache.hadoop.hbase.master.balancer.BalancerClusterState c) |
void |
initialize()
Initialize the load balancer.
|
boolean |
isStopped() |
protected void |
loadConf(org.apache.hadoop.conf.Configuration conf) |
void |
onConfigurationChange(org.apache.hadoop.conf.Configuration conf) |
void |
postMasterStartupInitialize()
If balancer needs to do initialization after Master has started up, lets do that here.
|
protected void |
preBalanceCluster(Map<TableName,Map<ServerName,List<RegionInfo>>> loadOfAllTable)
Called before actually executing balanceCluster.
|
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 |
setMasterServices(MasterServices masterServices)
Set the master service.
|
boolean |
shouldBeOnMaster(RegionInfo region)
Deprecated.
since 2.4.0, will be removed in 3.0.0.
|
protected boolean |
sloppyRegionServerExist(ClusterLoadState cs) |
void |
stop(String why) |
protected Map<ServerName,List<RegionInfo>> |
toEnsumbleTableLoad(Map<TableName,Map<ServerName,List<RegionInfo>>> LoadOfAllTable) |
void |
updateBalancerStatus(boolean status)
Updates the balancer status tag reported to JMX
|
void |
updateClusterMetrics(ClusterMetrics st)
Set the current cluster status.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitisMasterCanHostUserRegions, isSystemTablesOnlyOnMaster, isTablesOnMaster, updateBalancerLoadInfopublic static final String BALANCER_DECISION_BUFFER_ENABLED
public static final boolean DEFAULT_BALANCER_DECISION_BUFFER_ENABLED
public static final String BALANCER_REJECTION_BUFFER_ENABLED
public static final boolean DEFAULT_BALANCER_REJECTION_BUFFER_ENABLED
public static final boolean DEFAULT_HBASE_MASTER_LOADBALANCE_BYTABLE
protected static final int MIN_SERVER_BALANCE
protected volatile org.apache.hadoop.hbase.master.balancer.RegionLocationFinder regionFinder
protected boolean useRegionFinder
protected boolean isByTable
protected float slop
protected volatile RackManager rackManager
protected MetricsBalancer metricsBalancer
protected ClusterMetrics clusterStatus
protected ServerName masterServerName
protected MasterServices services
@Deprecated protected boolean onlySystemTablesOnMaster
protected BaseLoadBalancer()
protected BaseLoadBalancer(MetricsBalancer metricsBalancer)
protected final org.apache.hadoop.conf.Configuration getConf()
@Deprecated public boolean shouldBeOnMaster(RegionInfo region)
@Deprecated protected List<RegionPlan> balanceMasterRegions(Map<ServerName,List<RegionInfo>> clusterMap)
@Deprecated @NonNull protected Map<ServerName,List<RegionInfo>> assignMasterSystemRegions(Collection<RegionInfo> regions, List<ServerName> servers)
public void updateClusterMetrics(ClusterMetrics st)
LoadBalancerupdateClusterMetrics in interface LoadBalancerpublic void setMasterServices(MasterServices masterServices)
LoadBalancersetMasterServices in interface LoadBalancerpublic void postMasterStartupInitialize()
LoadBalancerpostMasterStartupInitialize in interface LoadBalancerprotected final boolean idleRegionServerExist(org.apache.hadoop.hbase.master.balancer.BalancerClusterState c)
protected final boolean sloppyRegionServerExist(ClusterLoadState cs)
@NonNull public Map<ServerName,List<RegionInfo>> roundRobinAssignment(List<RegionInfo> regions, List<ServerName> servers) throws HBaseIOException
roundRobinAssignment in interface LoadBalancerregions - all regionsservers - all serversHBaseIOExceptionpublic ServerName randomAssignment(RegionInfo regionInfo, List<ServerName> servers) throws HBaseIOException
randomAssignment in interface LoadBalancerregionInfo - Region for which this selection is being done.HBaseIOException@NonNull public 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 in interface LoadBalancerregions - regions and existing assignment from metaservers - available serversHBaseIOExceptionprotected float getDefaultSlop()
protected void loadConf(org.apache.hadoop.conf.Configuration conf)
public void initialize()
LoadBalancerinitialize in interface LoadBalancerpublic void regionOnline(RegionInfo regionInfo, ServerName sn)
LoadBalancerregionOnline in interface LoadBalancerpublic void regionOffline(RegionInfo regionInfo)
LoadBalancerregionOffline in interface LoadBalancerpublic void updateBalancerStatus(boolean status)
updateBalancerStatus in interface LoadBalancerprotected final Map<ServerName,List<RegionInfo>> toEnsumbleTableLoad(Map<TableName,Map<ServerName,List<RegionInfo>>> LoadOfAllTable)
protected abstract List<RegionPlan> balanceTable(TableName tableName, Map<ServerName,List<RegionInfo>> loadOfOneTable)
balanceCluster(Map). If
HConstants.HBASE_MASTER_LOADBALANCE_BYTABLE is enabled, we will call this method
multiple times, one table a time, where we will only pass in the regions for a single table
each time. If not, we will pass in all the regions at once, and the tableName will be
HConstants.ENSEMBLE_TABLE_NAME.tableName - the table to be balancedloadOfOneTable - region load of servers for the specific one tableprotected void preBalanceCluster(Map<TableName,Map<ServerName,List<RegionInfo>>> loadOfAllTable)
public final List<RegionPlan> balanceCluster(Map<TableName,Map<ServerName,List<RegionInfo>>> loadOfAllTable)
balanceTable(TableName, Map) to do actual balance.
THIs method is marked as final which means you should not override this method. See the javadoc
for balanceTable(TableName, Map) for more details.balanceCluster in interface LoadBalancerloadOfAllTable - region load of servers for all tablebalanceTable(TableName, Map)public void onConfigurationChange(org.apache.hadoop.conf.Configuration conf)
onConfigurationChange in interface ConfigurationObserveronConfigurationChange in interface LoadBalancerCopyright © 2007–2020 The Apache Software Foundation. All rights reserved.