HDDS-13532. Refactor BucketEndpoint.get()#10045
Open
rich7420 wants to merge 9 commits intoapache:masterfrom
Open
HDDS-13532. Refactor BucketEndpoint.get()#10045rich7420 wants to merge 9 commits intoapache:masterfrom
rich7420 wants to merge 9 commits intoapache:masterfrom
Conversation
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?
Reopen: #9110
This pull request refactors the massively monolithic
BucketEndpoint.get()method (ListObjects API implementation) to vastly improve codebase maintainability, readability, and unit-testability.The original
get()method was nearly 200 lines long. It tightly coupled logic across multiple domains—from parameter string deserialization, context variable instantiation, iterative key-prefix filtering logic, to S3 metrics/audit log emissions. This structure made it inherently risky to extend and nearly impossible to write isolated unit tests for individual components of the logic.Key Refactoring Improvements in this PR:
BucketListingContext): Introduced a dedicated package-private class to securely encapsulate listing state (such asbucketName,prefix,encodingType,maxKeys,decodedToken,ozoneKeyIterator, etc.). This successfully prevented "parameter-creep" and minimized variable clutter across the execution flow.validateAndPrepareParameters(): Sanitizes configuration limits, handles token decodings, verifies encoding types, and enforces S3 Bucket owner conditions.initializeListObjectResponse(): Generates the bare-bones boilerplate response structures.processKeyListing(): Owns the complex computational burden (thewhile (ozoneKeyIterator.hasNext())mechanism), resolving token depth matches, delimited deep structures, andCommonPrefixesallocations safely.buildFinalResponse(): Isolates the responsibility of executingPerformanceStringBuilderincrements and consistentauditReadSuccesspublishing.master's recent additions (S3RequestContext,PerformanceStringBuilder, and theBucketOperationHandlerChain-of-Responsibility pattern). The refactor cleanly embraces these integrations while achieving optimal flow footprint.What is the link to the Apache JIRA?
https://issues.apache.org/jira/browse/HDDS-13532
How was this patch tested?
https://github.com/rich7420/ozone/actions/runs/23993539910