ChenSammi commented on code in PR #5662:
URL: https://github.com/apache/ozone/pull/5662#discussion_r1452962012
##########
hadoop-ozone/client/src/test/java/org/apache/hadoop/ozone/client/MockDatanodeStorage.java:
##########
@@ -77,31 +159,51 @@ public void writeChunk(
if (exception != null) {
throw exception;
}
- data.put(createKey(blockID, chunkInfo),
- ByteString.copyFrom(bytes.toByteArray()));
- chunks.put(createKey(blockID, chunkInfo), chunkInfo);
+ String blockKey = createKey(blockID);
+ ByteString block;
+ if (data.containsKey(blockKey)) {
+ block = data.get(blockKey);
+ assert block.size() == chunkInfo.getOffset();
+ data.put(blockKey, block.concat(bytes));
+ } else {
+ assert chunkInfo.getOffset() == 0;
+ data.put(blockKey, bytes);
+ }
+
fullBlockData
.put(new BlockID(blockID.getContainerID(), blockID.getLocalID()),
- fullBlockData.getOrDefault(blockID, "")
+ fullBlockData.getOrDefault(toBlockID(blockID), "")
.concat(bytes.toStringUtf8()));
}
public ChunkInfo readChunkInfo(
DatanodeBlockID blockID,
ChunkInfo chunkInfo) {
- return chunks.get(createKey(blockID, chunkInfo));
+ BlockData blockData = getBlock(blockID);
+ for (ChunkInfo info : blockData.getChunksList()) {
+ if (info.getLen() == chunkInfo.getLen() &&
+ info.getOffset() == chunkInfo.getOffset()) {
+ return info;
+ }
+ }
+ throw new AssertionError("chunk " + chunkInfo + " not found");
}
public ByteString readChunkData(
DatanodeBlockID blockID,
ChunkInfo chunkInfo) {
- return data.get(createKey(blockID, chunkInfo));
-
+ //return data.get(createKey(blockID, chunkInfo));
Review Comment:
remove this line.
--
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]