org.apache.hadoop.hbase.master.balancer
Class FavoredNodeLoadBalancer
java.lang.Object
org.apache.hadoop.hbase.master.balancer.BaseLoadBalancer
org.apache.hadoop.hbase.master.balancer.FavoredNodeLoadBalancer
- All Implemented Interfaces:
- org.apache.hadoop.conf.Configurable, LoadBalancer
@InterfaceAudience.Private
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.
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
FavoredNodeLoadBalancer
public FavoredNodeLoadBalancer()
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 regionsservers
- 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 © 2013 The Apache Software Foundation. All Rights Reserved.