@InterfaceAudience.LimitedPrivate(value="Configuration") public class FavoredNodeLoadBalancer extends BaseLoadBalancer implements FavoredNodesPromoter
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 org.apache.hadoop.conf.Configuration | conf | 
| private FavoredNodesManager | fnm | 
| private static org.slf4j.Logger | LOG | 
| private RackManager | rackManager | 
BALANCER_DECISION_BUFFER_ENABLED, clusterStatus, config, DEFAULT_BALANCER_DECISION_BUFFER_ENABLED, isByTable, maintenanceMode, masterServerName, metricsBalancer, MIN_SERVER_BALANCE, namedQueueRecorder, onlySystemTablesOnMaster, overallSlop, regionFinder, services, slop, useRegionFinderFAVORED_ALWAYS_ASSIGN_REGIONSBOGUS_SERVER_NAME, SYSTEM_TABLES_ON_MASTER, TABLES_ON_MASTER| Constructor and Description | 
|---|
| FavoredNodeLoadBalancer() | 
areSomeRegionReplicasColocated, assignMasterSystemRegions, balanceCluster, balanceMasterRegions, createCluster, getConf, getRegionAssignmentsByServer, idleRegionServerExist, isStopped, needsBalance, onConfigurationChange, postMasterStartupInitialize, regionOffline, regionOnline, retainAssignment, setClusterMetrics, setMasterServices, setRackManager, setSlop, shouldBeOnMaster, stop, updateBalancerStatusclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitisMasterCanHostUserRegions, isSystemTablesOnlyOnMaster, isTablesOnMasterprivate static final org.slf4j.Logger LOG
private RackManager rackManager
private org.apache.hadoop.conf.Configuration conf
private FavoredNodesManager fnm
public FavoredNodeLoadBalancer()
public void setConf(org.apache.hadoop.conf.Configuration conf)
setConf in interface org.apache.hadoop.conf.ConfigurablesetConf in class BaseLoadBalancerpublic void initialize() throws HBaseIOException
LoadBalancerinitialize in interface LoadBalancerinitialize in class BaseLoadBalancerHBaseIOExceptionpublic List<RegionPlan> balanceTable(TableName tableName, Map<ServerName,List<RegionInfo>> loadOfOneTable)
LoadBalancerLoadBalancer
 should override this methodbalanceTable in interface LoadBalancerbalanceTable in class BaseLoadBalancertableName - the table to be balancedloadOfOneTable - region load of servers for the specific one table@NonNull public Map<ServerName,List<RegionInfo>> roundRobinAssignment(List<RegionInfo> regions, List<ServerName> servers) throws HBaseIOException
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 serversHBaseIOExceptionpublic ServerName randomAssignment(RegionInfo regionInfo, List<ServerName> servers) throws HBaseIOException
BaseLoadBalancerrandomAssignment in interface LoadBalancerrandomAssignment in class BaseLoadBalancerregionInfo - Region for which this selection is being done.HBaseIOExceptionprivate Pair<Map<ServerName,List<RegionInfo>>,List<RegionInfo>> segregateRegionsAndAssignRegionsWithFavoredNodes(List<RegionInfo> regions, List<ServerName> availableServers)
private ServerName availableServersContains(List<ServerName> servers, ServerName favoredNode)
private void assignRegionToAvailableFavoredNode(Map<ServerName,List<RegionInfo>> assignmentMapForFavoredNodes, RegionInfo region, ServerName primaryHost, ServerName secondaryHost, ServerName tertiaryHost)
private void addRegionToMap(Map<ServerName,List<RegionInfo>> assignmentMapForFavoredNodes, RegionInfo region, ServerName host)
public List<ServerName> getFavoredNodes(RegionInfo regionInfo)
private void roundRobinAssignmentImpl(FavoredNodeAssignmentHelper assignmentHelper, Map<ServerName,List<RegionInfo>> assignmentMap, List<RegionInfo> regions, List<ServerName> servers) throws IOException
IOExceptionprivate void assignSecondaryAndTertiaryNodesForRegion(FavoredNodeAssignmentHelper assignmentHelper, List<RegionInfo> regions, Map<RegionInfo,ServerName> primaryRSMap) throws IOException
IOExceptionpublic void generateFavoredNodesForDaughter(List<ServerName> servers, RegionInfo parent, RegionInfo regionA, RegionInfo regionB) throws IOException
generateFavoredNodesForDaughter in interface FavoredNodesPromoterIOExceptionprivate Set<ServerName> getInheritedFNForDaughter(FavoredNodeAssignmentHelper helper, List<ServerName> parentFavoredNodes, FavoredNodesPlan.Position primary, FavoredNodesPlan.Position secondary) throws IOException
IOExceptionpublic void generateFavoredNodesForMergedRegion(RegionInfo merged, RegionInfo[] mergeParents) throws IOException
generateFavoredNodesForMergedRegion in interface FavoredNodesPromoterIOExceptionCopyright © 2007–2021 The Apache Software Foundation. All rights reserved.