Skip to content

Commit

Permalink
[iceberg] Fix StatisticsFileCache JMX bean
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ZacBlanco committed Feb 7, 2025
1 parent 53da02f commit 16b447b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,9 @@ public StatisticsFileCache createStatisticsFileCache(IcebergConfig config, MBean
.<StatisticsFileCacheKey, ColumnStatistics>weigher((key, entry) -> (int) entry.getEstimatedSize())
.recordStats()
.build();
CacheStatsMBean bean = new CacheStatsMBean(delegate);
exporter.export(generatedNameOf(StatisticsFileCache.class, connectorId), bean);
return new StatisticsFileCache(delegate);
StatisticsFileCache statisticsFileCache = new StatisticsFileCache(delegate);
exporter.export(generatedNameOf(StatisticsFileCache.class, connectorId), statisticsFileCache);
return statisticsFileCache;
}

@ForCachingHiveMetastore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package com.facebook.presto.iceberg.statistics;

import com.facebook.airlift.stats.DistributionStat;
import com.facebook.presto.hive.CacheStatsMBean;
import com.facebook.presto.spi.statistics.ColumnStatistics;
import com.google.common.cache.Cache;
import com.google.common.cache.ForwardingCache.SimpleForwardingCache;
Expand All @@ -25,10 +26,19 @@ public class StatisticsFileCache
{
private final DistributionStat fileSizes = new DistributionStat();
private final DistributionStat columnCounts = new DistributionStat();
private final CacheStatsMBean cacheStats;

public StatisticsFileCache(Cache<StatisticsFileCacheKey, ColumnStatistics> delegate)
{
super(delegate);
cacheStats = new CacheStatsMBean(delegate);
}

@Managed
@Nested
public CacheStatsMBean getCacheStats()
{
return cacheStats;
}

@Managed
Expand Down

0 comments on commit 16b447b

Please sign in to comment.