private static boolean isInSafeMode(FileSystem dfs) throws IOException {
    if (isDistributedFileSystem(dfs)) {
      return ((DistributedFileSystem) dfs).setSafeMode(SAFEMODE_GET, true);
    } else {
      try {
        Object ret = dfs.getClass()
          .getMethod("setSafeMode", new Class[] { safeModeActionClazz, Boolean.class })
          .invoke(dfs, safeModeGet, true);
        return (Boolean) ret;
      } catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException e) {
        LOG.error("The file system does not support setSafeMode(). Abort.", e);
        throw new RuntimeException(e);
      }
    }
  }
Inquire the Active NameNode's safe mode status.
@param dfs A DistributedFileSystem object representing the underlying HDFS.
@return whether we're in safe mode
hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java