sreejasahithi commented on code in PR #9376:
URL: https://github.com/apache/ozone/pull/9376#discussion_r2622497353


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/safemode/SCMSafeModeManager.java:
##########
@@ -225,6 +245,63 @@ public double getCurrentContainerThreshold() {
         .getCurrentContainerThreshold();
   }
 
+  private synchronized void startSafeModePeriodicLogger() {
+    if (!getInSafeMode() || safeModeLogExecutor != null) {
+      return;
+    }
+    safeModeLogExecutor = Executors.newScheduledThreadPool(1,
+        new ThreadFactoryBuilder()
+            .setNameFormat(scmContext.threadNamePrefix() + 
"SCM-SafeMode-Log-%d")
+            .setDaemon(true)
+            .build());
+    safeModeLogExecutor.scheduleAtFixedRate(() -> {
+      try {
+        logSafeModeStatus();
+      } catch (Throwable t) {
+        LOG.warn("Safe mode periodic logger encountered an error", t);
+      }
+    }, 0L, safeModeLogIntervalMs, TimeUnit.MILLISECONDS);
+    LOG.info("Started periodic Safe Mode logging with interval {} ms", 
safeModeLogIntervalMs);
+  }
+
+  private void logSafeModeStatus() {
+    if (!getInSafeMode()) {
+      stopSafeModePeriodicLogger();
+      return;
+    }
+    SafeModeStatus safeModeStatus = status.get();
+    int validatedCount;
+    int preCheckValidatedCount;
+    synchronized (this) {
+      validatedCount = validatedRules.size();
+      preCheckValidatedCount = validatedPreCheckRules.size();
+    }
+    String rules = exitRules.values().stream()
+        .map(rule -> {
+          String name = rule.getRuleName();
+          boolean isValidated;
+          synchronized (this) {
+            isValidated = validatedRules.contains(name);
+          }
+          return name + "(status=" + (isValidated ? "validated" : "waiting")
+              + ", " + rule.getStatusText() + ")";
+        })
+        .collect(Collectors.joining(", "));
+    LOG.info(

Review Comment:
   with this update the periodic log message looks as follows:
   ```
   2025-12-14 15:48:47 2025-12-14 10:18:47,920 
[EventQueue-NodeRegistrationContainerReportForDataNodeSafeModeRule] INFO 
safemode.SCMSafeModeManager: 
   2025-12-14 15:48:47 SCM SafeMode Status | state=PRE_CHECKS_PASSED 
preCheckComplete=true validatedPreCheckRules=1/1 validatedRules=4/5
   2025-12-14 15:48:47 SCM SafeMode Status | DataNodeSafeModeRule (validated) 
registered datanodes (=5) >= required datanodes (=5)
   2025-12-14 15:48:47 SCM SafeMode Status | RatisContainerSafeModeRule 
(validated) 100.00% of [RATIS] Containers(0 / 0) with at least N reported 
replica (=1.00) >= safeModeCutoff (=0.99)
   2025-12-14 15:48:47 SCM SafeMode Status | HealthyPipelineSafeModeRule 
(waiting) healthy Ratis/THREE pipelines (=0) >= healthyPipelineThresholdCount 
(=1)
   2025-12-14 15:48:47 SCM SafeMode Status | OneReplicaPipelineSafeModeRule 
(validated) reported Ratis/THREE pipelines with at least one datanode (=0) >= 
threshold (=0)
   2025-12-14 15:48:47 SCM SafeMode Status | ECContainerSafeModeRule 
(validated) 100.00% of [EC] Containers(0 / 0) with at least N reported replica 
(=1.00) >= safeModeCutoff (=0.99)
   ```



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