sreejasahithi commented on code in PR #10604:
URL: https://github.com/apache/ozone/pull/10604#discussion_r3527255056
##########
hadoop-ozone/cli-debug/src/main/java/org/apache/hadoop/ozone/debug/replicas/ReplicasVerify.java:
##########
@@ -197,8 +212,68 @@ void findCandidateKeys(OzoneClient ozoneClient,
OzoneAddress address) throws IOE
checkVolume(ozoneClient, it.next(), keysArray, allKeysPassed);
}
}
- root.put("pass", allKeysPassed.get());
- System.out.println(JsonUtils.toJsonStringWithDefaultPrettyPrinter(root));
+ if (outputDir == null) {
+ root.put("pass", allKeysPassed.get());
+ System.out.println(JsonUtils.toJsonStringWithDefaultPrettyPrinter(root));
+ } else {
+ writeOutputToFiles(root, keysArray, allKeysPassed.get());
+ }
+ }
+
+ /**
+ * Writes verification output to file(s) instead of stdout.
+ * When recordsPerFile is greater than zero, the keys are split into
multiple valid JSON files.
+ */
+ private void writeOutputToFiles(ObjectNode root, ArrayNode keysArray,
boolean allKeysPassed) throws IOException {
Review Comment:
writeOutputToFiles only writes new files, it never deletes existing ones. A
re-run overwrites .0, .1, … but leaves higher numbered files from a prior run.
This can be confusing to the user.
##########
hadoop-ozone/cli-debug/src/main/java/org/apache/hadoop/ozone/debug/replicas/ReplicasVerify.java:
##########
Review Comment:
When --out is used with --max-records-per-file, each split file only
contains:
{ "keys": [ ... ] }
But stdout and single-file --out (without splitting) include a top-level
"pass" field:
{ "pass": true/false, "keys": [ ... ] }
So the JSON shape is inconsistent across output modes. If someone parses the
split files, they can’t see the overall pass/fail result unless they check each
key’s "pass".
Not sure if this is intentional. If split files are meant to be key-only
chunks, a short note in the help text would help. If all modes should match,
consider adding top-level "pass" to split files too (or writing a small summary
file).
##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestOzoneDebugReplicasVerify.java:
##########
Review Comment:
Tests cover split output (--out + --max-records-per-file) but not
single-file --out alone. You could add a test for this case aswell.
--
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]