@InterfaceAudience.Private public class FavoredNodeAssignmentHelper extends Object
Modifier and Type | Field and Description |
---|---|
static short |
FAVORED_NODES_NUM |
static byte[] |
FAVOREDNODES_QUALIFIER |
private static org.slf4j.Logger |
LOG |
static short |
MAX_ATTEMPTS_FN_GENERATION |
private RackManager |
rackManager |
private Map<String,List<ServerName>> |
rackToRegionServerMap |
private Map<String,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 |
---|---|
boolean |
canPlaceFavoredNodes() |
private Map<RegionInfo,List<ServerName>> |
generateFavoredNodes(Map<RegionInfo,ServerName> primaryRSMap) |
List<ServerName> |
generateFavoredNodes(RegionInfo hri) |
Map<RegionInfo,List<ServerName>> |
generateFavoredNodesRoundRobin(Map<ServerName,List<RegionInfo>> assignmentMap,
List<RegionInfo> regions) |
ServerName |
generateMissingFavoredNode(List<ServerName> favoredNodes) |
ServerName |
generateMissingFavoredNode(List<ServerName> favoredNodes,
List<ServerName> excludeNodes) |
private ServerName |
generateMissingFavoredNodeMultiRack(List<ServerName> favoredNodes) |
private ServerName |
generateMissingFavoredNodeMultiRack(List<ServerName> favoredNodes,
List<ServerName> excludeNodes) |
private ServerName |
generateMissingFavoredNodeSingleRack(List<ServerName> favoredNodes,
List<ServerName> excludeNodes) |
static int |
getDataNodePort(org.apache.hadoop.conf.Configuration conf) |
static byte[] |
getFavoredNodes(List<ServerName> serverAddrList)
Returns PB'ed bytes of
HBaseProtos.FavoredNodes generated by the server list. |
static String |
getFavoredNodesAsString(List<ServerName> nodes) |
static ServerName[] |
getFavoredNodesList(byte[] favoredNodes)
Convert PB bytes to ServerName.
|
(package private) String |
getOneRandomRack(Set<String> skipRackSet) |
private ServerName |
getOneRandomServer(String rack) |
protected ServerName |
getOneRandomServer(String rack,
Set<ServerName> skipServerSet)
Gets a random server from the specified rack and skips anything specified.
|
private String |
getRackOfServer(ServerName sn)
Get the rack of server from local mapping when present, saves lookup by the RackManager.
|
ServerName[] |
getSecondaryAndTertiary(RegionInfo regionInfo,
ServerName primaryRS) |
private List<ServerName> |
getServersFromRack(String rack) |
private int |
getTotalNumberOfRacks() |
void |
initialize() |
private static Put |
makePut(RegionInfo regionInfo,
List<ServerName> favoredNodeList) |
private Map<ServerName,Set<RegionInfo>> |
mapRSToPrimaries(Map<RegionInfo,ServerName> primaryRSMap) |
private ServerName[] |
multiRackCase(ServerName primaryRS,
String primaryRack)
Place secondary and tertiary nodes in a multi rack case.
|
private ServerName[] |
multiRackCaseWithRestrictions(Map<ServerName,Set<RegionInfo>> serverToPrimaries,
Map<RegionInfo,ServerName[]> secondaryAndTertiaryMap,
String primaryRack,
ServerName primaryRS,
RegionInfo regionInfo) |
void |
placePrimaryRSAsRoundRobin(Map<ServerName,List<RegionInfo>> assignmentMap,
Map<RegionInfo,ServerName> primaryRSMap,
List<RegionInfo> regions) |
Map<RegionInfo,ServerName[]> |
placeSecondaryAndTertiaryRS(Map<RegionInfo,ServerName> primaryRSMap) |
Map<RegionInfo,ServerName[]> |
placeSecondaryAndTertiaryWithRestrictions(Map<RegionInfo,ServerName> primaryRSMap)
For regions that share the primary, avoid placing the secondary and tertiary on a same RS.
|
private ServerName[] |
singleRackCase(RegionInfo regionInfo,
ServerName primaryRS,
String primaryRack) |
static void |
updateMetaWithFavoredNodesInfo(Map<RegionInfo,List<ServerName>> regionToFavoredNodes,
org.apache.hadoop.conf.Configuration conf)
Update meta table with favored nodes info
|
static void |
updateMetaWithFavoredNodesInfo(Map<RegionInfo,List<ServerName>> regionToFavoredNodes,
Connection connection)
Update meta table with favored nodes info
|
private static final org.slf4j.Logger LOG
private RackManager rackManager
private Map<String,List<ServerName>> rackToRegionServerMap
private List<String> uniqueRackList
private Map<String,String> regionServerToRackMap
private List<ServerName> servers
public static final byte[] FAVOREDNODES_QUALIFIER
public static final short FAVORED_NODES_NUM
public static final short MAX_ATTEMPTS_FN_GENERATION
public FavoredNodeAssignmentHelper(List<ServerName> servers, org.apache.hadoop.conf.Configuration conf)
public FavoredNodeAssignmentHelper(List<ServerName> servers, RackManager rackManager)
public void initialize()
public static void updateMetaWithFavoredNodesInfo(Map<RegionInfo,List<ServerName>> regionToFavoredNodes, Connection connection) throws IOException
regionToFavoredNodes
- map of RegionInfo's to their favored nodesconnection
- connection to be usedIOException
public static void updateMetaWithFavoredNodesInfo(Map<RegionInfo,List<ServerName>> regionToFavoredNodes, org.apache.hadoop.conf.Configuration conf) throws IOException
IOException
private static Put makePut(RegionInfo regionInfo, List<ServerName> favoredNodeList) throws IOException
IOException
public static ServerName[] getFavoredNodesList(byte[] favoredNodes) throws IOException
favoredNodes
- The PB'ed bytes of favored nodesServerName
for the byte array of favored nodes.IOException
public static byte[] getFavoredNodes(List<ServerName> serverAddrList)
HBaseProtos.FavoredNodes
generated by the server list.public void placePrimaryRSAsRoundRobin(Map<ServerName,List<RegionInfo>> assignmentMap, Map<RegionInfo,ServerName> primaryRSMap, List<RegionInfo> regions)
public Map<RegionInfo,ServerName[]> placeSecondaryAndTertiaryRS(Map<RegionInfo,ServerName> primaryRSMap)
public ServerName[] getSecondaryAndTertiary(RegionInfo regionInfo, ServerName primaryRS) throws IOException
IOException
private Map<ServerName,Set<RegionInfo>> mapRSToPrimaries(Map<RegionInfo,ServerName> primaryRSMap)
public Map<RegionInfo,ServerName[]> placeSecondaryAndTertiaryWithRestrictions(Map<RegionInfo,ServerName> primaryRSMap)
private ServerName[] multiRackCaseWithRestrictions(Map<ServerName,Set<RegionInfo>> serverToPrimaries, Map<RegionInfo,ServerName[]> secondaryAndTertiaryMap, String primaryRack, ServerName primaryRS, RegionInfo regionInfo) throws IOException
IOException
private ServerName[] singleRackCase(RegionInfo regionInfo, ServerName primaryRS, String primaryRack) throws IOException
IOException
private ServerName[] multiRackCase(ServerName primaryRS, String primaryRack) throws IOException
primaryRS
- The primary favored node.primaryRack
- The rack of the primary favored node.IOException
- Signals that an I/O exception has occurred.public boolean canPlaceFavoredNodes()
private int getTotalNumberOfRacks()
private List<ServerName> getServersFromRack(String rack)
protected ServerName getOneRandomServer(String rack, Set<ServerName> skipServerSet)
rack
- rack from a server is neededskipServerSet
- the server shouldn't belong to this setprivate ServerName getOneRandomServer(String rack) throws IOException
IOException
String getOneRandomRack(Set<String> skipRackSet) throws IOException
IOException
public static String getFavoredNodesAsString(List<ServerName> nodes)
public ServerName generateMissingFavoredNode(List<ServerName> favoredNodes) throws IOException
IOException
public ServerName generateMissingFavoredNode(List<ServerName> favoredNodes, List<ServerName> excludeNodes) throws IOException
IOException
private ServerName generateMissingFavoredNodeSingleRack(List<ServerName> favoredNodes, List<ServerName> excludeNodes) throws IOException
IOException
private ServerName generateMissingFavoredNodeMultiRack(List<ServerName> favoredNodes) throws IOException
IOException
private ServerName generateMissingFavoredNodeMultiRack(List<ServerName> favoredNodes, List<ServerName> excludeNodes) throws IOException
IOException
public List<ServerName> generateFavoredNodes(RegionInfo hri) throws IOException
IOException
public Map<RegionInfo,List<ServerName>> generateFavoredNodesRoundRobin(Map<ServerName,List<RegionInfo>> assignmentMap, List<RegionInfo> regions) throws IOException
IOException
private Map<RegionInfo,List<ServerName>> generateFavoredNodes(Map<RegionInfo,ServerName> primaryRSMap)
private String getRackOfServer(ServerName sn)
public static int getDataNodePort(org.apache.hadoop.conf.Configuration conf)
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.