szetszwo commented on code in PR #4825:
URL: https://github.com/apache/ozone/pull/4825#discussion_r1245441994


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManager.java:
##########
@@ -4431,6 +4433,24 @@ public void setTimes(OmKeyArgs keyArgs, long mtime, long 
atime)
       throws IOException {
   }
 
+  @Override
+  public boolean setSafeMode(SafeModeAction action, boolean isChecked)
+      throws IOException {
+    switch (action) {
+    case ENTER:
+      throw new OMException("Enter safe mode is unsupported",
+          INTERNAL_ERROR);
+    case LEAVE:
+    case FORCE_EXIT:

Review Comment:
   For `LEAVE`, it should exit safe mode only if preCheck is true.  We should 
make the change separately.
   ```java
   //SCMSafeModeManager
   @@ -237,20 +237,25 @@ public void completePreCheck(EventPublisher 
eventQueue) {
       * 2. Emits START_REPLICATION for ReplicationManager.
       * 3. Cleanup resources.
       * 4. Emit safe mode status.
   -   * @param eventQueue
       */
      @VisibleForTesting
   -  public void exitSafeMode(EventPublisher eventQueue) {
   -    LOG.info("SCM exiting safe mode.");
   -    // If safemode is exiting, then pre check must also have passed so
   -    // set it to true.
   -    setPreCheckComplete(true);
   +  public boolean exitSafeMode(boolean force) {
   +    LOG.info("SCM exiting safe mode, force? {}", force);
   +    if (force) {
   +      // If force exiting, set preCheck to true.
   +      setPreCheckComplete(true);
   +    } else {
   +      if (!getPreCheckComplete()) {
   +        return false;
   +      }
   +    }
        setInSafeMode(false);
    
        // TODO: Remove handler registration as there is no need to listen to
        // register events anymore.
    
        emitSafeModeStatus();
   +    return true;
      }
   ```



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