Skip to content

HDDS-11232. Avoid redundant getBucketInfo RPC on OFS getFileStatus#10792

Open
jojochuang wants to merge 4 commits into
apache:masterfrom
jojochuang:HDDS-getfilestatus-single-rpc
Open

HDDS-11232. Avoid redundant getBucketInfo RPC on OFS getFileStatus#10792
jojochuang wants to merge 4 commits into
apache:masterfrom
jojochuang:HDDS-getfilestatus-single-rpc

Conversation

@jojochuang

Copy link
Copy Markdown
Contributor

Summary

  • Cache validated bucket layouts per (volume, bucket) in BasicRootedOzoneClientAdapterImpl
  • After cache warm-up, getFileStatus() on ofs:// sends one client→OM GetFileStatus RPC instead of getBucketInfo + GetFileStatus
  • Preserves OBJECT_STORE layout rejection, link-bucket layout validation, snapshot paths, and headOp propagation

Test plan

  • mvn -pl :ozone-filesystem-common -am compile
  • Integration tests: TestOFS#testGetFileStatusUsesSingleOmRpcAfterCacheWarm and related new cases
  • CI

Generated-by: Cursor (Composer)

Made with Cursor

Cache validated bucket layouts per volume/bucket and call GetFileStatus
directly after cache warm-up, preserving layout checks and headOp behavior.

Co-authored-by: Cursor <cursoragent@cursor.com>
Change-Id: Icddbc99fee0cf0e78e52919283f93d29a1986a1c
Copilot AI review requested due to automatic review settings July 17, 2026 20:10
@jojochuang jojochuang changed the title Avoid redundant getBucketInfo RPC on OFS getFileStatus HDDS-15801. Avoid redundant getBucketInfo RPC on OFS getFileStatus Jul 17, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR optimizes ofs:// getFileStatus() by caching per-bucket layout validation in BasicRootedOzoneClientAdapterImpl, so repeated getFileStatus() calls can avoid an extra getBucketInfo/getBucketDetails round-trip and rely on a single OM GetFileStatus RPC after warm-up.

Changes:

  • Added a (volume, bucket)-scoped in-memory cache for validated bucket layouts and wired it into the bucket-resolution path.
  • Updated non-snapshot getFileStatus to validate bucket layout once (cached) and then call proxy.getOzoneFileStatus(...) directly.
  • Added integration tests asserting RPC-count behavior after cache warm-up and covering bucket-root stats, OBS-bucket layout rejection, and missing-file behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicRootedOzoneClientAdapterImpl.java Introduces cached bucket-layout validation and routes getFileStatus through a single OM RPC after warm-up.
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/AbstractRootedOzoneFileSystemTest.java Adds integration coverage for the single-RPC behavior and additional getFileStatus edge cases.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +314 to +322
private void ensureBucketLayoutValid(OFSPath ofsPath) throws IOException {
String volumeStr = ofsPath.getVolumeName();
String bucketStr = ofsPath.getBucketName();
if (validatedBucketLayouts.containsKey(
bucketLayoutCacheKey(volumeStr, bucketStr))) {
return;
}
resolveAndValidateBucketLayout(volumeStr, bucketStr);
}
Comment on lines +1886 to +1888
} finally {
objectStore.deleteVolume(obsBucket.getVolumeName());
}
@jojochuang
jojochuang marked this pull request as draft July 17, 2026 20:20
Delete the bucket before removing the volume to avoid VOLUME_NOT_EMPTY.

Co-authored-by: Cursor <cursoragent@cursor.com>
Change-Id: Iddfefe48d716e77cb58501514c919a44194cdae7
Copilot AI review requested due to automatic review settings July 17, 2026 20:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Comment on lines +314 to +322
private void ensureBucketLayoutValid(OFSPath ofsPath) throws IOException {
String volumeStr = ofsPath.getVolumeName();
String bucketStr = ofsPath.getBucketName();
if (validatedBucketLayouts.containsKey(
bucketLayoutCacheKey(volumeStr, bucketStr))) {
return;
}
resolveAndValidateBucketLayout(volumeStr, bucketStr);
}
Comment on lines +136 to +140
/**
* Cache of successfully validated bucket layouts for read paths.
*/
private final ConcurrentHashMap<String, BucketLayout> validatedBucketLayouts =
new ConcurrentHashMap<>();
@jojochuang
jojochuang marked this pull request as ready for review July 17, 2026 21:32
jojochuang and others added 2 commits July 17, 2026 14:32
Co-authored-by: Cursor <cursoragent@cursor.com>
Change-Id: Ifc177a61594da562cc3cbc13b6f622fada55971d
Mock ClientProtocol and warm the layout cache after getFileStatus stopped
calling OzoneBucket.getFileStatus for non-snapshot paths.

Co-authored-by: Cursor <cursoragent@cursor.com>
Change-Id: I34e369396f682c096fa23b0f5df7b8b165feab6f
Copilot AI review requested due to automatic review settings July 17, 2026 22:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicRootedOzoneClientAdapterImpl.java:756

  • validatedBucketLayouts is never invalidated. If a bucket is deleted and later re-created (potentially with a different layout), a cached entry can cause future getFileStatus() calls to skip layout validation and bypass OBJECT_STORE rejection. At minimum, clear the cache entry when OM reports BUCKET_NOT_FOUND so the next call revalidates against the current bucket definition.
    } catch (OMException e) {
      if (e.getResult() == OMException.ResultCodes.FILE_NOT_FOUND) {
        throw new FileNotFoundException(key + ": No such file or directory!");
      } else if (e.getResult() == OMException.ResultCodes.BUCKET_NOT_FOUND) {
        throw new FileNotFoundException(key + ": Bucket doesn't exist!");

Comment on lines +100 to +107
Field cacheField =
BasicRootedOzoneClientAdapterImpl.class.getDeclaredField(
"validatedBucketLayouts");
cacheField.setAccessible(true);
ConcurrentHashMap<String, BucketLayout> cache =
new ConcurrentHashMap<>();
cache.put(volumeName + "/" + bucketName, BucketLayout.FILE_SYSTEM_OPTIMIZED);
cacheField.set(adapter, cache);
@jojochuang jojochuang changed the title HDDS-15801. Avoid redundant getBucketInfo RPC on OFS getFileStatus HDDS-11232. Avoid redundant getBucketInfo RPC on OFS getFileStatus Jul 18, 2026
@jojochuang

Copy link
Copy Markdown
Contributor Author

@yandrey321 this PR aims to remove the extra RPC call in most cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants