mchades commented on code in PR #8602:
URL: https://github.com/apache/gravitino/pull/8602#discussion_r2366654578
##########
catalogs/catalog-fileset/src/main/java/org/apache/gravitino/catalog/fileset/FilesetCatalogOperations.java:
##########
@@ -257,6 +240,44 @@ public void initialize(
this.defaultFileSystemProvider =
FileSystemUtils.getFileSystemProviderByName(
fileSystemProvidersMap, defaultFileSystemProviderName);
+
+ scheduler =
+ new ScheduledThreadPoolExecutor(
+ 1,
+ new ThreadFactoryBuilder()
+ .setDaemon(true)
+ .setNameFormat("file-system-cache-for-fileset" + "-%d")
+ .build());
+
+ Caffeine<Object, Object> cacheBuilder =
+ Caffeine.newBuilder()
+ .expireAfterAccess(1, TimeUnit.HOURS)
+ .removalListener(
+ (ignored, value, cause) -> {
+ try {
+ ((FileSystem) value).close();
+ } catch (IOException e) {
+ LOG.warn("Failed to close FileSystem instance in cache",
e);
+ }
+ })
+ .scheduler(Scheduler.forScheduledExecutorService(scheduler));
+
+ MetricsSystem metricsSystem = GravitinoEnv.getInstance().metricsSystem();
+ // Metrics System could be null in UT.
+ if (metricsSystem != null) {
+ cacheBuilder.recordStats(
+ () -> {
+ String metricsPrefix =
+ String.join(
+ ".",
+ GRAVITINO_FILESET_CATALOG_METRIC_PREFIX,
+ catalogInfo.namespace().toString(),
+ catalogInfo.name(),
+ FILESYSTEM_CACHE);
+ return new
MetricsStatsCounter(metricsSystem.getMetricRegistry(), metricsPrefix);
Review Comment:
fixed and local tested:
<img width="1857" height="848" alt="image"
src="https://github.com/user-attachments/assets/5a83db09-cfbb-40a3-bb97-60139ed66be0"
/>
--
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]