@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:
setClusterInfoProvider(ClusterInfoProvider)
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. |
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.
|
void |
onConfigurationChange(org.apache.hadoop.conf.Configuration conf)
Notification that config has changed
|
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 |
setClusterInfoProvider(ClusterInfoProvider provider)
Set the cluster info provider.
|
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.
|
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.void updateClusterMetrics(ClusterMetrics metrics)
void setClusterInfoProvider(ClusterInfoProvider provider)
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 IOException
IOException
@NonNull Map<ServerName,List<RegionInfo>> retainAssignment(Map<RegionInfo,ServerName> regions, List<ServerName> servers) throws IOException
IOException
ServerName randomAssignment(RegionInfo regionInfo, List<ServerName> servers) throws IOException
regionInfo
- Region for which this selection is being done.IOException
void initialize() throws IOException
IOException
void regionOnline(RegionInfo regionInfo, ServerName sn)
void regionOffline(RegionInfo regionInfo)
void onConfigurationChange(org.apache.hadoop.conf.Configuration conf)
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 tableCopyright © 2007–2020 The Apache Software Foundation. All rights reserved.