HDDS-15877. Extend getFileStatus head-op (type-only) optimization to o3fs and remaining type-only callers#10779
Open
jojochuang wants to merge 1 commit into
Open
HDDS-15877. Extend getFileStatus head-op (type-only) optimization to o3fs and remaining type-only callers#10779jojochuang wants to merge 1 commit into
jojochuang wants to merge 1 commit into
Conversation
…o3fs and remaining type-only callers Follow-up of HDDS-15678, which added a headOp (metadata/type-only) flag so ofs isDirectory/isFile skip the SCM pipeline refresh and block-location retrieval. - o3fs BasicOzoneFileSystem.isDirectory/isFile now use the head-op path instead of the deprecated super.isDirectory/isFile (which triggered a full getFileStatus + pipeline refresh); BasicOzoneClientAdapterImpl forwards headOp to OzoneBucket.getFileStatus. - DeleteKeyHandler type checks pass headOp=true. - Trash-root type checks fetch the status once instead of exists() + two getFileStatus() calls for the same path. Adds unit tests for headOp propagation through the o3fs adapter and for the o3fs FileSystem isDirectory/isFile behaviour. Co-authored-by: Cursor <cursoragent@cursor.com> Change-Id: I2cf245c4731e662f0929ce30f731ce518b422813
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends the existing “head-op” (type-only / metadata-only) getFileStatus optimization beyond ofs:// to o3fs:// and other remaining type-only callers, reducing unnecessary OM→SCM pipeline refresh work and eliminating redundant exists()/getFileStatus() RPC patterns where only entry type is needed.
Changes:
- Add a
headOp-awaregetFileStatusoverride inBasicOzoneClientAdapterImpland routeBasicOzoneFileSystem.isDirectory/isFilethroughheadOp=truestatus checks (instead ofFileSystem.super.isDirectory/isFile). - Reduce redundant trash-root RPCs by fetching a single
FileStatusand handlingFileNotFoundExceptiondirectly. - Update CLI FSO delete-path directory checks to request
headOp=true, and add unit tests validating head-op propagation and exception behavior.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicOzoneFileSystem.java | Uses headOp=true for isDirectory/isFile and optimizes trash-root checks to avoid redundant status calls. |
| hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicOzoneClientAdapterImpl.java | Implements getFileStatus(..., headOp) to forward to OzoneBucket.getFileStatus(key, headOp). |
| hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicRootedOzoneClientAdapterImpl.java | Optimizes trash-root lookup by replacing exists()+2x getFileStatus() with a single getFileStatus() and FNFE handling. |
| hadoop-ozone/cli-shell/src/main/java/org/apache/hadoop/ozone/shell/keys/DeleteKeyHandler.java | Switches FSO directory-type checks to use bucket.getFileStatus(key, true) for type-only lookups. |
| hadoop-ozone/ozonefs-common/src/test/java/org/apache/hadoop/fs/ozone/TestBasicOzoneClientAdapterHeadOp.java | New unit tests ensuring the adapter threads headOp through and preserves exception mapping semantics. |
| hadoop-ozone/ozonefs-common/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFileSystemHeadOp.java | New unit tests ensuring BasicOzoneFileSystem.isDirectory/isFile uses headOp=true and preserves error behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
Follow-up of HDDS-15678, which introduced a
headOp(metadata / type-only) flag so that OFS (ofs://)isDirectory/isFileskip the SCM pipeline refresh (an OM→SCM round-trip) and block-location retrieval — those calls only need the entry type, not block locations.That change only covered the rooted (
ofs://) filesystem. This PR extends the same optimization to the remaining call sites that fetch a fullFileStatussolely to determine whether a path is a file or a directory:BasicOzoneFileSystem.isDirectory/isFile(primary). These still delegated to the deprecatedFileSystem.super.isDirectory/isFile, which internally call the fullgetFileStatus(f)and therefore trigger a pipeline refresh for file paths. They now go through a head-opgetFileStatus, mirroring what HDDS-15678 did for the rooted filesystem.BasicOzoneClientAdapterImplgains aheadOpgetFileStatusoverride that forwards the flag toOzoneBucket.getFileStatus(key, headOp). Without this,o3fskept paying the SCM round-trip forisDirectory/isFilewhileofsdid not. The@SuppressWarnings("deprecation")(previously needed for thesuper.*calls) is removed as those calls are gone.DeleteKeyHandler(ozone sh key deleteon FSO buckets). The twobucket.getFileStatus(...).isDirectory()checks now passheadOp=true(the API added by HDDS-15678).BasicOzoneFileSystem#getTrashRootsandBasicRootedOzoneClientAdapterImpl#getTrashRoots. These fetched the same path's status viaexists()plus up to twogetFileStatus()calls; they now fetch it once. (Trash roots are directories, which never triggered a pipeline refresh, so the win here is removing redundant RPCs rather than skipping a refresh.)Behaviour is unchanged:
isDirectory/isFilestill returnfalsefor a non-existent path (FileNotFoundExceptionis swallowed) and still propagate otherIOExceptions.What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-15877
How was this patch tested?
ozonefs-common:TestBasicOzoneClientAdapterHeadOp— verifies the o3fs adapter forwardsheadOpintoOzoneBucket.getFileStatus, that the 4-arg overload defaults toheadOp=false, and thatFILE_NOT_FOUNDmaps toFileNotFoundExceptionwhile otherOMExceptions propagate.TestOzoneFileSystemHeadOp— verifiesBasicOzoneFileSystem.isDirectory/isFilerequestheadOp=true, thatgetFileStatus(Path)still usesheadOp=false, that missing paths returnfalse, and that non-not-found exceptions propagate.ozonefs-commonunit suite passes (46 tests), including the HDDS-15678 rooted head-op tests.mvn checkstyle:checkclean onozone-filesystem-commonandozone-cli-shell.ozone-filesystem-hadoop2builds against the Hadoop 2.10.2 classpath (no Hadoop 3-only API used).Made with Cursor