Tejaskriya commented on code in PR #8941:
URL: https://github.com/apache/ozone/pull/8941#discussion_r2275581696


##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/replicas/ReplicasVerify.java:
##########
@@ -148,6 +155,11 @@ void processKey(OzoneClient ozoneClient, String 
volumeName, String bucketName, S
     OmKeyInfo keyInfo = ozoneClient.getProxy().getKeyInfo(
         volumeName, bucketName, keyName, false);
 
+    // Check if key should be filtered based on replication config
+    if (shouldFilterKey(keyInfo)) {

Review Comment:
   The name is a bit confusing, filter could be understood as keys to be passed 
or to be ignored too. It would be better to rename it to something like 
`shouldProcessKey`. With this change, the method should return true if it 
matches the conditions.



##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/replicas/ReplicasVerify.java:
##########
@@ -216,6 +228,34 @@ void processKey(OzoneClient ozoneClient, String 
volumeName, String bucketName, S
     }
   }
 
+  /**
+   * Check if the key should be filtered based on replication config.
+   * @param keyInfo the key to check
+   * @return true if the key should be filtered (skipped), false otherwise
+   */
+  private boolean shouldFilterKey(OmKeyInfo keyInfo) {
+    Optional<ReplicationConfig> filterConfig = 
replication.fromParams(getConf());
+    if (!filterConfig.isPresent()) {
+      // No filter specified, include all keys
+      return false;
+    }
+
+    ReplicationConfig keyReplicationConfig = keyInfo.getReplicationConfig();
+    ReplicationConfig filter = filterConfig.get();
+
+    // Check replication type match
+    if 
(!keyReplicationConfig.getReplicationType().equals(filter.getReplicationType()))
 {
+      return true;
+    }
+
+    // Check replication factor/config match
+    if 
(!keyReplicationConfig.getReplication().equals(filter.getReplication())) {

Review Comment:
   These can be combined:
   ```suggestion
           // Ignore key if replication type and factor/config don't match
       if 
(!keyReplicationConfig.getReplicationType().equals(filter.getReplicationType()) 
 
       && 
!keyReplicationConfig.getReplication().equals(filter.getReplication())) {
   ```



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