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
Modifier and TypeFieldDescriptionprivate org.apache.hbase.thirdparty.com.google.common.cache.LoadingCache<RegionInfo,
HDFSBlocksDistribution> private static final long
private org.apache.hadoop.conf.Configuration
private static final HDFSBlocksDistribution
private static final float
private final org.apache.hbase.thirdparty.com.google.common.util.concurrent.ListeningExecutorService
private long
private org.apache.hbase.thirdparty.com.google.common.cache.CacheLoader<RegionInfo,
HDFSBlocksDistribution> private static final org.slf4j.Logger
private MasterServices
private ClusterMetrics
-
Constructor Summary
-
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.Configuration
getConf()
private float
getOldLocality
(ServerName newServer, byte[] regionName, Map<ServerName, ServerMetrics> oldServers) protected TableDescriptor
getTableDescriptor
(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 HDFSBlocksDistribution
Returns 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.void
refreshAndWait
(Collection<RegionInfo> hris) private void
refreshLocalityChangedRegions
(ClusterMetrics oldStatus, ClusterMetrics newStatus) If locality for a region has changed, that pretty certainly means our cache is out of date.private boolean
Refresh all the region locations.void
setClusterMetrics
(ClusterMetrics status) void
setConf
(org.apache.hadoop.conf.Configuration conf) void
setServices
(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()
-