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

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

@InterfaceAudience.LimitedPrivate(value="Configuration")
public class FavoredNodeLoadBalancer
extends BaseLoadBalancer

An implementation of the LoadBalancer that assigns favored nodes for each region. There is a Primary RegionServer that hosts the region, and then there is Secondary and Tertiary RegionServers. Currently, the favored nodes information is used in creating HDFS files - the Primary RegionServer passes the primary, secondary, tertiary node addresses as hints to the DistributedFileSystem API for creating files on the filesystem. These nodes are treated as hints by the HDFS to place the blocks of the file. This alleviates the problem to do with reading from remote nodes (since we can make the Secondary RegionServer as the new Primary RegionServer) after a region is recovered. This should help provide consistent read latencies for the regions even when their primary region servers die.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.hadoop.hbase.master.balancer.BaseLoadBalancer
BaseLoadBalancer.Cluster
 
Field Summary
 
Fields inherited from class org.apache.hadoop.hbase.master.balancer.BaseLoadBalancer
metricsBalancer, services, slop
 
Constructor Summary
FavoredNodeLoadBalancer()
           
 
Method Summary
 List<RegionPlan> balanceCluster(Map<ServerName,List<HRegionInfo>> clusterState)
          Perform the major balance operation
 List<ServerName> getFavoredNodes(HRegionInfo regionInfo)
           
 ServerName randomAssignment(HRegionInfo regionInfo, List<ServerName> servers)
          Used to assign a single region to a random server.
 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 setConf(org.apache.hadoop.conf.Configuration conf)
           
 
Methods inherited from class org.apache.hadoop.hbase.master.balancer.BaseLoadBalancer
getConf, immediateAssignment, initialize, isStopped, needsBalance, regionOffline, regionOnline, retainAssignment, setClusterStatus, setMasterServices, setSlop, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FavoredNodeLoadBalancer

public FavoredNodeLoadBalancer()
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

balanceCluster

public List<RegionPlan> balanceCluster(Map<ServerName,List<HRegionInfo>> clusterState)
Description copied from interface: LoadBalancer
Perform the major balance operation

Returns:
List of plans

roundRobinAssignment

public Map<ServerName,List<HRegionInfo>> roundRobinAssignment(List<HRegionInfo> regions,
                                                              List<ServerName> servers)
Description copied from class: BaseLoadBalancer
Generates a bulk assignment plan to be used on cluster startup using a simple round-robin assignment.

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

Specified by:
roundRobinAssignment in interface LoadBalancer
Overrides:
roundRobinAssignment in class BaseLoadBalancer
Parameters:
regions - all regions
servers - all servers
Returns:
map of server to the regions it should take, or null if no assignment is possible (ie. no regions or no servers)

randomAssignment

public ServerName randomAssignment(HRegionInfo regionInfo,
                                   List<ServerName> servers)
Description copied from class: BaseLoadBalancer
Used to assign a single region to a random server.

Specified by:
randomAssignment in interface LoadBalancer
Overrides:
randomAssignment in class BaseLoadBalancer
Parameters:
regionInfo - Region for which this selection is being done.
Returns:
Servername

getFavoredNodes

public List<ServerName> getFavoredNodes(HRegionInfo regionInfo)


Copyright © 2007–2016 The Apache Software Foundation. All rights reserved.