Class PhysicalFilePool
java.lang.Object
org.apache.flink.runtime.checkpoint.filemerging.PhysicalFilePool
- All Implemented Interfaces:
Closeable,AutoCloseable
- Direct Known Subclasses:
BlockingPhysicalFilePool,NonBlockingPhysicalFilePool
A pool for reusing
PhysicalFile. This implementation should be thread-safe.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumTypes of supported physical file pool. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Queue<PhysicalFile>Queue maintaining exclusive physical files for reusing.protected final longMax size for a physical file.protected final PhysicalFile.PhysicalFileCreatorcreator to create a physical file.protected final Map<FileMergingSnapshotManager.SubtaskKey,Queue<PhysicalFile>> Map maintaining queues of different subtasks for reusing shared physical files. -
Constructor Summary
ConstructorsConstructorDescriptionPhysicalFilePool(long maxFileSize, PhysicalFile.PhysicalFileCreator physicalFileCreator) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidclose(FileMergingSnapshotManager.SubtaskKey subtaskKey) Close files in shared file pool by subtaskKey and close all files in exclusive file pool.protected abstract Queue<PhysicalFile>Create and return a file queue.protected Queue<PhysicalFile>getFileQueue(FileMergingSnapshotManager.SubtaskKey subtaskKey, CheckpointedStateScope scope) Get or create a file queue for specific subtaskKey and checkpoint scope.booleanisEmpty()Return whether the pool is empty or not.abstract PhysicalFilepollFile(FileMergingSnapshotManager.SubtaskKey subtaskKey, CheckpointedStateScope scope) Poll a physical file from the pool.abstract booleantryPutFile(FileMergingSnapshotManager.SubtaskKey subtaskKey, PhysicalFile physicalFile) Try to put a physical file into file pool.
-
Field Details
-
physicalFileCreator
creator to create a physical file. -
maxFileSize
protected final long maxFileSizeMax size for a physical file. -
exclusivePhysicalFilePool
Queue maintaining exclusive physical files for reusing.
-
-
Constructor Details
-
PhysicalFilePool
-
-
Method Details
-
tryPutFile
public abstract boolean tryPutFile(FileMergingSnapshotManager.SubtaskKey subtaskKey, PhysicalFile physicalFile) throws IOException Try to put a physical file into file pool.- Parameters:
subtaskKey- the key of current subtask.physicalFile- target physical file.- Returns:
- true if file is in the pool, false otherwise.
- Throws:
IOException
-
pollFile
@Nonnull public abstract PhysicalFile pollFile(FileMergingSnapshotManager.SubtaskKey subtaskKey, CheckpointedStateScope scope) throws IOException Poll a physical file from the pool.- Parameters:
subtaskKey- the key of current subtask.scope- the scope of the checkpoint.- Returns:
- a physical file.
- Throws:
IOException
-
createFileQueue
Create and return a file queue.- Returns:
- a created file queue.
-
getFileQueue
protected Queue<PhysicalFile> getFileQueue(FileMergingSnapshotManager.SubtaskKey subtaskKey, CheckpointedStateScope scope) Get or create a file queue for specific subtaskKey and checkpoint scope.- Parameters:
subtaskKey- the key of current subtask.scope- the scope of the checkpoint.- Returns:
- an existing or created file queue.
-
isEmpty
public boolean isEmpty()Return whether the pool is empty or not.- Returns:
- whether the pool is empty or not.
-
close
Close files in shared file pool by subtaskKey and close all files in exclusive file pool.- Parameters:
subtaskKey- the key of current subtask.- Throws:
IOException- if anything goes wrong when closing files.
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-