fapifta commented on a change in pull request #719: HDDS-3270. Allow safemode listeners to be notified when some precheck rules pass URL: https://github.com/apache/hadoop-ozone/pull/719#discussion_r400819244
########## File path: hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/SCMPipelineManager.java ########## @@ -641,13 +663,26 @@ public boolean getSafeModeStatus() { } @Override - public void handleSafeModeTransition( + public synchronized void handleSafeModeTransition( SCMSafeModeManager.SafeModeStatus status) { - this.isInSafeMode.set(status.getSafeModeStatus()); - if (!status.getSafeModeStatus()) { - // TODO: #CLUTIL if we reenter safe mode the fixed interval pipeline - // creation job needs to stop + // TODO: #CLUTIL - handle safemode getting re-enabled + boolean currentAllowPipelines = + allowPipelineCreation.getAndSet(status.isPreCheckComplete()); + boolean currentlyInSafeMode = + isInSafeMode.getAndSet(status.isInSafeMode()); + boolean triggerPipelines = false; + + // Trigger pipeline creation only if the preCheck status has changed to + // complete. + if (allowPipelineCreation.get() && !currentAllowPipelines) { + triggerPipelines = true; + } + // Start the pipeline creation thread only when safemode switches off + if (!getSafeModeStatus() && currentlyInSafeMode) { startPipelineCreator(); + triggerPipelines = true; + } + if (triggerPipelines) { Review comment: Oh, I missed one small detail in the shouldSchedulePipelineCreator method... and misinterpreted it sorry about that... So triggerPipelineCreation will create pipelines if the safemode precheck is finished and allowPipelineCreation is already true in SCMPipelineManager. With that it makes perfect sense, that we want to trigger the pipeline creation once when precheck is complete, and start the scheduled runs after the safe mode is exited. But in this case, it would be enough to call triggerPipelineCreation when we arrived to the end of the precheck stage, and start the background pipeline creator schedule when we left safe mode. Now what I understand happens at a startup when this is interesting is the following: for (0..nodecount) { triggerPipelineCreation() // noop as allowPipelineCreation is false } precheck finished triggerPipelineCreation // runs and creates pipelines safe mode exit startFixedIntervalPipelineCreator // calls createPipelines right away once at start triggerPipelineCreation // tries to call createPipelines if it is not running from the prev. call I think we don't need this last call, which makes the triggerPipelines boolean unnecessary and the code a bit simpler. Is it correct, or I am still missing something? :) ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: ozone-issues-unsubscr...@hadoop.apache.org For additional commands, e-mail: ozone-issues-h...@hadoop.apache.org