@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 |
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)
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)
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 nn * @return List of plans
|
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 |
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
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
HBaseIOException
ServerName randomAssignment(RegionInfo regionInfo, List<ServerName> servers) throws HBaseIOException
regionInfo
- Region for which this selection is being done. nnHBaseIOException
void initialize() throws HBaseIOException
HBaseIOException
void regionOnline(RegionInfo regionInfo, ServerName sn)
void regionOffline(RegionInfo regionInfo)
void onConfigurationChange(org.apache.hadoop.conf.Configuration conf)
ConfigurationObserver
ConfigurationManager
object when the
Configuration
object is reloaded from disk.onConfigurationChange
in interface ConfigurationObserver
void postMasterStartupInitialize()
void updateBalancerStatus(boolean status)
default void updateBalancerLoadInfo(Map<TableName,Map<ServerName,List<RegionInfo>>> loadOfAllTable)
loadOfAllTable
- region load of servers for all table@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.