@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.Modifier and Type | Field and Description |
---|---|
private FavoredNodesManager |
fnm |
private static org.slf4j.Logger |
LOG |
BALANCER_DECISION_BUFFER_ENABLED, BALANCER_REJECTION_BUFFER_ENABLED, clusterStatus, DEFAULT_BALANCER_DECISION_BUFFER_ENABLED, DEFAULT_BALANCER_REJECTION_BUFFER_ENABLED, DEFAULT_HBASE_MASTER_LOADBALANCE_BYTABLE, isByTable, masterServerName, metricsBalancer, MIN_SERVER_BALANCE, onlySystemTablesOnMaster, rackManager, regionFinder, services, slop, useRegionFinder
FAVORED_ALWAYS_ASSIGN_REGIONS
BOGUS_SERVER_NAME, SYSTEM_TABLES_ON_MASTER, TABLES_ON_MASTER
Constructor and Description |
---|
FavoredNodeLoadBalancer() |
assignMasterSystemRegions, balanceCluster, balanceMasterRegions, getConf, getDefaultSlop, idleRegionServerExist, isStopped, loadConf, onConfigurationChange, postMasterStartupInitialize, preBalanceCluster, regionOffline, regionOnline, retainAssignment, setMasterServices, shouldBeOnMaster, sloppyRegionServerExist, stop, toEnsumbleTableLoad, updateBalancerStatus, updateClusterMetrics
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
isMasterCanHostUserRegions, isSystemTablesOnlyOnMaster, isTablesOnMaster, updateBalancerLoadInfo
private static final org.slf4j.Logger LOG
private FavoredNodesManager fnm
public FavoredNodeLoadBalancer()
public void initialize()
LoadBalancer
initialize
in interface LoadBalancer
initialize
in class BaseLoadBalancer
protected List<RegionPlan> balanceTable(TableName tableName, Map<ServerName,List<RegionInfo>> loadOfOneTable)
BaseLoadBalancer
BaseLoadBalancer.balanceCluster(Map)
. If
HConstants.HBASE_MASTER_LOADBALANCE_BYTABLE
is enabled, we will call this method
multiple times, one table a time, where we will only pass in the regions for a single table
each time. If not, we will pass in all the regions at once, and the tableName
will be
HConstants.ENSEMBLE_TABLE_NAME
.balanceTable
in class BaseLoadBalancer
tableName
- 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
BaseLoadBalancer
roundRobinAssignment
in interface LoadBalancer
roundRobinAssignment
in class BaseLoadBalancer
regions
- all regionsservers
- all serversHBaseIOException
public ServerName randomAssignment(RegionInfo regionInfo, List<ServerName> servers) throws HBaseIOException
BaseLoadBalancer
randomAssignment
in interface LoadBalancer
randomAssignment
in class BaseLoadBalancer
regionInfo
- Region for which this selection is being done. nnHBaseIOException
private 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
IOException
private void assignSecondaryAndTertiaryNodesForRegion(FavoredNodeAssignmentHelper assignmentHelper, List<RegionInfo> regions, Map<RegionInfo,ServerName> primaryRSMap) throws IOException
IOException
public void generateFavoredNodesForDaughter(List<ServerName> servers, RegionInfo parent, RegionInfo regionA, RegionInfo regionB) throws IOException
generateFavoredNodesForDaughter
in interface FavoredNodesPromoter
IOException
private Set<ServerName> getInheritedFNForDaughter(FavoredNodeAssignmentHelper helper, List<ServerName> parentFavoredNodes, FavoredNodesPlan.Position primary, FavoredNodesPlan.Position secondary) throws IOException
IOException
public void generateFavoredNodesForMergedRegion(RegionInfo merged, RegionInfo[] mergeParents) throws IOException
generateFavoredNodesForMergedRegion
in interface FavoredNodesPromoter
IOException
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.