Skip to content

Commit 16b447b

Browse files
committed
[iceberg] Fix StatisticsFileCache JMX bean
Previously, only the cache stats were available through the JMX plugin because only the CacheStatsMBean was exported. The file size and column count distributions were not available. This fixes the issue by problem by exporting the StatisticsFileCache object instead and embedding the cache stats object
1 parent 53da02f commit 16b447b

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergCommonModule.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,9 @@ public StatisticsFileCache createStatisticsFileCache(IcebergConfig config, MBean
195195
.<StatisticsFileCacheKey, ColumnStatistics>weigher((key, entry) -> (int) entry.getEstimatedSize())
196196
.recordStats()
197197
.build();
198-
CacheStatsMBean bean = new CacheStatsMBean(delegate);
199-
exporter.export(generatedNameOf(StatisticsFileCache.class, connectorId), bean);
200-
return new StatisticsFileCache(delegate);
198+
StatisticsFileCache statisticsFileCache = new StatisticsFileCache(delegate);
199+
exporter.export(generatedNameOf(StatisticsFileCache.class, connectorId), statisticsFileCache);
200+
return statisticsFileCache;
201201
}
202202

203203
@ForCachingHiveMetastore

presto-iceberg/src/main/java/com/facebook/presto/iceberg/statistics/StatisticsFileCache.java

+10
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
package com.facebook.presto.iceberg.statistics;
1515

1616
import com.facebook.airlift.stats.DistributionStat;
17+
import com.facebook.presto.hive.CacheStatsMBean;
1718
import com.facebook.presto.spi.statistics.ColumnStatistics;
1819
import com.google.common.cache.Cache;
1920
import com.google.common.cache.ForwardingCache.SimpleForwardingCache;
@@ -25,10 +26,19 @@ public class StatisticsFileCache
2526
{
2627
private final DistributionStat fileSizes = new DistributionStat();
2728
private final DistributionStat columnCounts = new DistributionStat();
29+
private final CacheStatsMBean cacheStats;
2830

2931
public StatisticsFileCache(Cache<StatisticsFileCacheKey, ColumnStatistics> delegate)
3032
{
3133
super(delegate);
34+
cacheStats = new CacheStatsMBean(delegate);
35+
}
36+
37+
@Managed
38+
@Nested
39+
public CacheStatsMBean getCacheStats()
40+
{
41+
return cacheStats;
3242
}
3343

3444
@Managed

0 commit comments

Comments
 (0)