Class RegionLocationFinder
java.lang.Object
org.apache.hadoop.hbase.master.balancer.RegionLocationFinder
This will find where data for a region is located in HDFS. It ranks
ServerName's by the
size of the store files they are holding for a given region.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate org.apache.hbase.thirdparty.com.google.common.cache.LoadingCache<RegionInfo,HDFSBlocksDistribution> private static final longprivate org.apache.hadoop.conf.Configurationprivate static final HDFSBlocksDistributionprivate static final floatprivate final org.apache.hbase.thirdparty.com.google.common.util.concurrent.ListeningExecutorServiceprivate longprivate org.apache.hbase.thirdparty.com.google.common.cache.CacheLoader<RegionInfo,HDFSBlocksDistribution> private static final org.slf4j.Loggerprivate MasterServicesprivate ClusterMetrics -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate org.apache.hbase.thirdparty.com.google.common.util.concurrent.ListenableFuture<HDFSBlocksDistribution>private org.apache.hbase.thirdparty.com.google.common.cache.LoadingCache<RegionInfo,HDFSBlocksDistribution> Create a cache for region to list of servers(package private) org.apache.hbase.thirdparty.com.google.common.cache.LoadingCache<RegionInfo,HDFSBlocksDistribution> getCache()org.apache.hadoop.conf.ConfigurationgetConf()private floatgetOldLocality(ServerName newServer, byte[] regionName, Map<ServerName, ServerMetrics> oldServers) protected TableDescriptorgetTableDescriptor(TableName tableName) return TableDescriptor for a given tableNameprotected List<ServerName>getTopBlockLocations(RegionInfo region) protected List<ServerName>getTopBlockLocations(RegionInfo region, String currentHost) Returns an ordered list of hosts which have better locality for this region than the current host.protected HDFSBlocksDistributionReturns an ordered list of hosts that are hosting the blocks for this region.(package private) List<ServerName>mapHostNameToServerName(List<String> hosts) Map hostname to ServerName, The output ServerName list will have the same order as input hosts.voidrefreshAndWait(Collection<RegionInfo> hris) private voidrefreshLocalityChangedRegions(ClusterMetrics oldStatus, ClusterMetrics newStatus) If locality for a region has changed, that pretty certainly means our cache is out of date.private booleanRefresh all the region locations.voidsetClusterMetrics(ClusterMetrics status) voidsetConf(org.apache.hadoop.conf.Configuration conf) voidsetServices(MasterServices services)
-
Field Details
-
LOG
-
CACHE_TIME
- See Also:
-
EPSILON
- See Also:
-
EMPTY_BLOCK_DISTRIBUTION
-
conf
-
status
-
services
-
executor
private final org.apache.hbase.thirdparty.com.google.common.util.concurrent.ListeningExecutorService executor -
lastFullRefresh
-
loader
private org.apache.hbase.thirdparty.com.google.common.cache.CacheLoader<RegionInfo,HDFSBlocksDistribution> loader -
cache
private org.apache.hbase.thirdparty.com.google.common.cache.LoadingCache<RegionInfo,HDFSBlocksDistribution> cache
-
-
Constructor Details
-
RegionLocationFinder
-
-
Method Details
-
createCache
private org.apache.hbase.thirdparty.com.google.common.cache.LoadingCache<RegionInfo,HDFSBlocksDistribution> createCache()Create a cache for region to list of servers- Returns:
- A new Cache.
-
getConf
-
setConf
-
setServices
-
setClusterMetrics
-
refreshLocalityChangedRegions
If locality for a region has changed, that pretty certainly means our cache is out of date. Compare oldStatus and newStatus, refreshing any regions which have moved or changed locality. -
getOldLocality
private float getOldLocality(ServerName newServer, byte[] regionName, Map<ServerName, ServerMetrics> oldServers) -
scheduleFullRefresh
Refresh all the region locations.- Returns:
- true if user created regions got refreshed.
-
getTopBlockLocations
-
getTopBlockLocations
Returns an ordered list of hosts which have better locality for this region than the current host. -
internalGetTopBlockLocation
Returns an ordered list of hosts that are hosting the blocks for this region. The weight of each host is the sum of the block lengths of all files on that host, so the first host in the list is the server which holds the most bytes of the given region's HFiles.- Parameters:
region- region- Returns:
- ordered list of hosts holding blocks of the specified region
-
getTableDescriptor
return TableDescriptor for a given tableName- Parameters:
tableName- the table name- Throws:
IOException
-
mapHostNameToServerName
Map hostname to ServerName, The output ServerName list will have the same order as input hosts.- Parameters:
hosts- the list of hosts- Returns:
- ServerName list
-
getBlockDistribution
-
asyncGetBlockDistribution
private org.apache.hbase.thirdparty.com.google.common.util.concurrent.ListenableFuture<HDFSBlocksDistribution> asyncGetBlockDistribution(RegionInfo hri) -
refreshAndWait
-
getCache
org.apache.hbase.thirdparty.com.google.common.cache.LoadingCache<RegionInfo,HDFSBlocksDistribution> getCache()
-