yuqi1129 commented on code in PR #7782: URL: https://github.com/apache/gravitino/pull/7782#discussion_r2246775747
########## catalogs/catalog-fileset/src/main/java/org/apache/gravitino/catalog/fileset/FilesetCatalogOperations.java: ########## @@ -129,8 +129,75 @@ public class FilesetCatalogOperations extends ManagedSchemaOperations private boolean disableFSOps; + @VisibleForTesting ScheduledThreadPoolExecutor scheduler; + @VisibleForTesting Cache<FileSystemCacheKey, FileSystem> fileSystemCache; + FilesetCatalogOperations(EntityStore store) { this.store = store; + scheduler = + new ScheduledThreadPoolExecutor( + 1, + new ThreadFactoryBuilder() + .setDaemon(true) + .setNameFormat("file-system-cache-for-fileset" + "-%d") + .build()); + + this.fileSystemCache = + 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)) + .build(); + } + + static class FileSystemCacheKey { + private final NameIdentifier ident; + private final Map<String, String> conf; + private final String pathPrefix; + private final String currentUser; Review Comment: It looks weird to make a file system instance shared between different filesets, so I added the name identfier to it. Removing it won't make a difference and it's logically correct. -- 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: commits-unsubscr...@gravitino.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org