Copilot commented on code in PR #9122:
URL: https://github.com/apache/ozone/pull/9122#discussion_r2417238163


##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/service/TestKeyDeletingService.java:
##########
@@ -300,21 +301,34 @@ void checkDeletedTableCleanUpForSnapshot() throws 
Exception {
       // Create snapshot
       String snapName = uniqueObjectName("snap");
       writeClient.createSnapshot(volumeName, bucketName1, snapName);
-
+      keyDeletingService.suspend();
       // Delete the key
       writeClient.deleteKey(key1);
       writeClient.deleteKey(key2);
-
+      // Create a key3 in bucket1 which should be reclaimable to check quota 
usage.
+      OmKeyArgs key3 = createAndCommitKey(volumeName, bucketName1, 
uniqueObjectName(keyName), 3);
+      OmBucketInfo bucketInfo = writeClient.getBucketInfo(volumeName, 
bucketName1);
+      long key1Size = QuotaUtil.getReplicatedSize(key1.getDataSize(), 
key1.getReplicationConfig());
+      long key3Size = QuotaUtil.getReplicatedSize(key3.getDataSize(), 
key3.getReplicationConfig());
+
+      assertEquals(key1Size, bucketInfo.getSnapshotUsedBytes());
+      assertEquals(1, bucketInfo.getSnapshotUsedNamespace());
+      writeClient.deleteKey(key3);
+      bucketInfo = writeClient.getBucketInfo(volumeName, bucketName1);
+      assertEquals(key1Size + key3Size, bucketInfo.getSnapshotUsedBytes());
+      assertEquals(2, bucketInfo.getSnapshotUsedNamespace());
+      writeClient.getBucketInfo(volumeName, bucketName1);

Review Comment:
   This line appears to be redundant as the result is not used and the same 
call is made on line 317 with the result stored in bucketInfo.
   ```suggestion
   
   ```



##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/service/KeyDeletingService.java:
##########
@@ -165,6 +170,60 @@ Pair<Pair<Integer, Long>, Boolean> 
processKeyDeletes(List<BlockGroup> keyBlocksL
     return purgeResult;
   }
 
+  private static final class BucketPurgeSize {
+    private BucketNameInfo bucket;
+    private long purgedBytes;
+    private long purgedNamespace;
+
+    private BucketPurgeSize(String volume, String bucket, long bucketId) {
+      this.bucket = 
BucketNameInfo.newBuilder().setBucketId(bucketId).setVolumeName(volume)
+              .setBucketName(bucket).build();
+      this.purgedBytes = 0;
+      this.purgedNamespace = 0;
+    }
+
+    private BucketPurgeSize incrementPurgedBytes(long bytes) {
+      purgedBytes += bytes;
+      return this;
+    }
+
+    private BucketPurgeSize incrementPurgedNamespace(long namespace) {
+      purgedNamespace += namespace;
+      return this;
+    }
+
+    private BucketPurgeKeysSize toProtobuf() {
+      return BucketPurgeKeysSize.newBuilder()
+          .setBucketNameInfo(bucket)
+          .setPurgedBytes(purgedBytes)
+          .setPurgedNamespace(purgedNamespace)
+          .build();
+    }
+
+    private int getEstimatedSize() {
+      // Using -10 as the placeholder to get max size i.e. 10 bytes to store 
the long value in protobuf.

Review Comment:
   Using a magic number -10 as a placeholder is not clear. Consider using a 
named constant or adding more explanation about why -10 gives the maximum size 
for a long value in protobuf.



##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/service/TestKeyDeletingService.java:
##########
@@ -1374,6 +1403,6 @@ private long countBlocksPendingDeletion() {
   }
 
   private static String uniqueObjectName(String prefix) {
-    return prefix + OBJECT_COUNTER.getAndIncrement();
+    return prefix + String.format("%010d", OBJECT_COUNTER.getAndIncrement());

Review Comment:
   The format string '%010d' creates 10-digit zero-padded numbers, but this 
change from simple increment could affect test reproducibility if tests depend 
on specific object names.
   ```suggestion
       return prefix + OBJECT_COUNTER.getAndIncrement();
   ```



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