@InterfaceAudience.LimitedPrivate(value="Configuration") public class FavoredNodeLoadBalancer extends BaseLoadBalancer
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.BaseLoadBalancer.Cluster
metricsBalancer, services, slop
Constructor and Description |
---|
FavoredNodeLoadBalancer() |
Modifier and Type | Method and Description |
---|---|
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) |
getConf, immediateAssignment, initialize, isStopped, needsBalance, regionOffline, regionOnline, retainAssignment, setClusterStatus, setMasterServices, setSlop, stop
public void setConf(org.apache.hadoop.conf.Configuration conf)
setConf
in interface org.apache.hadoop.conf.Configurable
setConf
in class BaseLoadBalancer
public List<RegionPlan> balanceCluster(Map<ServerName,List<HRegionInfo>> clusterState)
LoadBalancer
public Map<ServerName,List<HRegionInfo>> roundRobinAssignment(List<HRegionInfo> regions, List<ServerName> servers)
BaseLoadBalancer
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 LoadBalancer
roundRobinAssignment
in class BaseLoadBalancer
regions
- all regionsservers
- all serverspublic ServerName randomAssignment(HRegionInfo regionInfo, List<ServerName> servers)
BaseLoadBalancer
randomAssignment
in interface LoadBalancer
randomAssignment
in class BaseLoadBalancer
regionInfo
- Region for which this selection is being done.public List<ServerName> getFavoredNodes(HRegionInfo regionInfo)
Copyright © 2014 The Apache Software Foundation. All rights reserved.