szetszwo commented on code in PR #9953:
URL: https://github.com/apache/ozone/pull/9953#discussion_r3059602154
##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/safemode/SCMSafeModeManager.java:
##########
@@ -183,6 +218,13 @@ public synchronized void validateSafeModeExitRules(String
ruleName) {
public void forceExitSafeMode() {
LOG.info("SCM force-exiting safe mode.");
status.set(SafeModeStatus.OUT_OF_SAFE_MODE);
+ exitRules.values().forEach(rule -> {
+ try {
+ rule.cleanup();
+ } catch (Exception e) {
+ LOG.warn("Safe mode exit rule cleanup failed for {}",
rule.getRuleName(), e);
+ }
+ });
Review Comment:
This change is unrelated to refreshing. Let's do it separately but not here.
##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/safemode/SCMSafeModeManager.java:
##########
@@ -117,11 +120,39 @@ public SCMSafeModeManager(final ConfigurationSource conf,
status.set(SafeModeStatus.OUT_OF_SAFE_MODE);
emitSafeModeStatus();
}
+
+ this.refreshIntervalMs = conf.getTimeDuration(
+ HDDS_SCM_SAFEMODE_RULE_REFRESH_INTERVAL,
+ HDDS_SCM_SAFEMODE_RULE_REFRESH_INTERVAL_DEFAULT,
+ TimeUnit.MILLISECONDS);
+ }
+
+ private void startRefresh() {
+ final boolean enabled = refreshIntervalMs > 0;
+ LOG.info("Container safe mode rule refresh: enabled? {}, {}={}ms",
+ enabled, HDDS_SCM_SAFEMODE_RULE_REFRESH_INTERVAL, refreshIntervalMs);
+ if (!enabled) {
+ return;
+ }
+ final String name = "safemode-refreshing(" + refreshIntervalMs +
"ms)-thread";
+ final Thread t = new Thread(() -> {
+ while (getInSafeMode()) {
+ try {
+ Thread.sleep(refreshIntervalMs);
+ } catch (InterruptedException e) {
+ LOG.info("Interrupted {}", name, e);
+ }
+ runRefreshAndValidate();
+ }
Review Comment:
Sorry that the try-catch should be outside the while-loop.
--
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]