rich7420 opened a new pull request, #10045:
URL: https://github.com/apache/ozone/pull/10045

   
   ### What changes were proposed in this pull request?
   Reopen: https://github.com/apache/ozone/pull/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:**
   * **Context Encapsulation (`BucketListingContext`)**: Introduced a dedicated 
package-private class to securely encapsulate listing state (such as 
`bucketName`, `prefix`, `encodingType`, `maxKeys`, `decodedToken`, 
`ozoneKeyIterator`, etc.). This successfully prevented "parameter-creep" and 
minimized variable clutter across the execution flow.
   * **Method Extraction & Separation of Concerns**: We systematically 
decomposed the unmaintainable block into multiple single-responsibility helper 
methods:
     * `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 (the `while 
(ozoneKeyIterator.hasNext())` mechanism), resolving token depth matches, 
delimited deep structures, and `CommonPrefixes` allocations safely.
     * `buildFinalResponse()`: Isolates the responsibility of executing 
`PerformanceStringBuilder` increments and consistent `auditReadSuccess` 
publishing.
   * **Seamless Upstream Synchronization**: During refactoring, this branch was 
comprehensively synced and merged with `master`'s recent additions 
(`S3RequestContext`, `PerformanceStringBuilder`, and the 
`BucketOperationHandler` Chain-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


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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to