devmadhuu commented on code in PR #6500:
URL: https://github.com/apache/ozone/pull/6500#discussion_r1587363239
##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/KeyValueContainerMetadataInspector.java:
##########
@@ -373,33 +375,32 @@ private boolean checkAndRepair(JsonObject parent,
return repaired;
};
- JsonObject blockCountError = buildErrorAndRepair("dBMetadata." +
+ ObjectNode blockCountError = buildErrorAndRepair("dBMetadata." +
OzoneConsts.BLOCK_COUNT, blockCountAggregate, blockCountDB,
keyRepairAction);
errors.add(blockCountError);
}
// Check and repair used bytes.
- JsonElement usedBytesDB = parent.getAsJsonObject("dBMetadata")
- .get(OzoneConsts.CONTAINER_BYTES_USED);
- JsonElement usedBytesAggregate = parent.getAsJsonObject("aggregates")
- .get("usedBytes");
+ JsonNode usedBytesDB = parent.path("dBMetadata")
+ .path(OzoneConsts.CONTAINER_BYTES_USED);
+ JsonNode usedBytesAggregate = parent.path("aggregates").path("usedBytes");
// If used bytes is absent from the DB, it is only an error if there is
// a non-zero aggregate of used bytes among the block keys.
long usedBytesDBLong = 0;
- if (!usedBytesDB.isJsonNull()) {
- usedBytesDBLong = usedBytesDB.getAsLong();
+ if (!usedBytesDB.isMissingNode()) {
Review Comment:
> The `isJsonNull()` method is used to check if the JsonElement representing
`usedBytesDB` is a JSON null value. If it's not null, then the value is
extracted using getAsLong().
>
> The `isMissingNode()` method is used to check if the JsonNode representing
`usedBytesDB` is missing or not present in the JSON structure. If it's not
missing, then the value is extracted using asLong().
Pls check old code for `blockCountDB`
--
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]