@InterfaceAudience.Private public interface LoadBalancer extends Stoppable, ConfigurationObserver
balanceCluster(Map).
On cluster startup, bulk assignment can be used to determine locations for all Regions in a
cluster.
This class produces plans for the AssignmentManager to execute.
About locking:
setMasterServices(MasterServices) and then initialize()
to initialize the balancer, and before calling initialize(), we will never call any
methods of this balancer. So these two methods do not need to be synchronized.balanceCluster(Map) method will use the ClusterMetrics which is set by
updateClusterMetrics(ClusterMetrics), and also lots of configurations, which could be
changed by onConfigurationChange(Configuration), so the easier way is to make these
three methods synchronized. And since there will be only one balancing thread, this will not
impact performance too much.roundRobinAssignment(List, List), retainAssignment(Map, List) and
randomAssignment(RegionInfo, List) could be called from multiple threads concurrently,
so these three methods should not be synchronized, the implementation classes need to make sure
that they are thread safe.| Modifier and Type | Field and Description |
|---|---|
static ServerName |
BOGUS_SERVER_NAME |
static String |
HBASE_RSGROUP_LOADBALANCER_CLASS
Deprecated.
since 3.0.0, will be removed in 4.0.0. In the new implementation, as the base load
balancer will always be the rs group based one, you should just use
HConstants.HBASE_MASTER_LOADBALANCER_CLASS to
config the per group load balancer. |
static String |
MOVE_THROTTLING
Configuration to determine the time to sleep when throttling (if throttling is implemented by
the underlying implementation).
|
static Duration |
MOVE_THROTTLING_DEFAULT
The default value, in milliseconds, for the hbase.master.balancer.move.throttlingMillis if
throttling is implemented.
|
static String |
SYSTEM_TABLES_ON_MASTER
Deprecated.
since 2.4.0, will be removed in 3.0.0.
|
static String |
TABLES_ON_MASTER
Deprecated.
since 2.4.0, will be removed in 3.0.0.
|
| Modifier and Type | Method and Description |
|---|---|
List<RegionPlan> |
balanceCluster(Map<TableName,Map<ServerName,List<RegionInfo>>> loadOfAllTable)
Perform the major balance operation for cluster.
|
void |
initialize()
Initialize the load balancer.
|
static boolean |
isMasterCanHostUserRegions(org.apache.hadoop.conf.Configuration conf)
Deprecated.
since 2.4.0, will be removed in 3.0.0.
|
static boolean |
isSystemTablesOnlyOnMaster(org.apache.hadoop.conf.Configuration conf)
Deprecated.
since 2.4.0, will be removed in 3.0.0.
|
static boolean |
isTablesOnMaster(org.apache.hadoop.conf.Configuration conf)
Deprecated.
since 2.4.0, will be removed in 3.0.0.
|
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.
|
ServerName |
randomAssignment(RegionInfo regionInfo,
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 |
setMasterServices(MasterServices masterServices)
Set the master service.
|
default void |
throttle(RegionPlan plan) |
default void |
updateBalancerLoadInfo(Map<TableName,Map<ServerName,List<RegionInfo>>> loadOfAllTable)
In some scenarios, Balancer needs to update internal status or information according to the
current tables load
|
void |
updateBalancerStatus(boolean status) |
void |
updateClusterMetrics(ClusterMetrics metrics)
Set the current cluster status.
|
@Deprecated static final String TABLES_ON_MASTER
@Deprecated static final String SYSTEM_TABLES_ON_MASTER
static final ServerName BOGUS_SERVER_NAME
@Deprecated static final String HBASE_RSGROUP_LOADBALANCER_CLASS
HConstants.HBASE_MASTER_LOADBALANCER_CLASS to
config the per group load balancer.static final String MOVE_THROTTLING
static final Duration MOVE_THROTTLING_DEFAULT
void updateClusterMetrics(ClusterMetrics metrics)
void setMasterServices(MasterServices masterServices)
List<RegionPlan> balanceCluster(Map<TableName,Map<ServerName,List<RegionInfo>>> loadOfAllTable) throws IOException
loadOfAllTable - region load of servers for all tableIOException@NonNull Map<ServerName,List<RegionInfo>> roundRobinAssignment(List<RegionInfo> regions, List<ServerName> servers) throws HBaseIOException
HBaseIOException@NonNull Map<ServerName,List<RegionInfo>> retainAssignment(Map<RegionInfo,ServerName> regions, List<ServerName> servers) throws HBaseIOException
HBaseIOExceptionServerName randomAssignment(RegionInfo regionInfo, List<ServerName> servers) throws HBaseIOException
regionInfo - Region for which this selection is being done.HBaseIOExceptionvoid initialize()
throws HBaseIOException
HBaseIOExceptionvoid regionOnline(RegionInfo regionInfo, ServerName sn)
void regionOffline(RegionInfo regionInfo)
void onConfigurationChange(org.apache.hadoop.conf.Configuration conf)
onConfigurationChange in interface ConfigurationObservervoid postMasterStartupInitialize()
void updateBalancerStatus(boolean status)
default void updateBalancerLoadInfo(Map<TableName,Map<ServerName,List<RegionInfo>>> loadOfAllTable)
loadOfAllTable - region load of servers for all tabledefault void throttle(RegionPlan plan) throws Exception
Exception@Deprecated static boolean isTablesOnMaster(org.apache.hadoop.conf.Configuration conf)
@Deprecated static boolean isSystemTablesOnlyOnMaster(org.apache.hadoop.conf.Configuration conf)
@Deprecated static boolean isMasterCanHostUserRegions(org.apache.hadoop.conf.Configuration conf)
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.