You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "sarvekshayr (via GitHub)" <gi...@apache.org> on 2025/11/26 10:19:01 UTC

Re: [PR] HDDS-14012. SCM needs to log safemode exit rules at regular intervals [ozone]

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


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/safemode/SCMSafeModeManager.java:
##########
@@ -225,6 +241,56 @@ 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 s = status.get();

Review Comment:
   Please avoid single character variable names.



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org