adoroszlai commented on code in PR #7748:
URL: https://github.com/apache/ozone/pull/7748#discussion_r1957807169


##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/ReadReplicas.java:
##########
@@ -246,4 +204,91 @@ private File createDirectory(String volumeName, String 
bucketName,
     }
     return dir;
   }
+
+  private void findCandidateKeys(OzoneClient ozoneClient, OzoneAddress 
address) throws IOException {
+    ObjectStore objectStore = ozoneClient.getObjectStore();
+    String volumeName = address.getVolumeName();
+    String bucketName = address.getBucketName();
+    String keyName = address.getKeyName();
+    if (!keyName.isEmpty()) {
+      processKey(ozoneClient, volumeName, bucketName, keyName);
+    } else if (!bucketName.isEmpty()) {
+      OzoneVolume volume = objectStore.getVolume(volumeName);
+      OzoneBucket bucket = volume.getBucket(bucketName);
+      checkBucket(bucket, ozoneClient);
+    } else if (!volumeName.isEmpty()) {
+      OzoneVolume volume = objectStore.getVolume(volumeName);
+      checkVolume(volume, ozoneClient);
+    } else {
+      for (Iterator<? extends OzoneVolume> it = objectStore.listVolumes(null); 
it.hasNext();) {
+        checkVolume(it.next(), ozoneClient);
+      }
+    }
+  }

Review Comment:
   There is no rush to first get these changes in.  If you would like to do it 
separately, please extract the common methods first, then implement the new 
tool using it.
   
   When trying to generalize for reuse from existing code, I find it useful to 
work on  the new code at the same time.  This helps guide the refactoring 
process.  In this case, I would add this new command locally while extracting 
the common methods.
   
   Duplicated logic is just an intermediate state, not something to be 
committed for later refactoring in separate PRs.  My experience is that those 
refactoring PRs tend not to happen, for at least two reasons:
   - there is always something more important to work on
   - "never touch working code"



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