@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:
You can also add custom Cost function by setting the the following configuration value:
All custom Cost Functions needs to extends CostFunction
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.
| Modifier and Type | Class and Description |
|---|---|
static class |
StochasticLoadBalancer.GeneratorType |
| Modifier and Type | Field and Description |
|---|---|
protected List<org.apache.hadoop.hbase.master.balancer.CandidateGenerator> |
candidateGenerators |
protected static String |
COST_FUNCTIONS_COST_FUNCTIONS_KEY |
protected static int |
DEFAULT_KEEP_REGION_LOADS |
protected static long |
DEFAULT_MAX_RUNNING_TIME |
protected static int |
DEFAULT_MAX_STEPS |
protected static float |
DEFAULT_MIN_COST_NEED_BALANCE |
protected static boolean |
DEFAULT_RUN_MAX_STEPS |
protected static int |
DEFAULT_STEPS_PER_REGION |
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 |
static String |
OVERALL_COST_FUNCTION_NAME |
protected static String |
RUN_MAX_STEPS_KEY |
protected static String |
STEPS_PER_REGION_KEY |
BALANCER_DECISION_BUFFER_ENABLED, BALANCER_REJECTION_BUFFER_ENABLED, clusterStatus, DEFAULT_BALANCER_DECISION_BUFFER_ENABLED, DEFAULT_BALANCER_REJECTION_BUFFER_ENABLED, DEFAULT_HBASE_MASTER_LOADBALANCE_BYTABLE, isByTable, masterServerName, metricsBalancer, MIN_SERVER_BALANCE, provider, rackManager, regionFinder, slop, useRegionFinderBOGUS_SERVER_NAME, HBASE_RSGROUP_LOADBALANCER_CLASS| Constructor and Description |
|---|
StochasticLoadBalancer()
The constructor that pass a MetricsStochasticBalancer to BaseLoadBalancer to replace its
default MetricsBalancer
|
StochasticLoadBalancer(MetricsStochasticBalancer metricsStochasticBalancer) |
| Modifier and Type | Method and Description |
|---|---|
protected List<RegionPlan> |
balanceTable(TableName tableName,
Map<ServerName,List<RegionInfo>> loadOfOneTable)
Given the cluster state this will try and approach an optimal balance.
|
protected List<org.apache.hadoop.hbase.master.balancer.CandidateGenerator> |
createCandidateGenerators() |
protected org.apache.hadoop.hbase.master.balancer.CandidateGenerator |
getRandomGenerator()
Select the candidate generator to use based on the cost of cost functions.
|
protected void |
loadConf(org.apache.hadoop.conf.Configuration conf) |
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 |
updateClusterMetrics(ClusterMetrics st)
Set the current cluster status.
|
balanceCluster, getConf, getDefaultSlop, idleRegionServerExist, initialize, isStopped, onConfigurationChange, postMasterStartupInitialize, preBalanceCluster, randomAssignment, regionOffline, regionOnline, retainAssignment, roundRobinAssignment, setClusterInfoProvider, sloppyRegionServerExist, stop, toEnsumbleTableLoad, updateBalancerStatusprotected static final String STEPS_PER_REGION_KEY
protected static final int DEFAULT_STEPS_PER_REGION
protected static final String MAX_STEPS_KEY
protected static final int DEFAULT_MAX_STEPS
protected static final String RUN_MAX_STEPS_KEY
protected static final boolean DEFAULT_RUN_MAX_STEPS
protected static final String MAX_RUNNING_TIME_KEY
protected static final long DEFAULT_MAX_RUNNING_TIME
protected static final String KEEP_REGION_LOADS
protected static final int DEFAULT_KEEP_REGION_LOADS
protected static final String MIN_COST_NEED_BALANCE_KEY
protected static final float DEFAULT_MIN_COST_NEED_BALANCE
protected static final String COST_FUNCTIONS_COST_FUNCTIONS_KEY
public static final String OVERALL_COST_FUNCTION_NAME
protected List<org.apache.hadoop.hbase.master.balancer.CandidateGenerator> candidateGenerators
public StochasticLoadBalancer()
public StochasticLoadBalancer(MetricsStochasticBalancer metricsStochasticBalancer)
protected List<org.apache.hadoop.hbase.master.balancer.CandidateGenerator> createCandidateGenerators()
protected void loadConf(org.apache.hadoop.conf.Configuration conf)
loadConf in class BaseLoadBalancerpublic void updateClusterMetrics(ClusterMetrics st)
LoadBalancerupdateClusterMetrics in interface LoadBalancerupdateClusterMetrics in class BaseLoadBalancerpublic void updateBalancerLoadInfo(Map<TableName,Map<ServerName,List<RegionInfo>>> loadOfAllTable)
LoadBalancerloadOfAllTable - region load of servers for all tableprotected org.apache.hadoop.hbase.master.balancer.CandidateGenerator getRandomGenerator()
protected List<RegionPlan> balanceTable(TableName tableName, Map<ServerName,List<RegionInfo>> loadOfOneTable)
balanceTable in class BaseLoadBalancertableName - the table to be balancedloadOfOneTable - region load of servers for the specific one tableCopyright © 2007–2020 The Apache Software Foundation. All rights reserved.