@InterfaceAudience.LimitedPrivate(value="Configuration") public class StochasticLoadBalancer extends BaseLoadBalancer
This is a best effort load balancer. Given a Cost function F(C) => x It will randomly try and mutate the cluster to Cprime. If F(Cprime) < F(C) then the new cluster state becomes the plan. It includes costs functions to compute the cost of:
Every cost function returns a number between 0 and 1 inclusive; where 0 is the lowest cost best solution, and 1 is the highest possible cost and the worst solution. The computed costs are scaled by their respective multipliers:
In addition to the above configurations, the balancer can be tuned by the following configuration values:
This balancer is best used with hbase.master.loadbalance.bytable set to false so that the balancer gets the full picture of all loads on the cluster.
BaseLoadBalancer.Cluster| 限定符和类型 | 字段和说明 |
|---|---|
protected static String |
KEEP_REGION_LOADS |
protected static String |
MAX_RUNNING_TIME_KEY |
protected static String |
MAX_STEPS_KEY |
protected static String |
MIN_COST_NEED_BALANCE_KEY |
protected static Random |
RANDOM |
protected static String |
RUN_MAX_STEPS_KEY |
protected static String |
STEPS_PER_REGION_KEY |
clusterStatus, config, maintenanceMode, masterServerName, metricsBalancer, MIN_SERVER_BALANCE, onlySystemTablesOnMaster, overallSlop, rackManager, regionFinder, services, slop, useRegionFinderBOGUS_SERVER_NAME, SYSTEM_TABLES_ON_MASTER, TABLES_ON_MASTER| 构造器和说明 |
|---|
StochasticLoadBalancer()
The constructor that pass a MetricsStochasticBalancer to BaseLoadBalancer to replace its
default MetricsBalancer
|
| 限定符和类型 | 方法和说明 |
|---|---|
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
|
List<RegionPlan> |
balanceCluster(Map<ServerName,List<RegionInfo>> clusterState)
Given the cluster state this will try and approach an optimal balance.
|
List<RegionPlan> |
balanceCluster(TableName tableName,
Map<ServerName,List<RegionInfo>> clusterState)
Perform the major balance operation
|
static String |
composeAttributeName(String tableName,
String costFunctionName)
A helper function to compose the attribute name from tablename and costfunction name
|
protected double |
computeCost(BaseLoadBalancer.Cluster cluster,
double previousCost)
This is the main cost function.
|
String[] |
getCostFunctionNames()
Get the names of the cost functions
|
protected void |
initCosts(BaseLoadBalancer.Cluster cluster) |
protected boolean |
needsBalance(BaseLoadBalancer.Cluster cluster) |
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. |
protected void |
setCandidateGenerators(List<org.apache.hadoop.hbase.master.balancer.StochasticLoadBalancer.CandidateGenerator> customCandidateGenerators) |
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.
|
protected void |
setSlop(org.apache.hadoop.conf.Configuration conf) |
protected void |
updateCostsWithAction(BaseLoadBalancer.Cluster cluster,
BaseLoadBalancer.Cluster.Action action) |
void |
updateMetricsSize(int size)
Update the number of metrics that are reported to JMX
|
assignMasterSystemRegions, balanceMasterRegions, createCluster, getConf, getRegionAssignmentsByServer, initialize, isStopped, postMasterStartupInitialize, randomAssignment, regionOffline, regionOnline, retainAssignment, roundRobinAssignment, setClusterLoad, setRackManager, shouldBeOnMaster, stop, updateBalancerStatusclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitisMasterCanHostUserRegions, isSystemTablesOnlyOnMaster, isTablesOnMasterprotected static final Random RANDOM
public StochasticLoadBalancer()
public void onConfigurationChange(org.apache.hadoop.conf.Configuration conf)
ConfigurationObserverConfigurationManager
object when the Configuration object is reloaded from disk.onConfigurationChange 在接口中 ConfigurationObserveronConfigurationChange 在接口中 LoadBalanceronConfigurationChange 在类中 BaseLoadBalancerpublic void setConf(org.apache.hadoop.conf.Configuration conf)
setConf 在接口中 org.apache.hadoop.conf.ConfigurablesetConf 在类中 BaseLoadBalancerprotected void setCandidateGenerators(List<org.apache.hadoop.hbase.master.balancer.StochasticLoadBalancer.CandidateGenerator> customCandidateGenerators)
protected void setSlop(org.apache.hadoop.conf.Configuration conf)
setSlop 在类中 BaseLoadBalancerpublic void setClusterMetrics(ClusterMetrics st)
LoadBalancersetClusterMetrics 在接口中 LoadBalancersetClusterMetrics 在类中 BaseLoadBalancerpublic void updateMetricsSize(int size)
public void setMasterServices(MasterServices masterServices)
LoadBalancersetMasterServices 在接口中 LoadBalancersetMasterServices 在类中 BaseLoadBalancerprotected boolean areSomeRegionReplicasColocated(BaseLoadBalancer.Cluster c)
BaseLoadBalancerareSomeRegionReplicasColocated 在类中 BaseLoadBalancerc - Cluster informationprotected boolean needsBalance(BaseLoadBalancer.Cluster cluster)
needsBalance 在类中 BaseLoadBalancerpublic List<RegionPlan> balanceCluster(TableName tableName, Map<ServerName,List<RegionInfo>> clusterState)
LoadBalancerpublic List<RegionPlan> balanceCluster(Map<ServerName,List<RegionInfo>> clusterState)
protected void initCosts(BaseLoadBalancer.Cluster cluster)
protected void updateCostsWithAction(BaseLoadBalancer.Cluster cluster, BaseLoadBalancer.Cluster.Action action)
public String[] getCostFunctionNames()
protected double computeCost(BaseLoadBalancer.Cluster cluster, double previousCost)
cluster - The state of the clusterpreviousCost - the previous cost. This is used as an early out.Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.