code: void enterSafeMode() throws IOException {
      writeLock();
      try {
        // Ensure that any concurrent operations have been fully synced
        // before entering safe mode. This ensures that the FSImage
        // is entirely stable on disk as soon as we're in safe mode.
        getEditLog().logSyncAll();
        if (!isInSafeMode()) {
          safeMode = SafeModeUtil.getInstance(this);
          safeMode.setManual();
          return;
        }
        safeMode.setManual();
        getEditLog().logSyncAll();
        NameNode.stateChangeLog.info("STATE* Safe mode is ON. "
          + safeMode.getTurnOffTip());
      } finally {
        writeUnlock();
      }
    }
docs: Enter safe mode manually.
  
  @throws IOException