sumitagrawl commented on code in PR #8566:
URL: https://github.com/apache/ozone/pull/8566#discussion_r2206446563


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/BlockManagerImpl.java:
##########
@@ -223,20 +223,26 @@ public void deleteBlocks(List<BlockGroup> 
keyBlocksInfoList)
     // TODO: track the block size info so that we can reclaim the container
     // TODO: used space when the block is deleted.
     for (BlockGroup bg : keyBlocksInfoList) {
+      List<DeletedBlock> deletedBlocks = bg.getAllBlocks();

Review Comment:
   we can have only latest list with translated with size = 0 and 
repeatedSize=0 if data is not available during upgrade.



##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/client/DeletedBlock.java:
##########
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hdds.client;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import java.util.Objects;
+import org.apache.hadoop.hdds.protocol.proto.HddsProtos;
+
+/**
+ * DeletedBlock of Ozone (BlockID + usedBytes).
+ */
+public class DeletedBlock {
+
+  private BlockID blockID;
+  private long size;
+  private long replicatedSize;
+
+  public DeletedBlock(BlockID blockID, long size, long replicatedSize) {
+    this.blockID = blockID;
+    this.size = size;
+    this.replicatedSize = replicatedSize;
+  }
+
+  public BlockID getBlockID() {
+    return this.blockID;
+  }
+
+  public long getSize() {
+    return this.size;
+  }
+
+  public long getReplicatedSize() {
+    return this.replicatedSize;
+  }
+
+  @Override
+  public String toString() {
+    StringBuilder sb = new StringBuilder(64);
+    appendTo(sb);
+    return sb.toString();
+  }
+
+  public void appendTo(StringBuilder sb) {
+    sb.append(" localID: ").append(blockID.getContainerBlockID().getLocalID());
+    sb.append(" containerID: 
").append(blockID.getContainerBlockID().getContainerID());
+    sb.append(" size: ").append(size);
+    sb.append(" replicatedSize: ").append(replicatedSize);
+  }
+
+  @JsonIgnore
+  public HddsProtos.DeletedBlock getProtobuf() {
+    return HddsProtos.DeletedBlock.newBuilder()
+        .setBlockId(blockID.getProtobuf())
+        .setSize(size)
+        .setReplicatedSize(replicatedSize)
+        .build();
+  }
+
+  @JsonIgnore
+  public static DeletedBlock getFromProtobuf(HddsProtos.DeletedBlock 
deletedBlockID) {
+    return new DeletedBlock(
+        BlockID.getFromProtobuf(deletedBlockID.getBlockId()),
+        deletedBlockID.getSize(),
+        deletedBlockID.getReplicatedSize());
+  }
+
+  @Override
+  public boolean equals(Object o) {

Review Comment:
   we do not need equal and hash here, no sorting or comparision



##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java:
##########
@@ -720,7 +723,11 @@ public PendingKeysDeletion getPendingDeletionKeys(
       String volume, String bucket, String startKey,
       CheckedFunction<KeyValue<String, OmKeyInfo>, Boolean, IOException> 
filter,
       int count) throws IOException {
+    boolean isDataDistributionEnabled = 
ozoneManager.getScmInfo().getMetaDataLayoutVersion() >=

Review Comment:
   no need any logic here, can be part of 
ScmBlockLocationProtocolClientSideTranslatorPB where conversion can be done 
based on protocol type compatibility. This logic can be simple.



##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/client/DeletedBlock.java:
##########
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hdds.client;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import java.util.Objects;
+import org.apache.hadoop.hdds.protocol.proto.HddsProtos;
+
+/**
+ * DeletedBlock of Ozone (BlockID + usedBytes).
+ */
+public class DeletedBlock {
+
+  private BlockID blockID;
+  private long size;
+  private long replicatedSize;
+
+  public DeletedBlock(BlockID blockID, long size, long replicatedSize) {
+    this.blockID = blockID;
+    this.size = size;
+    this.replicatedSize = replicatedSize;
+  }
+
+  public BlockID getBlockID() {
+    return this.blockID;
+  }
+
+  public long getSize() {
+    return this.size;
+  }
+
+  public long getReplicatedSize() {
+    return this.replicatedSize;
+  }
+
+  @Override
+  public String toString() {
+    StringBuilder sb = new StringBuilder(64);
+    appendTo(sb);
+    return sb.toString();
+  }
+
+  public void appendTo(StringBuilder sb) {

Review Comment:
   this need not be public or can be part of toString logic itself



##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/client/DeletedBlock.java:
##########
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hdds.client;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import java.util.Objects;
+import org.apache.hadoop.hdds.protocol.proto.HddsProtos;
+
+/**
+ * DeletedBlock of Ozone (BlockID + usedBytes).
+ */
+public class DeletedBlock {

Review Comment:
   move this with BlockGroup module path,
   org.apache.hadoop.ozone.common.BlockGroup



##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/client/DeletedBlock.java:
##########
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hdds.client;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import java.util.Objects;
+import org.apache.hadoop.hdds.protocol.proto.HddsProtos;
+
+/**
+ * DeletedBlock of Ozone (BlockID + usedBytes).
+ */
+public class DeletedBlock {
+
+  private BlockID blockID;
+  private long size;
+  private long replicatedSize;
+
+  public DeletedBlock(BlockID blockID, long size, long replicatedSize) {
+    this.blockID = blockID;
+    this.size = size;
+    this.replicatedSize = replicatedSize;
+  }
+
+  public BlockID getBlockID() {
+    return this.blockID;
+  }
+
+  public long getSize() {
+    return this.size;
+  }
+
+  public long getReplicatedSize() {
+    return this.replicatedSize;
+  }
+
+  @Override
+  public String toString() {
+    StringBuilder sb = new StringBuilder(64);
+    appendTo(sb);
+    return sb.toString();
+  }
+
+  public void appendTo(StringBuilder sb) {
+    sb.append(" localID: ").append(blockID.getContainerBlockID().getLocalID());
+    sb.append(" containerID: 
").append(blockID.getContainerBlockID().getContainerID());
+    sb.append(" size: ").append(size);
+    sb.append(" replicatedSize: ").append(replicatedSize);
+  }
+
+  @JsonIgnore
+  public HddsProtos.DeletedBlock getProtobuf() {
+    return HddsProtos.DeletedBlock.newBuilder()

Review Comment:
   we do not need proto conversion here, can be part of BlockGroup itself



-- 
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: issues-unsubscr...@ozone.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@ozone.apache.org
For additional commands, e-mail: issues-h...@ozone.apache.org

Reply via email to