DaveTeng0 commented on code in PR #3923:
URL: https://github.com/apache/ozone/pull/3923#discussion_r1011096116


##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/KeyValueHandler.java:
##########
@@ -1110,6 +1113,51 @@ public void deleteBlock(Container container, BlockData 
blockData)
     }
   }
 
+  @Override
+  public void deleteUnreferenced(Container container, long localID)
+      throws IOException {
+    // Since the block/chunk is already checked that is unreferenced, no
+    // need to lock the container here.
+    StringBuilder prefixBuilder = new StringBuilder();
+    ContainerLayoutVersion layoutVersion = container.getContainerData().
+        getLayoutVersion();
+    long containerID = container.getContainerData().getContainerID();
+    // Only supports the default chunk/block name format now
+    switch (layoutVersion) {
+    case FILE_PER_BLOCK:
+      prefixBuilder.append(localID).append(".block");
+      break;
+    case FILE_PER_CHUNK:
+      prefixBuilder.append(localID).append("_chunk_");
+      break;
+    default:
+      throw new IOException("Unsupported container layout version " +
+          layoutVersion + " for the container " + containerID);
+    }
+    String prefix = prefixBuilder.toString();
+    File chunkDir = ContainerUtils.getChunkDir(container.getContainerData());
+    String[] chunkNames = getFilesWithPrefix(prefix, chunkDir);
+    if (chunkNames.length == 0) {
+      LOG.warn("Missing delete block(Container = {}, Block = {}",

Review Comment:
   ohh!! Thanks Shaohong for the explanation!!



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