@InterfaceAudience.Private public class FavoredStochasticBalancer extends StochasticLoadBalancer 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. This provides two
CandidateGenerator
Modifier and Type | Class and Description |
---|---|
(package private) class |
FavoredStochasticBalancer.FavoredNodeLoadPicker |
private class |
FavoredStochasticBalancer.FavoredNodeLocalityPicker
Pick favored nodes with the highest locality for a region with lowest locality.
|
StochasticLoadBalancer.GeneratorType
Modifier and Type | Field and Description |
---|---|
private FavoredNodesManager |
fnm |
private static org.slf4j.Logger |
LOG |
candidateGenerators, COST_FUNCTIONS_COST_FUNCTIONS_KEY, costFunctions, DEFAULT_KEEP_REGION_LOADS, DEFAULT_MAX_RUNNING_TIME, DEFAULT_MAX_STEPS, DEFAULT_MIN_COST_NEED_BALANCE, DEFAULT_RUN_MAX_STEPS, DEFAULT_STEPS_PER_REGION, KEEP_REGION_LOADS, loads, MAX_RUNNING_TIME_KEY, MAX_STEPS_KEY, MIN_COST_NEED_BALANCE_KEY, OVERALL_COST_FUNCTION_NAME, regionCacheRatioOnOldServerMap, RUN_MAX_STEPS_KEY, STEPS_PER_REGION_KEY
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, provider, rackManager, regionFinder, slop, useRegionFinder
FAVORED_ALWAYS_ASSIGN_REGIONS
BOGUS_SERVER_NAME, HBASE_RSGROUP_LOADBALANCER_CLASS
Constructor and Description |
---|
FavoredStochasticBalancer() |
Modifier and Type | Method and Description |
---|---|
private void |
addRegionToMap(Map<ServerName,List<RegionInfo>> assignmentMapForFavoredNodes,
RegionInfo region,
ServerName host) |
private void |
assignRegionToAvailableFavoredNode(Map<ServerName,List<RegionInfo>> assignmentMapForFavoredNodes,
RegionInfo region,
ServerName primaryHost,
ServerName secondaryHost,
ServerName tertiaryHost)
Assign the region to primary if its available.
|
protected List<RegionPlan> |
balanceTable(TableName tableName,
Map<ServerName,List<RegionInfo>> loadOfOneTable)
For all regions correctly assigned to favored nodes, we just use the stochastic balancer
implementation.
|
protected List<CandidateGenerator> |
createCandidateGenerators() |
void |
generateFavoredNodesForDaughter(List<ServerName> servers,
RegionInfo parent,
RegionInfo regionA,
RegionInfo regionB)
Generate Favored Nodes for daughters during region split.
|
void |
generateFavoredNodesForMergedRegion(RegionInfo merged,
RegionInfo[] mergeParents)
Generate favored nodes for a region during merge.
|
private Map<ServerName,List<RegionInfo>> |
generateFNForRegionsWithoutFN(FavoredNodeAssignmentHelper helper,
List<RegionInfo> regions) |
List<ServerName> |
getFavoredNodes(RegionInfo regionInfo) |
private Set<ServerName> |
getInheritedFNForDaughter(FavoredNodeAssignmentHelper helper,
List<ServerName> parentFavoredNodes,
FavoredNodesPlan.Position primary,
FavoredNodesPlan.Position secondary) |
private List<ServerName> |
getOnlineFavoredNodes(List<ServerName> onlineServers,
List<ServerName> serversWithoutStartCodes)
Return list of favored nodes that are online.
|
protected CandidateGenerator |
getRandomGenerator()
Returns any candidate generator in random
|
private ServerName |
getServerFromFavoredNode(List<ServerName> servers,
ServerName fn)
Get the ServerName for the FavoredNode.
|
private void |
mergeAssignmentMaps(Map<ServerName,List<RegionInfo>> assignmentMap,
Map<ServerName,List<RegionInfo>> otherAssignments) |
ServerName |
randomAssignment(RegionInfo regionInfo,
List<ServerName> servers)
If we have favored nodes for a region, we will return one of the FN as destination.
|
Map<ServerName,List<RegionInfo>> |
retainAssignment(Map<RegionInfo,ServerName> regions,
List<ServerName> servers)
Reuse BaseLoadBalancer's retainAssignment, but generate favored nodes when its missing.
|
Map<ServerName,List<RegionInfo>> |
roundRobinAssignment(List<RegionInfo> regions,
List<ServerName> servers)
Round robin assignment: Segregate the regions into two types: 1.
|
private Pair<Map<ServerName,List<RegionInfo>>,List<RegionInfo>> |
segregateRegionsAndAssignRegionsWithFavoredNodes(Collection<RegionInfo> regions,
List<ServerName> onlineServers)
Return a pair - one with assignments when favored nodes are present and another with regions
without favored nodes.
|
void |
setFavoredNodesManager(FavoredNodesManager fnm) |
private void |
updateFavoredNodesForRegion(RegionInfo regionInfo,
List<ServerName> newFavoredNodes) |
composeAttributeName, computeCost, createCostFunctions, functionCost, getCandidateGenerators, getCostFunctionNames, getCostFunctions, initCosts, loadConf, needsBalance, nextAction, sendRejectionReasonToRingBuffer, setRackManager, updateBalancerLoadInfo, updateClusterMetrics, updateCostsAndWeightsWithAction, updateMetricsSize
balanceCluster, getConf, getDefaultSlop, idleRegionServerExist, initialize, isStopped, onConfigurationChange, postMasterStartupInitialize, preBalanceCluster, regionOffline, regionOnline, setClusterInfoProvider, sloppyRegionServerExist, stop, toEnsumbleTableLoad, updateBalancerStatus
private static final org.slf4j.Logger LOG
private FavoredNodesManager fnm
public FavoredStochasticBalancer()
public void setFavoredNodesManager(FavoredNodesManager fnm)
setFavoredNodesManager
in interface FavoredNodesPromoter
protected List<CandidateGenerator> createCandidateGenerators()
createCandidateGenerators
in class StochasticLoadBalancer
protected CandidateGenerator getRandomGenerator()
getRandomGenerator
in class StochasticLoadBalancer
@NonNull public Map<ServerName,List<RegionInfo>> roundRobinAssignment(List<RegionInfo> regions, List<ServerName> servers) throws HBaseIOException
roundRobinAssignment
in interface LoadBalancer
roundRobinAssignment
in class BaseLoadBalancer
regions
- all regionsservers
- all serversHBaseIOException
private void mergeAssignmentMaps(Map<ServerName,List<RegionInfo>> assignmentMap, Map<ServerName,List<RegionInfo>> otherAssignments)
private Map<ServerName,List<RegionInfo>> generateFNForRegionsWithoutFN(FavoredNodeAssignmentHelper helper, List<RegionInfo> regions) throws IOException
IOException
private Pair<Map<ServerName,List<RegionInfo>>,List<RegionInfo>> segregateRegionsAndAssignRegionsWithFavoredNodes(Collection<RegionInfo> regions, List<ServerName> onlineServers) throws HBaseIOException
HBaseIOException
private void addRegionToMap(Map<ServerName,List<RegionInfo>> assignmentMapForFavoredNodes, RegionInfo region, ServerName host)
private ServerName getServerFromFavoredNode(List<ServerName> servers, ServerName fn)
private void assignRegionToAvailableFavoredNode(Map<ServerName,List<RegionInfo>> assignmentMapForFavoredNodes, RegionInfo region, ServerName primaryHost, ServerName secondaryHost, ServerName tertiaryHost)
public ServerName randomAssignment(RegionInfo regionInfo, List<ServerName> servers) throws HBaseIOException
randomAssignment
in interface LoadBalancer
randomAssignment
in class BaseLoadBalancer
regionInfo
- Region for which this selection is being done.HBaseIOException
private void updateFavoredNodesForRegion(RegionInfo regionInfo, List<ServerName> newFavoredNodes) throws IOException
IOException
@NonNull public Map<ServerName,List<RegionInfo>> retainAssignment(Map<RegionInfo,ServerName> regions, List<ServerName> servers) throws HBaseIOException
retainAssignment
in interface LoadBalancer
retainAssignment
in class BaseLoadBalancer
regions
- regions and existing assignment from metaservers
- available serversHBaseIOException
private List<ServerName> getOnlineFavoredNodes(List<ServerName> onlineServers, List<ServerName> serversWithoutStartCodes)
public List<ServerName> getFavoredNodes(RegionInfo regionInfo)
getFavoredNodes
in interface FavoredNodesPromoter
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
protected List<RegionPlan> balanceTable(TableName tableName, Map<ServerName,List<RegionInfo>> loadOfOneTable)
balanceTable
in class StochasticLoadBalancer
tableName
- the table to be balancedloadOfOneTable
- region load of servers for the specific one tableCopyright © 2007–2020 The Apache Software Foundation. All rights reserved.