xicm commented on a change in pull request #4294:
URL: https://github.com/apache/hbase/pull/4294#discussion_r839132102
##########
File path:
hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/RegionHDFSBlockLocationFinder.java
##########
@@ -102,8 +108,28 @@ public HDFSBlocksDistribution load(RegionInfo key) throws
Exception {
* @return A new Cache.
*/
private LoadingCache<RegionInfo, HDFSBlocksDistribution> createCache() {
- return CacheBuilder.newBuilder().expireAfterWrite(CACHE_TIME,
TimeUnit.MILLISECONDS)
- .build(loader);
+
+ long maximumWeight = getConf().getLong(
+ BALANCER_REGIONBLOCKLOCATION_CACHE_MAX_SIZE, 0);
+
+ if (maximumWeight > 0) {
+ return CacheBuilder.newBuilder()
+ .expireAfterWrite(CACHE_TIME, TimeUnit.MILLISECONDS)
+ .weigher(
+ new Weigher<RegionInfo, HDFSBlocksDistribution>() {
+ @Override
+ public int weigh(RegionInfo regionInfo, HDFSBlocksDistribution
hdfsBlocksDistribution) {
+ return (int) (regionInfo.heapSize() +
+ hdfsBlocksDistribution.heapSize());
Review comment:
Calculating the heap involves too many changes, shall we limit the cache
with maximumSize?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]