@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| Modifier and Type | Field and Description |
|---|---|
private FavoredNodesPlan |
globalFavoredNodesAssignmentPlan |
private static org.apache.commons.logging.Log |
LOG |
private RackManager |
rackManager |
clusterStatus, config, masterServerName, metricsBalancer, regionFinder, services, slop, TABLES_ON_MASTER, tablesOnMaster| Constructor and Description |
|---|
FavoredNodeLoadBalancer() |
areSomeRegionReplicasColocated, assignMasterRegions, balanceMasterRegions, createCluster, getConf, getRegionAssignmentsByServer, getTablesOnMaster, immediateAssignment, initialize, isStopped, needsBalance, onConfigurationChange, regionOffline, regionOnline, retainAssignment, setClusterStatus, setMasterServices, setRackManager, setSlop, shouldBeOnMaster, stop, tablesOnMasterprivate static final org.apache.commons.logging.Log LOG
private FavoredNodesPlan globalFavoredNodesAssignmentPlan
private RackManager rackManager
public void setConf(org.apache.hadoop.conf.Configuration conf)
setConf in interface org.apache.hadoop.conf.ConfigurablesetConf in class BaseLoadBalancerpublic List<RegionPlan> balanceCluster(Map<ServerName,List<HRegionInfo>> clusterState)
LoadBalancerpublic Map<ServerName,List<HRegionInfo>> roundRobinAssignment(List<HRegionInfo> regions, List<ServerName> servers)
BaseLoadBalancerTakes 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 LoadBalancerroundRobinAssignment in class BaseLoadBalancerregions - all regionsservers - all serverspublic ServerName randomAssignment(HRegionInfo regionInfo, List<ServerName> servers)
BaseLoadBalancerrandomAssignment in interface LoadBalancerrandomAssignment in class BaseLoadBalancerregionInfo - Region for which this selection is being done.private Pair<Map<ServerName,List<HRegionInfo>>,List<HRegionInfo>> segregateRegionsAndAssignRegionsWithFavoredNodes(List<HRegionInfo> regions, List<ServerName> availableServers)
private ServerName availableServersContains(List<ServerName> servers, ServerName favoredNode)
private void assignRegionToAvailableFavoredNode(Map<ServerName,List<HRegionInfo>> assignmentMapForFavoredNodes, HRegionInfo region, ServerName primaryHost, ServerName secondaryHost, ServerName tertiaryHost)
private void addRegionToMap(Map<ServerName,List<HRegionInfo>> assignmentMapForFavoredNodes, HRegionInfo region, ServerName host)
public List<ServerName> getFavoredNodes(HRegionInfo regionInfo)
private void roundRobinAssignmentImpl(FavoredNodeAssignmentHelper assignmentHelper, Map<ServerName,List<HRegionInfo>> assignmentMap, List<HRegionInfo> regions, List<ServerName> servers)
private void assignSecondaryAndTertiaryNodesForRegion(FavoredNodeAssignmentHelper assignmentHelper, List<HRegionInfo> regions, Map<HRegionInfo,ServerName> primaryRSMap)
Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.