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

   ### What changes were proposed in this pull request?
   
   Each GVFS filesystem operation now loads the catalog and the fileset once, 
instead of four times and twice. The `FileSystem` resolution and the file 
location lookup share the loaded catalog.
   
   REST requests per operation, with the metadata cache disabled (the default), 
a local file system and credential vending disabled:
   
   | Operation | Before | After |
   |---|---|---|
   | open, create, append, delete, mkdirs, getFileStatus, listStatus, 
getDefaultBlockSize, getDefaultReplication, setWorkingDirectory | 12 (catalog 
load x4, fileset load x2) | 8 (catalog load x1, fileset load x1) |
   | rename | 14 (catalog load x5, fileset load x2) | 9 (catalog load x1, 
fileset load x1) |
   
   For append, the counts cover the requests sent before the local file system 
rejects the append.
   
   The remaining REST requests are one schema load, three `getSecrets`, one 
catalog `getCredentials` and one `getFileLocation` (two for rename).
   
   The issue counts 11 REST requests before the change. The extra one is the 
catalog `getCredentials`, which was added after the issue was filed.
   
   With credential vending enabled, the credential path no longer loads the 
catalog and the fileset again.
   
   With the metadata cache enabled there is no gain, because #13851 already 
serves these loads from the cache.
   
   The issue also names a third cause, which is not changed here: every 
operation builds the full property map, including schema properties and 
secrets, even when the `FileSystem` is already cached. The `FileSystem` cache 
key is computed from that map. The HDFS provider reads the Kerberos principal 
and impersonation keys from it, and those keys can be set on the schema or 
bound as secrets. A third-party provider's `getFullAuthority` can read any 
property.
   
   The `getSchema()` NPE noted in the issue is not reached by this change, so 
it is left as is.
   
   ### Why are the changes needed?
   
   Every GVFS filesystem operation repeated the same catalog and fileset loads. 
The cost grows with the number of operations, so a scan over many files pays it 
once per file.
   
   Fixes #12856
   
   ### Does this PR introduce _any_ user-facing change?
   
   No configuration or property key changes.
   
   A subclass that overrides `getFileset(NameIdentifier)` must override 
`getFileset(NameIdentifier, FilesetCatalog)` instead, because the built-in 
operations call only the latter.
   
   The catalog properties, secrets and credentials now come from the object 
returned by `getFilesetCatalog`. When that object is not a `Catalog`, the 
catalog is loaded from the metadata cache, or from the server when the cache is 
disabled, which adds one catalog load per operation.
   
   The built-in operations of `DefaultGVFSOperations` no longer call 
`getActualFileSystem` and `getActualFilePath`. Overrides of these two methods 
apply only to direct calls, not to the built-in operations.
   
   ### How was this patch tested?
   
   - `TestGvfsBase#testMetadataRestCallsPerOperation` runs every operation in 
the table against the mock server, plus getFileStatus and rename on a 
non-default current location. With the metadata cache disabled, it asserts that 
each operation loads the catalog once and the fileset once. It also asserts 
that each file location is looked up once. Last, it asserts that the current 
location name reaches both the `FileSystem` and the location lookup. With the 
metadata cache enabled, it asserts that open and rename after a warm-up 
operation load neither the catalog nor the fileset from the server. The 
cache-disabled cases fail on the code before this change.
   - `TestBaseGVFSOperationsSecrets#testCredentialVendingReusesLoadedFileset` 
asserts that, with credential vending enabled, one resolution calls 
`getFileset(NameIdentifier, FilesetCatalog)` once and loads the fileset once.
   - `TestBaseGVFSOperationsSecrets#testFilesetCatalogThatIsNotCatalog` 
resolves a `FileSystem` when the fileset catalog is not a `Catalog`, and 
asserts that the catalog properties reach the `FileSystem`.
   
   ## AI Disclosure
   
   Human-led contribution. Grok Bot, working for dragonknightk, assisted with 
this change, including the code, tests, and description. All submitted content 
was reviewed by a human before submission. (๑•̀ㅂ•́)و✧
   


-- 
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]

Reply via email to