interface SafeMode

The SafeMode interface provides a way to perform safe mode actions and obtain the status after such actions performed to the FileSystem.

This is admin only interface, should be implemented accordingly when necessary to Filesystem that support safe mode, e.g. DistributedFileSystem (HDFS) and ViewDistributedFileSystem.

public interface SafeMode {
  default boolean setSafeMode(SafeModeAction action) throws IOException {
    return setSafeMode(action, false);
  boolean setSafeMode(SafeModeAction action, boolean isChecked) throws IOException;

The goals of this interface is allow any file system implementation to share the same concept of safe mode with the following actions and states

Safe mode actions

  1. GET, get the safe mode status of the file system.
  2. ENTER, enter the safe mode for the file system.
  3. LEAVE, exit safe mode for the file system gracefully.
  4. FORCE_EXIT, exit safe mode for the file system even if there is any ongoing data process.

Safe mode states

  1. return true, when safe mode is on.
  2. return false, when safe mode is off, usually it’s the result of safe mode actions with GET, LEAVE, FORCE_EXIT.