You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by GitBox <gi...@apache.org> on 2022/03/29 08:21:05 UTC
[GitHub] [hbase] xicm commented on a change in pull request #4294: Hbase 25624 Bound LoadBalancer's RegionLocationFinder cache
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: issues-unsubscribe@hbase.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org