Xushaohong commented on code in PR #3923:
URL: https://github.com/apache/ozone/pull/3923#discussion_r1011076715
##########
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:
> just curious~ when will this happen? Is the unreferenced block deleted by
other thread?
```chunkNames`` here is an array of file/dir name, so if we cannot find any
matching one, it means the client did not write any chunk into the block.
Since the putBlock request may fail, we don't know if the chunk exists, and
thus we need to check it when receiving the request to delete such blocks~
##########
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:
> just curious~ when will this happen? Is the unreferenced block deleted by
other thread?
```chunkNames``` here is an array of file/dir name, so if we cannot find
any matching one, it means the client did not write any chunk into the block.
Since the putBlock request may fail, we don't know if the chunk exists, and
thus we need to check it when receiving the request to delete such blocks~
--
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]