|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.hadoop.hbase.master.balancer.BaseLoadBalancer
public abstract class BaseLoadBalancer
The base class for load balancers. It provides the the functions used to by
AssignmentManager to assign regions in the edge cases. It doesn't
provide an implementation of the actual balancing algorithm.
| Nested Class Summary | |
|---|---|
protected static class |
BaseLoadBalancer.Cluster
An efficient array based implementation similar to ClusterState for keeping the status of the cluster in terms of region assignment and distribution. |
| Field Summary | |
|---|---|
protected MetricsBalancer |
metricsBalancer
|
protected MasterServices |
services
|
protected float |
slop
|
| Constructor Summary | |
|---|---|
BaseLoadBalancer()
|
|
| Method Summary | |
|---|---|
org.apache.hadoop.conf.Configuration |
getConf()
|
Map<HRegionInfo,ServerName> |
immediateAssignment(List<HRegionInfo> regions,
List<ServerName> servers)
Generates an immediate assignment plan to be used by a new master for regions in transition that do not have an already known destination. |
void |
initialize()
Initialize the load balancer. |
boolean |
isStopped()
|
protected boolean |
needsBalance(ClusterLoadState cs)
|
ServerName |
randomAssignment(HRegionInfo regionInfo,
List<ServerName> servers)
Used to assign a single region to a random server. |
void |
regionOffline(HRegionInfo regionInfo)
Marks the region as offline at balancer. |
void |
regionOnline(HRegionInfo regionInfo,
ServerName sn)
Marks the region as online at balancer. |
Map<ServerName,List<HRegionInfo>> |
retainAssignment(Map<HRegionInfo,ServerName> regions,
List<ServerName> servers)
Generates a bulk assignment startup plan, attempting to reuse the existing assignment information from META, but adjusting for the specified list of available/online servers available for assignment. |
Map<ServerName,List<HRegionInfo>> |
roundRobinAssignment(List<HRegionInfo> regions,
List<ServerName> servers)
Generates a bulk assignment plan to be used on cluster startup using a simple round-robin assignment. |
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)
|
void |
stop(String why)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.apache.hadoop.hbase.master.LoadBalancer |
|---|
balanceCluster |
| Field Detail |
|---|
protected float slop
protected final MetricsBalancer metricsBalancer
protected MasterServices services
| Constructor Detail |
|---|
public BaseLoadBalancer()
| Method Detail |
|---|
public void setConf(org.apache.hadoop.conf.Configuration conf)
setConf in interface org.apache.hadoop.conf.Configurableprotected void setSlop(org.apache.hadoop.conf.Configuration conf)
public org.apache.hadoop.conf.Configuration getConf()
getConf in interface org.apache.hadoop.conf.Configurablepublic void setClusterStatus(ClusterStatus st)
LoadBalancer
setClusterStatus in interface LoadBalancerpublic void setMasterServices(MasterServices masterServices)
LoadBalancer
setMasterServices in interface LoadBalancerprotected boolean needsBalance(ClusterLoadState cs)
public Map<ServerName,List<HRegionInfo>> roundRobinAssignment(List<HRegionInfo> regions,
List<ServerName> servers)
Takes a list of all the regions and all the servers in the cluster and returns a map of each server to the regions that it should be assigned.
Currently implemented as a round-robin assignment. Same invariant as load balancing, all servers holding floor(avg) or ceiling(avg). TODO: Use block locations from HDFS to place regions with their blocks
roundRobinAssignment in interface LoadBalancerregions - all regionsservers - all servers
public Map<HRegionInfo,ServerName> immediateAssignment(List<HRegionInfo> regions,
List<ServerName> servers)
immediateAssignment in interface LoadBalancerregions - servers -
public ServerName randomAssignment(HRegionInfo regionInfo,
List<ServerName> servers)
randomAssignment in interface LoadBalancerregionInfo - Region for which this selection is being done.
public Map<ServerName,List<HRegionInfo>> retainAssignment(Map<HRegionInfo,ServerName> regions,
List<ServerName> servers)
Takes a map of all regions to their existing assignment from META. Also takes a list of online servers for regions to be assigned to. Attempts to retain all assignment, so in some instances initial assignment will not be completely balanced.
Any leftover regions without an existing server to be assigned to will be assigned randomly to available servers.
retainAssignment in interface LoadBalancerregions - regions and existing assignment from metaservers - available servers
public void initialize()
throws HBaseIOException
LoadBalancer
initialize in interface LoadBalancerHBaseIOException
public void regionOnline(HRegionInfo regionInfo,
ServerName sn)
LoadBalancer
regionOnline in interface LoadBalancerpublic void regionOffline(HRegionInfo regionInfo)
LoadBalancer
regionOffline in interface LoadBalancerpublic boolean isStopped()
isStopped in interface Stoppablepublic void stop(String why)
stop in interface Stoppable
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||