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 Summary
Constructors Constructor Description FileMappingManager(org.apache.flink.core.fs.FileSystem fileSystem, String remoteBase, String localBase)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MappingEntrycreateNewFile(org.apache.flink.core.fs.Path filePath, boolean overwrite, FileBasedCache cache)Create a new file in the mapping table.booleandeleteFileOrDirectory(org.apache.flink.core.fs.Path file, boolean recursive)Delete a file or directory from mapping table and file system, the directory deletion may be deferred.voidgiveUpOwnership(org.apache.flink.core.fs.Path path, org.apache.flink.runtime.state.StreamStateHandle stateHandle)intlink(String src, String dst)Add a mapping 'dst -> src' to the mapping table.List<String>listByPrefix(String path)MappingEntrymappingEntry(String path)MappingEntryregisterReusedRestoredFile(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.booleanrenameFile(String src, String dst)1.
-
-
-
Method Detail
-
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.
-
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 pathdst- 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 IOExceptionDelete a file or directory from mapping table and file system, the directory deletion may be deferred.- Parameters:
file- to be deletedrecursive- 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)
-
-