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

   ## What changes were proposed in this pull request?
   
   The `Recon/api/NSSummaryEndpoint.java` so far has been handling only FSO 
buckets. 
   
   Keeping the class as it is, makes it very difficult to make an 
implementation for non FSO buckets as well. 
   
   In order to allow the addition of the nonFSO bucket handling code, we 
refactored the Bucket specific code out of the NSSummaryEndpoint.  We created 
an abstract BucketHandler class with a concrete FSOBucket subclass. That 
subclass functions exactly as the code does now.
   
   In the process of refactoring, we noticed the large switch statements in 
NSSummaryEndpoint.java.  They all switch on the case of the EntityType being 
summarized.  That didn't seem very object oriented, so we refactored those 
switch statements into an abstract class named EntityHandler, with concrete 
subclasses for each of the 6 defined entities, (Root, Volume, etc.)
   
   No functionality was changed in the process.  We just re-organized the code 
to make it easier to maintain/more object oriented.
   
   ## What is the link to the Apache JIRA
   
   https://issues.apache.org/jira/browse/HDDS-5504
   
   https://issues.apache.org/jira/browse/HDDS-5505
   
   ## How was this patch tested?
   
   All the original tests remain unchanged and continue to pass.
   
   To make reviews easier, we also wanted to find a way to diff the old code 
with the new. Ordinary diff tools can't handle this amount of refactoring. So 
we wrote a simple python script to insert the refactored methods back into the 
original switch statements. That way we could use standard diff tools to 
confirm no unexpected changes were made in the refactoring.
   
   So for example, [using GitHub 
diffs:](https://github.com/GeorgeJahad/ozone/compare/64d67668d2f8cbfa60d0b8055ee53d0c104e20d8..GeorgeJahad:reorgNSSummaryEndpoint2?w=1)
   
   Lines 124-140 show the diffs in the Root entity case of the getBasicInfo() 
switch statement.  In the green sections, you can see that the only diffs are 
that we added the getSummaryResponse() method header and replaced the "break" 
statement with a method return statement.
   
   Obviously that isn't valid java, but it isn't meant to be; it is just a file 
of code that has been generated to allow us to be sure that the changes were as 
we intended.


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