org.apache.hadoop.hbase.master.balancer
Class StochasticLoadBalancer

java.lang.Object
  extended by org.apache.hadoop.hbase.master.balancer.BaseLoadBalancer
      extended by org.apache.hadoop.hbase.master.balancer.StochasticLoadBalancer
All Implemented Interfaces:
org.apache.hadoop.conf.Configurable, LoadBalancer

@InterfaceAudience.Private
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.


Field Summary
 
Fields inherited from class org.apache.hadoop.hbase.master.balancer.BaseLoadBalancer
services
 
Constructor Summary
StochasticLoadBalancer()
           
 
Method Summary
 List<RegionPlan> balanceCluster(Map<ServerName,List<HRegionInfo>> clusterState)
          Given the cluster state this will try and approach an optimal balance.
protected  double computeCost(Map<HRegionInfo,ServerName> initialRegionMapping, Map<ServerName,List<HRegionInfo>> clusterState)
          This is the main cost function.
 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.
 
Methods inherited from class org.apache.hadoop.hbase.master.balancer.BaseLoadBalancer
getConf, immediateAssignment, needsBalance, randomAssignment, retainAssignment, roundRobinAssignment
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StochasticLoadBalancer

public StochasticLoadBalancer()
Method Detail

setConf

public void setConf(org.apache.hadoop.conf.Configuration conf)
Specified by:
setConf in interface org.apache.hadoop.conf.Configurable
Overrides:
setConf in class BaseLoadBalancer

setClusterStatus

public void setClusterStatus(ClusterStatus st)
Description copied from interface: LoadBalancer
Set the current cluster status. This allows a LoadBalancer to map host name to a server

Specified by:
setClusterStatus in interface LoadBalancer
Overrides:
setClusterStatus in class BaseLoadBalancer

setMasterServices

public void setMasterServices(MasterServices masterServices)
Description copied from interface: LoadBalancer
Set the master service.

Specified by:
setMasterServices in interface LoadBalancer
Overrides:
setMasterServices in class BaseLoadBalancer

balanceCluster

public List<RegionPlan> balanceCluster(Map<ServerName,List<HRegionInfo>> clusterState)
Given the cluster state this will try and approach an optimal balance. This should always approach the optimal state given enough steps.

Returns:
List of plans

computeCost

protected double computeCost(Map<HRegionInfo,ServerName> initialRegionMapping,
                             Map<ServerName,List<HRegionInfo>> clusterState)
This is the main cost function. It will compute a cost associated with a proposed cluster state. All different costs will be combined with their multipliers to produce a double cost.

Parameters:
initialRegionMapping - Map of where the regions started.
clusterState - Map of ServerName to list of regions.
Returns:
a double of a cost associated with the proposed


Copyright © 2013 The Apache Software Foundation. All Rights Reserved.