You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gravitino.apache.org by "mchades (via GitHub)" <gi...@apache.org> on 2025/08/22 10:43:19 UTC

[PR] [#7572] improvement(gvfs): add fileset cache in GVFS [gravitino]

mchades opened a new pull request, #8254:
URL: https://github.com/apache/gravitino/pull/8254

   ### What changes were proposed in this pull request?
   
   add fileset cache in GVFS
   
   ### Why are the changes needed?
   
   Fix: #7572
   
   ### Does this PR introduce _any_ user-facing change?
   
   no
   
   ### How was this patch tested?
   
   CI pass
   


-- 
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-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#7572] improvement(gvfs): add fileset cache in GVFS [gravitino]

Posted by "mchades (via GitHub)" <gi...@apache.org>.
mchades commented on code in PR #8254:
URL: https://github.com/apache/gravitino/pull/8254#discussion_r2298229403


##########
clients/filesystem-hadoop3/src/main/java/org/apache/gravitino/filesystem/hadoop/FilesetCatalogCache.java:
##########
@@ -70,6 +76,27 @@ public FilesetCatalog getFilesetCatalog(NameIdentifier catalogIdent) {
     return filesetCatalog;
   }
 
+  /**
+   * Gets the fileset by the given fileset identifier.
+   *
+   * @param filesetIdent the fileset identifier.
+   * @return the fileset.
+   */
+  public Fileset getFileset(NameIdentifier filesetIdent) {
+    NameIdentifier catalogIdent =
+        NameIdentifier.of(filesetIdent.namespace().level(0), filesetIdent.namespace().level(1));
+    FilesetCatalog filesetCatalog = getFilesetCatalog(catalogIdent);
+    Fileset fileset =
+        filesetCache.get(
+            filesetIdent,
+            ident ->
+                filesetCatalog.loadFileset(
+                    NameIdentifier.of(filesetIdent.namespace().level(2), filesetIdent.name())));
+    Preconditions.checkArgument(
+        fileset != null, String.format("Loaded fileset: %s is null.", filesetIdent));

Review Comment:
   It shouldn't, unless a bug is introduced.



-- 
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-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#7572] improvement(gvfs): add fileset cache in GVFS [gravitino]

Posted by "mchades (via GitHub)" <gi...@apache.org>.
mchades commented on code in PR #8254:
URL: https://github.com/apache/gravitino/pull/8254#discussion_r2299517930


##########
clients/filesystem-hadoop3/src/main/java/org/apache/gravitino/filesystem/hadoop/FilesetCatalogCache.java:
##########
@@ -70,6 +76,27 @@ public FilesetCatalog getFilesetCatalog(NameIdentifier catalogIdent) {
     return filesetCatalog;
   }
 
+  /**
+   * Gets the fileset by the given fileset identifier.
+   *
+   * @param filesetIdent the fileset identifier.
+   * @return the fileset.
+   */
+  public Fileset getFileset(NameIdentifier filesetIdent) {
+    NameIdentifier catalogIdent =
+        NameIdentifier.of(filesetIdent.namespace().level(0), filesetIdent.namespace().level(1));
+    FilesetCatalog filesetCatalog = getFilesetCatalog(catalogIdent);
+    Fileset fileset =
+        filesetCache.get(
+            filesetIdent,
+            ident ->
+                filesetCatalog.loadFileset(
+                    NameIdentifier.of(filesetIdent.namespace().level(2), filesetIdent.name())));
+    Preconditions.checkArgument(
+        fileset != null, String.format("Loaded fileset: %s is null.", filesetIdent));

Review Comment:
   So you are suggesting removing this check?



-- 
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-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#7572] improvement(gvfs): add fileset cache in GVFS [gravitino]

Posted by "mchades (via GitHub)" <gi...@apache.org>.
mchades commented on code in PR #8254:
URL: https://github.com/apache/gravitino/pull/8254#discussion_r2300091215


##########
clients/client-python/gravitino/filesystem/gvfs_base_operations.py:
##########
@@ -547,3 +549,32 @@ def _get_fileset_catalog(self, catalog_ident: NameIdentifier):
             return catalog
         finally:
             write_lock.release()
+
+    def _get_fileset(self, fileset_ident: NameIdentifier):
+        read_lock = self._fileset_cache_lock.gen_rlock()
+        try:
+            read_lock.acquire()
+            cache_value: Fileset = self._fileset_cache.get(fileset_ident)
+            if cache_value is not None:
+                return cache_value
+        finally:
+            read_lock.release()
+
+        write_lock = self._fileset_cache_lock.gen_wlock()
+        try:
+            write_lock.acquire()
+            cache_value: Fileset = self._fileset_cache.get(fileset_ident)
+            if cache_value is not None:
+                return cache_value
+
+            catalog_ident: NameIdentifier = NameIdentifier.of(
+                fileset_ident.namespace().level(0), fileset_ident.namespace().level(1)
+            )
+            catalog: FilesetCatalog = self._get_fileset_catalog(catalog_ident)
+            fileset = catalog.as_fileset_catalog().load_fileset(
+                NameIdentifier.of(fileset_ident.namespace().level(2), fileset_ident.name())
+            )
+            self._fileset_cache[fileset_ident] = fileset
+            return fileset
+        finally:
+            write_lock.release()

Review Comment:
   added



##########
clients/filesystem-hadoop3/src/main/java/org/apache/gravitino/filesystem/hadoop/FilesetCatalogCache.java:
##########
@@ -80,6 +107,14 @@ private Cache<NameIdentifier, FilesetCatalog> newCatalogCache(
         .build();
   }
 
+  private Cache<NameIdentifier, Fileset> newFilesetCache(
+      ScheduledThreadPoolExecutor filesetCleanScheduler) {
+    return Caffeine.newBuilder()
+        .maximumSize(100)
+        .scheduler(Scheduler.forScheduledExecutorService(filesetCleanScheduler))

Review Comment:
   fixed



-- 
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-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#7572] improvement(gvfs): add fileset cache in GVFS [gravitino]

Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao commented on code in PR #8254:
URL: https://github.com/apache/gravitino/pull/8254#discussion_r2303303076


##########
clients/client-python/gravitino/filesystem/gvfs_config.py:
##########
@@ -76,3 +76,6 @@ class GVFSConfig:
 
     # The configuration key prefix for the client.
     GVFS_FILESYSTEM_CLIENT_CONFIG_PREFIX = "gvfs_gravitino_client_"
+
+    # The configuration key for whether to enable fileset catalog cache. The default is false.
+    GVFS_FILESYSTEM_ENABLE_FILESET_CATALOG_CACHE = "enable_fileset_catalog_cache"

Review Comment:
   Also, you should clearly describe the side-effects in here and doc.



-- 
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-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#7572] improvement(gvfs): add fileset cache in GVFS [gravitino]

Posted by "mchades (via GitHub)" <gi...@apache.org>.
mchades commented on code in PR #8254:
URL: https://github.com/apache/gravitino/pull/8254#discussion_r2303905830


##########
clients/client-python/gravitino/filesystem/gvfs_config.py:
##########
@@ -76,3 +76,6 @@ class GVFSConfig:
 
     # The configuration key prefix for the client.
     GVFS_FILESYSTEM_CLIENT_CONFIG_PREFIX = "gvfs_gravitino_client_"
+
+    # The configuration key for whether to enable fileset catalog cache. The default is false.
+    GVFS_FILESYSTEM_ENABLE_FILESET_CATALOG_CACHE = "enable_fileset_catalog_cache"

Review Comment:
   fixed



-- 
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-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#7572] improvement(gvfs): add fileset cache in GVFS [gravitino]

Posted by "yuqi1129 (via GitHub)" <gi...@apache.org>.
yuqi1129 commented on code in PR #8254:
URL: https://github.com/apache/gravitino/pull/8254#discussion_r2299480603


##########
clients/filesystem-hadoop3/src/main/java/org/apache/gravitino/filesystem/hadoop/FilesetCatalogCache.java:
##########
@@ -80,6 +107,14 @@ private Cache<NameIdentifier, FilesetCatalog> newCatalogCache(
         .build();
   }
 
+  private Cache<NameIdentifier, Fileset> newFilesetCache(
+      ScheduledThreadPoolExecutor filesetCleanScheduler) {
+    return Caffeine.newBuilder()
+        .maximumSize(100)

Review Comment:
   This can be slightly larger, say 1000, or 10000.



-- 
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-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#7572] improvement(gvfs): add fileset cache in GVFS [gravitino]

Posted by "mchades (via GitHub)" <gi...@apache.org>.
mchades commented on code in PR #8254:
URL: https://github.com/apache/gravitino/pull/8254#discussion_r2300271737


##########
clients/filesystem-hadoop3/src/main/java/org/apache/gravitino/filesystem/hadoop/FilesetCatalogCache.java:
##########
@@ -80,6 +107,14 @@ private Cache<NameIdentifier, FilesetCatalog> newCatalogCache(
         .build();
   }
 
+  private Cache<NameIdentifier, Fileset> newFilesetCache(
+      ScheduledThreadPoolExecutor filesetCleanScheduler) {
+    return Caffeine.newBuilder()
+        .maximumSize(100)
+        .scheduler(Scheduler.forScheduledExecutorService(filesetCleanScheduler))

Review Comment:
   after I removed this scheduler, the cache tests failed (more details see [here](https://github.com/apache/gravitino/actions/runs/17231457433/job/48886396015?pr=8254)): 
   
   > TestSimpleClient > testInternalCache() FAILED
   >     org.awaitility.core.ConditionTimeoutException: Assertion condition defined as a Lambda expression in org.apache.gravitino.filesystem.hadoop.TestGvfsBase expected: <0> but was: <1> within 5 seconds.
   >         at app//org.awaitility.core.ConditionAwaiter.await(ConditionAwaiter.java:167)
   >         at app//org.awaitility.core.AssertionCondition.await(AssertionCondition.java:119)
   >         at app//org.awaitility.core.AssertionCondition.await(AssertionCondition.java:31)
   >         at app//org.awaitility.core.ConditionFactory.until(ConditionFactory.java:1006)
   >         at app//org.awaitility.core.ConditionFactory.untilAsserted(ConditionFactory.java:790)
   >         at app//org.apache.gravitino.filesystem.hadoop.TestGvfsBase.testInternalCache(TestGvfsBase.java:387)
   >         at java.base@17.0.16/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   >         at java.base@17.0.16/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
   >         at java.base@17.0.16/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   >         at java.base@17.0.16/java.lang.reflect.Method.invoke(Method.java:569)
   
   
   I'll add it back and make it a local variable.



-- 
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-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#7572] improvement(gvfs): add fileset cache in GVFS [gravitino]

Posted by "mchades (via GitHub)" <gi...@apache.org>.
mchades commented on code in PR #8254:
URL: https://github.com/apache/gravitino/pull/8254#discussion_r2299933251


##########
clients/filesystem-hadoop3/src/main/java/org/apache/gravitino/filesystem/hadoop/FilesetCatalogCache.java:
##########
@@ -80,6 +107,14 @@ private Cache<NameIdentifier, FilesetCatalog> newCatalogCache(
         .build();
   }
 
+  private Cache<NameIdentifier, Fileset> newFilesetCache(
+      ScheduledThreadPoolExecutor filesetCleanScheduler) {
+    return Caffeine.newBuilder()
+        .maximumSize(100)
+        .scheduler(Scheduler.forScheduledExecutorService(filesetCleanScheduler))

Review Comment:
   the Caffine will use it automatically, the same is also used elsewhere in the project
   
   https://github.com/apache/gravitino/blob/a4d0545b54e44504ce445de3f97c218aaf233eb1/catalogs/hive-metastore-common/src/main/java/org/apache/gravitino/hive/CachedClientPool.java#L73-L81



-- 
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-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#7572] improvement(gvfs): add fileset cache in GVFS [gravitino]

Posted by "mchades (via GitHub)" <gi...@apache.org>.
mchades commented on code in PR #8254:
URL: https://github.com/apache/gravitino/pull/8254#discussion_r2300082185


##########
clients/filesystem-hadoop3/src/main/java/org/apache/gravitino/filesystem/hadoop/FilesetCatalogCache.java:
##########
@@ -80,6 +107,14 @@ private Cache<NameIdentifier, FilesetCatalog> newCatalogCache(
         .build();
   }
 
+  private Cache<NameIdentifier, Fileset> newFilesetCache(
+      ScheduledThreadPoolExecutor filesetCleanScheduler) {
+    return Caffeine.newBuilder()
+        .maximumSize(100)
+        .scheduler(Scheduler.forScheduledExecutorService(filesetCleanScheduler))

Review Comment:
    ok, if it's unnecessary, I'll remove all the scheduler from the client side.
   
   BTW, it's first introduced by the PR #4320 in [GravitinoVirtualFileSystem.java](https://github.com/apache/gravitino/pull/4320/files#diff-64c5b87c772c66c642144ad44764c1339ad846ddc013000c52c9ab503cbce02eR141-R145)



-- 
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-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#7572] improvement(gvfs): add fileset cache in GVFS [gravitino]

Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao commented on code in PR #8254:
URL: https://github.com/apache/gravitino/pull/8254#discussion_r2303281252


##########
clients/client-python/gravitino/filesystem/gvfs_config.py:
##########
@@ -76,3 +76,6 @@ class GVFSConfig:
 
     # The configuration key prefix for the client.
     GVFS_FILESYSTEM_CLIENT_CONFIG_PREFIX = "gvfs_gravitino_client_"
+
+    # The configuration key for whether to enable fileset catalog cache. The default is false.
+    GVFS_FILESYSTEM_ENABLE_FILESET_CATALOG_CACHE = "enable_fileset_catalog_cache"

Review Comment:
   This is not only for catalog cache, the configuration name is misleading, can you figure out a better name.



-- 
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-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#7572] improvement(gvfs): add fileset cache in GVFS [gravitino]

Posted by "mchades (via GitHub)" <gi...@apache.org>.
mchades commented on code in PR #8254:
URL: https://github.com/apache/gravitino/pull/8254#discussion_r2298227606


##########
clients/filesystem-hadoop3/src/main/java/org/apache/gravitino/filesystem/hadoop/FilesetCatalogCache.java:
##########
@@ -80,6 +107,14 @@ private Cache<NameIdentifier, FilesetCatalog> newCatalogCache(
         .build();
   }
 
+  private Cache<NameIdentifier, Fileset> newFilesetCache(
+      ScheduledThreadPoolExecutor filesetCleanScheduler) {
+    return Caffeine.newBuilder()
+        .maximumSize(100)

Review Comment:
   Just copy from catalogCache. It seems there won't be too many filesets in one GVFS instance. What value do you prefer? I'll update it accordingly.



-- 
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-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#7572] improvement(gvfs): add fileset cache in GVFS [gravitino]

Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao commented on code in PR #8254:
URL: https://github.com/apache/gravitino/pull/8254#discussion_r2299894186


##########
clients/client-python/gravitino/filesystem/gvfs_base_operations.py:
##########
@@ -547,3 +549,32 @@ def _get_fileset_catalog(self, catalog_ident: NameIdentifier):
             return catalog
         finally:
             write_lock.release()
+
+    def _get_fileset(self, fileset_ident: NameIdentifier):
+        read_lock = self._fileset_cache_lock.gen_rlock()
+        try:
+            read_lock.acquire()
+            cache_value: Fileset = self._fileset_cache.get(fileset_ident)
+            if cache_value is not None:
+                return cache_value
+        finally:
+            read_lock.release()
+
+        write_lock = self._fileset_cache_lock.gen_wlock()
+        try:
+            write_lock.acquire()
+            cache_value: Fileset = self._fileset_cache.get(fileset_ident)
+            if cache_value is not None:
+                return cache_value
+
+            catalog_ident: NameIdentifier = NameIdentifier.of(
+                fileset_ident.namespace().level(0), fileset_ident.namespace().level(1)
+            )
+            catalog: FilesetCatalog = self._get_fileset_catalog(catalog_ident)
+            fileset = catalog.as_fileset_catalog().load_fileset(
+                NameIdentifier.of(fileset_ident.namespace().level(2), fileset_ident.name())
+            )
+            self._fileset_cache[fileset_ident] = fileset
+            return fileset
+        finally:
+            write_lock.release()

Review Comment:
   Because cache has side-effects, I suggest that we add a configuration to enable/disable the cache, by default it can be disabled.



-- 
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-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#7572] improvement(gvfs): add fileset cache in GVFS [gravitino]

Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao commented on code in PR #8254:
URL: https://github.com/apache/gravitino/pull/8254#discussion_r2299910184


##########
clients/filesystem-hadoop3/src/main/java/org/apache/gravitino/filesystem/hadoop/FilesetCatalogCache.java:
##########
@@ -80,6 +107,14 @@ private Cache<NameIdentifier, FilesetCatalog> newCatalogCache(
         .build();
   }
 
+  private Cache<NameIdentifier, Fileset> newFilesetCache(
+      ScheduledThreadPoolExecutor filesetCleanScheduler) {
+    return Caffeine.newBuilder()
+        .maximumSize(100)
+        .scheduler(Scheduler.forScheduledExecutorService(filesetCleanScheduler))

Review Comment:
   What is the usage of this `scheduler`? I don't find any `Callable` or `Runnable` for this scheduler.



-- 
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-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#7572] improvement(gvfs): add fileset cache in GVFS [gravitino]

Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao commented on code in PR #8254:
URL: https://github.com/apache/gravitino/pull/8254#discussion_r2303309758


##########
clients/filesystem-hadoop3/src/main/java/org/apache/gravitino/filesystem/hadoop/BaseGVFSOperations.java:
##########
@@ -146,13 +146,15 @@ protected BaseGVFSOperations(Configuration configuration) {
         "'%s' is not set in the configuration",
         GravitinoVirtualFileSystemConfiguration.FS_GRAVITINO_CLIENT_METALAKE_KEY);
 
-    GravitinoClient client = GravitinoVirtualFileSystemUtils.createClient(configuration);
-    this.filesetCatalogCache = new FilesetCatalogCache(client);
+    this.gravitinoClient = GravitinoVirtualFileSystemUtils.createClient(configuration);
+    this.enableFilesetCatalogCache =
+        configuration.getBoolean(
+            FS_GRAVITINO_FILESET_CATALOG_CACHE_ENABLE,
+            FS_GRAVITINO_FILESET_CATALOG_CACHE_ENABLE_DEFAULT);
+    this.filesetCatalogCache =
+        enableFilesetCatalogCache ? new FilesetCatalogCache(gravitinoClient) : null;

Review Comment:
   I don't like specifically setting `null` value in the code, it is error-prone. You'd better use `Optional` instead.



-- 
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-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#7572] improvement(gvfs): add fileset cache in GVFS [gravitino]

Posted by "mchades (via GitHub)" <gi...@apache.org>.
mchades commented on PR #8254:
URL: https://github.com/apache/gravitino/pull/8254#issuecomment-3227164684

   @jerryshao @yuqi1129 All comments resolved, please help to review again, thanks!


-- 
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-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#7572] improvement(gvfs): add fileset cache in GVFS [gravitino]

Posted by "yuqi1129 (via GitHub)" <gi...@apache.org>.
yuqi1129 commented on code in PR #8254:
URL: https://github.com/apache/gravitino/pull/8254#discussion_r2297979933


##########
clients/filesystem-hadoop3/src/main/java/org/apache/gravitino/filesystem/hadoop/FilesetCatalogCache.java:
##########
@@ -70,6 +76,27 @@ public FilesetCatalog getFilesetCatalog(NameIdentifier catalogIdent) {
     return filesetCatalog;
   }
 
+  /**
+   * Gets the fileset by the given fileset identifier.
+   *
+   * @param filesetIdent the fileset identifier.
+   * @return the fileset.
+   */
+  public Fileset getFileset(NameIdentifier filesetIdent) {
+    NameIdentifier catalogIdent =
+        NameIdentifier.of(filesetIdent.namespace().level(0), filesetIdent.namespace().level(1));
+    FilesetCatalog filesetCatalog = getFilesetCatalog(catalogIdent);
+    Fileset fileset =
+        filesetCache.get(
+            filesetIdent,
+            ident ->
+                filesetCatalog.loadFileset(
+                    NameIdentifier.of(filesetIdent.namespace().level(2), filesetIdent.name())));
+    Preconditions.checkArgument(
+        fileset != null, String.format("Loaded fileset: %s is null.", filesetIdent));

Review Comment:
   When will the fileset become null?



##########
clients/filesystem-hadoop3/src/main/java/org/apache/gravitino/filesystem/hadoop/FilesetCatalogCache.java:
##########
@@ -80,6 +107,14 @@ private Cache<NameIdentifier, FilesetCatalog> newCatalogCache(
         .build();
   }
 
+  private Cache<NameIdentifier, Fileset> newFilesetCache(
+      ScheduledThreadPoolExecutor filesetCleanScheduler) {
+    return Caffeine.newBuilder()
+        .maximumSize(100)

Review Comment:
   Why is the size so small? Is there any other consideration that I am not aware of?



-- 
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-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#7572] improvement(gvfs): add fileset cache in GVFS [gravitino]

Posted by "yuqi1129 (via GitHub)" <gi...@apache.org>.
yuqi1129 commented on code in PR #8254:
URL: https://github.com/apache/gravitino/pull/8254#discussion_r2299520579


##########
clients/filesystem-hadoop3/src/main/java/org/apache/gravitino/filesystem/hadoop/FilesetCatalogCache.java:
##########
@@ -70,6 +76,27 @@ public FilesetCatalog getFilesetCatalog(NameIdentifier catalogIdent) {
     return filesetCatalog;
   }
 
+  /**
+   * Gets the fileset by the given fileset identifier.
+   *
+   * @param filesetIdent the fileset identifier.
+   * @return the fileset.
+   */
+  public Fileset getFileset(NameIdentifier filesetIdent) {
+    NameIdentifier catalogIdent =
+        NameIdentifier.of(filesetIdent.namespace().level(0), filesetIdent.namespace().level(1));
+    FilesetCatalog filesetCatalog = getFilesetCatalog(catalogIdent);
+    Fileset fileset =
+        filesetCache.get(
+            filesetIdent,
+            ident ->
+                filesetCatalog.loadFileset(
+                    NameIdentifier.of(filesetIdent.namespace().level(2), filesetIdent.name())));
+    Preconditions.checkArgument(
+        fileset != null, String.format("Loaded fileset: %s is null.", filesetIdent));

Review Comment:
   This is not a big problem; it depends on you. I remember when I used the same code, jerry just suggested me  remove it as `NoSuchFilesetException` will occur.  For me both are okay.



-- 
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-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#7572] improvement(gvfs): add fileset cache in GVFS [gravitino]

Posted by "yuqi1129 (via GitHub)" <gi...@apache.org>.
yuqi1129 commented on code in PR #8254:
URL: https://github.com/apache/gravitino/pull/8254#discussion_r2299481114


##########
clients/filesystem-hadoop3/src/main/java/org/apache/gravitino/filesystem/hadoop/FilesetCatalogCache.java:
##########
@@ -70,6 +76,27 @@ public FilesetCatalog getFilesetCatalog(NameIdentifier catalogIdent) {
     return filesetCatalog;
   }
 
+  /**
+   * Gets the fileset by the given fileset identifier.
+   *
+   * @param filesetIdent the fileset identifier.
+   * @return the fileset.
+   */
+  public Fileset getFileset(NameIdentifier filesetIdent) {
+    NameIdentifier catalogIdent =
+        NameIdentifier.of(filesetIdent.namespace().level(0), filesetIdent.namespace().level(1));
+    FilesetCatalog filesetCatalog = getFilesetCatalog(catalogIdent);
+    Fileset fileset =
+        filesetCache.get(
+            filesetIdent,
+            ident ->
+                filesetCatalog.loadFileset(
+                    NameIdentifier.of(filesetIdent.namespace().level(2), filesetIdent.name())));
+    Preconditions.checkArgument(
+        fileset != null, String.format("Loaded fileset: %s is null.", filesetIdent));

Review Comment:
   It can't be null according to the code.



-- 
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-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#7572] improvement(gvfs): add fileset cache in GVFS [gravitino]

Posted by "yuqi1129 (via GitHub)" <gi...@apache.org>.
yuqi1129 merged PR #8254:
URL: https://github.com/apache/gravitino/pull/8254


-- 
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-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#7572] improvement(gvfs): add fileset cache in GVFS [gravitino]

Posted by "yuqi1129 (via GitHub)" <gi...@apache.org>.
yuqi1129 commented on code in PR #8254:
URL: https://github.com/apache/gravitino/pull/8254#discussion_r2299982565


##########
clients/filesystem-hadoop3/src/main/java/org/apache/gravitino/filesystem/hadoop/FilesetCatalogCache.java:
##########
@@ -80,6 +107,14 @@ private Cache<NameIdentifier, FilesetCatalog> newCatalogCache(
         .build();
   }
 
+  private Cache<NameIdentifier, Fileset> newFilesetCache(
+      ScheduledThreadPoolExecutor filesetCleanScheduler) {
+    return Caffeine.newBuilder()
+        .maximumSize(100)
+        .scheduler(Scheduler.forScheduledExecutorService(filesetCleanScheduler))

Review Comment:
   In the client size, there is no need to set it explicitly. The reason that I set it in `CachedClientPool` is that we need to hold the reference of the `scheduler` or JVM can't clean up the class loader in Gravitino server.



-- 
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-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org