errose28 commented on code in PR #8146:
URL: https://github.com/apache/ozone/pull/8146#discussion_r2036215557
##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/replicas/chunk/ChunkKeyHandler.java:
##########
@@ -123,51 +119,64 @@ protected void execute(OzoneClient client, OzoneAddress
address)
keyLocation.getContainerID(), pipeline);
ArrayNode responseFromAllNodes = JsonUtils.createArrayNode();
for (Map.Entry<DatanodeDetails,
ContainerProtos.GetBlockResponseProto> entry : responses.entrySet()) {
- chunkPaths.clear();
ObjectNode jsonObj = JsonUtils.createObjectNode(null);
if (entry.getValue() == null) {
- LOG.error("Cant execute getBlock on this node");
+ LOG.error("Can't execute getBlock on this node");
continue;
}
- tempchunks = entry.getValue().getBlockData().getChunksList();
- ContainerProtos.ContainerDataProto containerData =
- readContainerResponses.get(entry.getKey()).getContainerData();
- for (ContainerProtos.ChunkInfo chunkInfo : tempchunks) {
- String fileName = containerLayoutVersion.getChunkFile(new File(
+ ContainerProtos.ChunkInfo chunks = null;
+ String fileName = "";
+ if (entry.getValue().getBlockData().getChunksCount() > 0) {
+ chunks = entry.getValue().getBlockData().getChunks(0);
+ ContainerProtos.ContainerDataProto containerData =
+
readContainerResponses.get(entry.getKey()).getContainerData();
+ fileName = containerLayoutVersion.getChunkFile(new File(
getChunkLocationPath(containerData.getContainerPath())),
keyLocation.getBlockID(),
- chunkInfo.getChunkName()).toString();
- chunkPaths.add(fileName);
- ChunkDetails chunkDetails = new ChunkDetails();
- chunkDetails.setChunkName(fileName);
- chunkDetails.setChunkOffset(chunkInfo.getOffset());
- chunkDetailsList.add(chunkDetails);
+ chunks.getChunkName()).toString();
}
- containerChunkInfoVerbose.setContainerPath(containerData
- .getContainerPath());
- containerChunkInfoVerbose.setPipeline(keyPipeline);
- containerChunkInfoVerbose.setChunkInfos(chunkDetailsList);
- containerChunkInfo.setFiles(chunkPaths);
- containerChunkInfo.setPipelineID(keyPipeline.getId().getId());
- if (isECKey) {
- ChunkType blockChunksType =
- isECParityBlock(keyPipeline, entry.getKey()) ?
- ChunkType.PARITY : ChunkType.DATA;
- containerChunkInfoVerbose.setChunkType(blockChunksType);
- containerChunkInfo.setChunkType(blockChunksType);
+
+ ObjectNode dnObj = JsonUtils.createObjectNode(null);
+ dnObj.put("hostname", entry.getKey().getHostName());
+ dnObj.put("ip", entry.getKey().getIpAddress());
+ dnObj.put("uuid", entry.getKey().getUuidString());
+ jsonObj.set("datanode", dnObj);
+
+ jsonObj.put("file", fileName);
+
+ ObjectMapper objectMapper = new ObjectMapper();
+ JsonNode blockDataNode =
objectMapper.readTree(JsonFormat.printer().print(entry.getValue().getBlockData()));
Review Comment:
This is going to create an intermediate json object, which we then just
extract values from to put in our final json object. We should just extract
values from the proto and put them in our json objects directly without this
step, since the json object it gives us is not in our desired format.
--
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]