@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| Modifier and Type | Field and Description |
|---|---|
protected static String |
KEEP_REGION_LOADS |
protected static String |
MAX_RUNNING_TIME_KEY |
protected static String |
MAX_STEPS_KEY |
protected static String |
STEPS_PER_REGION_KEY |
clusterStatus, config, masterServerName, metricsBalancer, rackManager, regionFinder, services, slop, TABLES_ON_MASTER, tablesOnMaster| Constructor and Description |
|---|
StochasticLoadBalancer() |
| Modifier and Type | Method and Description |
|---|---|
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<HRegionInfo>> clusterState)
Given the cluster state this will try and approach an optimal balance.
|
protected double |
computeCost(BaseLoadBalancer.Cluster cluster,
double previousCost)
This is the main cost function.
|
protected void |
initCosts(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. |
void |
setClusterStatus(ClusterStatus 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) |
assignMasterRegions, balanceMasterRegions, createCluster, getConf, getRegionAssignmentsByServer, getTablesOnMaster, immediateAssignment, initialize, isStopped, needsBalance, randomAssignment, regionOffline, regionOnline, retainAssignment, roundRobinAssignment, setRackManager, shouldBeOnMaster, stop, tablesOnMasterprotected static final String STEPS_PER_REGION_KEY
protected static final String MAX_STEPS_KEY
protected static final String MAX_RUNNING_TIME_KEY
protected static final String KEEP_REGION_LOADS
public void onConfigurationChange(org.apache.hadoop.conf.Configuration conf)
ConfigurationObserverConfigurationManager
object when the Configuration object is reloaded from disk.onConfigurationChange in interface ConfigurationObserveronConfigurationChange in interface LoadBalanceronConfigurationChange in class BaseLoadBalancerpublic void setConf(org.apache.hadoop.conf.Configuration conf)
setConf in interface org.apache.hadoop.conf.ConfigurablesetConf in class BaseLoadBalancerprotected void setSlop(org.apache.hadoop.conf.Configuration conf)
setSlop in class BaseLoadBalancerpublic void setClusterStatus(ClusterStatus st)
LoadBalancersetClusterStatus in interface LoadBalancersetClusterStatus in class BaseLoadBalancerpublic void setMasterServices(MasterServices masterServices)
LoadBalancersetMasterServices in interface LoadBalancersetMasterServices in class BaseLoadBalancerprotected boolean areSomeRegionReplicasColocated(BaseLoadBalancer.Cluster c)
BaseLoadBalancerareSomeRegionReplicasColocated in class BaseLoadBalancerc - Cluster informationpublic List<RegionPlan> balanceCluster(Map<ServerName,List<HRegionInfo>> clusterState)
protected void initCosts(BaseLoadBalancer.Cluster cluster)
protected void updateCostsWithAction(BaseLoadBalancer.Cluster cluster, BaseLoadBalancer.Cluster.Action action)
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–2016 The Apache Software Foundation. All rights reserved.