@InterfaceAudience.Private public class FavoredNodeAssignmentHelper extends Object
FavoredNodeLoadBalancer
that has all the intelligence
for racks, meta scans, etc. Instantiated by the FavoredNodeLoadBalancer
when needed (from within calls like
FavoredNodeLoadBalancer.randomAssignment(HRegionInfo, List)
).Modifier and Type | Field and Description |
---|---|
static short |
FAVORED_NODES_NUM |
static byte[] |
FAVOREDNODES_QUALIFIER |
private static org.apache.commons.logging.Log |
LOG |
private RackManager |
rackManager |
private Map<String,List<ServerName>> |
rackToRegionServerMap |
private Random |
random |
private Map<ServerName,String> |
regionServerToRackMap |
private List<ServerName> |
servers |
private List<String> |
uniqueRackList |
Constructor and Description |
---|
FavoredNodeAssignmentHelper(List<ServerName> servers,
org.apache.hadoop.conf.Configuration conf) |
FavoredNodeAssignmentHelper(List<ServerName> servers,
RackManager rackManager) |
Modifier and Type | Method and Description |
---|---|
(package private) boolean |
canPlaceFavoredNodes() |
static byte[] |
getFavoredNodes(List<ServerName> serverAddrList) |
static String |
getFavoredNodesAsString(List<ServerName> nodes) |
static ServerName[] |
getFavoredNodesList(byte[] favoredNodes) |
private String |
getOneRandomRack(Set<String> skipRackSet) |
private ServerName |
getOneRandomServer(String rack) |
private ServerName |
getOneRandomServer(String rack,
Set<ServerName> skipServerSet) |
private List<ServerName> |
getServersFromRack(String rack) |
private int |
getTotalNumberOfRacks() |
void |
initialize() |
(package private) static Put |
makePutFromRegionInfo(HRegionInfo regionInfo,
List<ServerName> favoredNodeList)
Generates and returns a Put containing the region info for the catalog table
and the servers
|
private Map<ServerName,Set<HRegionInfo>> |
mapRSToPrimaries(Map<HRegionInfo,ServerName> primaryRSMap) |
private ServerName[] |
multiRackCase(HRegionInfo regionInfo,
ServerName primaryRS,
String primaryRack) |
private ServerName[] |
multiRackCaseWithRestrictions(Map<ServerName,Set<HRegionInfo>> serverToPrimaries,
Map<HRegionInfo,ServerName[]> secondaryAndTertiaryMap,
String primaryRack,
ServerName primaryRS,
HRegionInfo regionInfo) |
(package private) void |
placePrimaryRSAsRoundRobin(Map<ServerName,List<HRegionInfo>> assignmentMap,
Map<HRegionInfo,ServerName> primaryRSMap,
List<HRegionInfo> regions) |
(package private) Map<HRegionInfo,ServerName[]> |
placeSecondaryAndTertiaryRS(Map<HRegionInfo,ServerName> primaryRSMap) |
Map<HRegionInfo,ServerName[]> |
placeSecondaryAndTertiaryWithRestrictions(Map<HRegionInfo,ServerName> primaryRSMap)
For regions that share the primary, avoid placing the secondary and tertiary
on a same RS.
|
private ServerName[] |
singleRackCase(HRegionInfo regionInfo,
ServerName primaryRS,
String primaryRack) |
static void |
updateMetaWithFavoredNodesInfo(Map<HRegionInfo,List<ServerName>> regionToFavoredNodes,
org.apache.hadoop.conf.Configuration conf)
Update meta table with favored nodes info
|
static void |
updateMetaWithFavoredNodesInfo(Map<HRegionInfo,List<ServerName>> regionToFavoredNodes,
Connection connection)
Update meta table with favored nodes info
|
private static final org.apache.commons.logging.Log LOG
private RackManager rackManager
private Map<String,List<ServerName>> rackToRegionServerMap
private Map<ServerName,String> regionServerToRackMap
private Random random
private List<ServerName> servers
public static final byte[] FAVOREDNODES_QUALIFIER
public static final short FAVORED_NODES_NUM
public FavoredNodeAssignmentHelper(List<ServerName> servers, org.apache.hadoop.conf.Configuration conf)
public FavoredNodeAssignmentHelper(List<ServerName> servers, RackManager rackManager)
public static void updateMetaWithFavoredNodesInfo(Map<HRegionInfo,List<ServerName>> regionToFavoredNodes, Connection connection) throws IOException
regionToFavoredNodes
- map of HRegionInfo's to their favored nodesconnection
- connection to be usedIOException
public static void updateMetaWithFavoredNodesInfo(Map<HRegionInfo,List<ServerName>> regionToFavoredNodes, org.apache.hadoop.conf.Configuration conf) throws IOException
regionToFavoredNodes
- conf
- IOException
static Put makePutFromRegionInfo(HRegionInfo regionInfo, List<ServerName> favoredNodeList) throws IOException
regionInfo
- favoredNodeList
- IOException
public static ServerName[] getFavoredNodesList(byte[] favoredNodes) throws com.google.protobuf.InvalidProtocolBufferException
favoredNodes
- The PB'ed bytes of favored nodesServerName
for the byte array of favored nodes.com.google.protobuf.InvalidProtocolBufferException
public static byte[] getFavoredNodes(List<ServerName> serverAddrList)
serverAddrList
- HBaseProtos.FavoredNodes
generated by the server list.void placePrimaryRSAsRoundRobin(Map<ServerName,List<HRegionInfo>> assignmentMap, Map<HRegionInfo,ServerName> primaryRSMap, List<HRegionInfo> regions)
Map<HRegionInfo,ServerName[]> placeSecondaryAndTertiaryRS(Map<HRegionInfo,ServerName> primaryRSMap)
private Map<ServerName,Set<HRegionInfo>> mapRSToPrimaries(Map<HRegionInfo,ServerName> primaryRSMap)
public Map<HRegionInfo,ServerName[]> placeSecondaryAndTertiaryWithRestrictions(Map<HRegionInfo,ServerName> primaryRSMap)
primaryRSMap
- private ServerName[] multiRackCaseWithRestrictions(Map<ServerName,Set<HRegionInfo>> serverToPrimaries, Map<HRegionInfo,ServerName[]> secondaryAndTertiaryMap, String primaryRack, ServerName primaryRS, HRegionInfo regionInfo) throws IOException
IOException
private ServerName[] singleRackCase(HRegionInfo regionInfo, ServerName primaryRS, String primaryRack) throws IOException
IOException
private ServerName[] multiRackCase(HRegionInfo regionInfo, ServerName primaryRS, String primaryRack) throws IOException
IOException
boolean canPlaceFavoredNodes()
public void initialize()
private int getTotalNumberOfRacks()
private List<ServerName> getServersFromRack(String rack)
private ServerName getOneRandomServer(String rack, Set<ServerName> skipServerSet) throws IOException
IOException
private ServerName getOneRandomServer(String rack) throws IOException
IOException
private String getOneRandomRack(Set<String> skipRackSet) throws IOException
IOException
public static String getFavoredNodesAsString(List<ServerName> nodes)
Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.