xicm commented on a change in pull request #4294:
URL: https://github.com/apache/hbase/pull/4294#discussion_r837190831
##########
File path:
hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/RegionHDFSBlockLocationFinder.java
##########
@@ -102,8 +109,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)(ObjectSizeCalculator.getObjectSize(regionInfo) +
Review comment:
I use ObjectSizeCalculator.getObjectSize to estimate the size of the
Object in the cache, Is there a better way?
--
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]