Class FileMappingManager

java.lang.Object
org.apache.flink.state.forst.fs.filemapping.FileMappingManager

public class FileMappingManager extends Object
A manager to manage file mapping of forst file system, including misc file mapping (remote file -> local file) and linked mapping (remote file -> remote file). Note, the key/value of mapping table must be a file path, directories are maintained by file system itself, directories wouldn't be the key/value of mapping table.
  • Constructor Details

    • FileMappingManager

      public FileMappingManager(org.apache.flink.core.fs.FileSystem fileSystem, String remoteBase, String localBase)
  • Method Details

    • createNewFile

      public MappingEntry createNewFile(org.apache.flink.core.fs.Path filePath, boolean overwrite, FileBasedCache cache)
      Create a new file in the mapping table.
    • registerReusedRestoredFile

      public MappingEntry registerReusedRestoredFile(String key, org.apache.flink.runtime.state.StreamStateHandle stateHandle, org.apache.flink.core.fs.Path dbFilePath, FileBasedCache cache)
      Register a file restored from checkpoints to the mapping table.
    • link

      public int link(String src, String dst)
      Add a mapping 'dst -> src' to the mapping table.
    • listByPrefix

      public List<String> listByPrefix(String path)
    • renameFile

      public boolean renameFile(String src, String dst) throws IOException
      1. If src can match any key, we only `mark rename`, no physical file would be renamed. 2. If src is a directory, all files under src will be renamed, including linked files and local files, the directory also would be renamed in file system physically.
      Parameters:
      src - the source path
      dst - the destination path
      Returns:
      always return true except for IOException
      Throws:
      IOException
    • deleteFileOrDirectory

      public boolean deleteFileOrDirectory(org.apache.flink.core.fs.Path file, boolean recursive) throws IOException
      Delete a file or directory from mapping table and file system, the directory deletion may be deferred.
      Parameters:
      file - to be deleted
      recursive - whether to delete recursively
      Returns:
      true if the file or directory is deleted successfully, false otherwise.
      Throws:
      IOException - if an error occurs during deletion
    • mappingEntry

      @VisibleForTesting @Nullable public MappingEntry mappingEntry(String path)
    • giveUpOwnership

      public void giveUpOwnership(org.apache.flink.core.fs.Path path, org.apache.flink.runtime.state.StreamStateHandle stateHandle)