errose28 commented on code in PR #8898:
URL: https://github.com/apache/ozone/pull/8898#discussion_r2261294953


##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/replicas/ReplicasVerify.java:
##########
@@ -207,15 +271,95 @@ void processKey(OzoneClient ozoneClient, String 
volumeName, String bucketName, S
     }
 
     keyNode.put("pass", keyPass);
-    if (!keyPass) {
+    if (keyPass) {
+      keysPassed.incrementAndGet();
+    } else {
+      keysFailed.incrementAndGet();
       allKeysPassed.set(false);
+      
+      for (String failedType : failedVerificationTypes) {
+        AtomicInteger counter = failuresByType.get(failedType);
+        if (counter != null) {
+          counter.incrementAndGet();
+        } else {
+          failuresByType.computeIfAbsent(failedType, k -> new 
AtomicInteger(0)).incrementAndGet();
+        }
+      }
     }
 
     if (!keyPass || allResults) {
       keysArray.add(keyNode);
     }
   }
 
+  /**
+   * Adds ShutdownHook to print summary statistics.
+   */
+  private void addShutdownHook() {
+    ShutdownHookManager.get().addShutdownHook(() -> {
+      if (endTime == 0) {
+        endTime = System.nanoTime();
+      }
+      printSummary(System.out);

Review Comment:
   We should print the summary to stderr so the json output can be redirected 
into tools like jq and does not need to be manually trimmed off. Even though it 
is not technically an "error", this pattern is used with standard commands like 
`time`, which prints its execution time summary to stderr to avoid interfering 
with the output of the command it was timing.
   ```suggestion
         printSummary(System.err);
   ```



-- 
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]

Reply via email to