public abstract class PhysicalFilePool extends Object implements Closeable
PhysicalFile. This implementation should be thread-safe.| Modifier and Type | Class and Description |
|---|---|
static class |
PhysicalFilePool.Type
Types of supported physical file pool.
|
| Modifier and Type | Field and Description |
|---|---|
protected Queue<PhysicalFile> |
exclusivePhysicalFilePool
Queue maintaining exclusive physical files for reusing.
|
protected long |
maxFileSize
Max size for a physical file.
|
protected PhysicalFile.PhysicalFileCreator |
physicalFileCreator
creator to create a physical file.
|
protected Map<FileMergingSnapshotManager.SubtaskKey,Queue<PhysicalFile>> |
sharedPhysicalFilePoolBySubtask
Map maintaining queues of different subtasks for reusing shared physical files.
|
| Constructor and Description |
|---|
PhysicalFilePool(long maxFileSize,
PhysicalFile.PhysicalFileCreator physicalFileCreator) |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
void |
close(FileMergingSnapshotManager.SubtaskKey subtaskKey)
Close files in shared file pool by subtaskKey and close all files in exclusive file pool.
|
protected abstract Queue<PhysicalFile> |
createFileQueue()
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.
|
boolean |
isEmpty()
Return whether the pool is empty or not.
|
abstract PhysicalFile |
pollFile(FileMergingSnapshotManager.SubtaskKey subtaskKey,
CheckpointedStateScope scope)
Poll a physical file from the pool.
|
abstract boolean |
tryPutFile(FileMergingSnapshotManager.SubtaskKey subtaskKey,
PhysicalFile physicalFile)
Try to put a physical file into file pool.
|
protected final PhysicalFile.PhysicalFileCreator physicalFileCreator
protected final long maxFileSize
protected final Map<FileMergingSnapshotManager.SubtaskKey,Queue<PhysicalFile>> sharedPhysicalFilePoolBySubtask
protected final Queue<PhysicalFile> exclusivePhysicalFilePool
public PhysicalFilePool(long maxFileSize,
PhysicalFile.PhysicalFileCreator physicalFileCreator)
public abstract boolean tryPutFile(FileMergingSnapshotManager.SubtaskKey subtaskKey, PhysicalFile physicalFile) throws IOException
subtaskKey - the key of current subtask.physicalFile - target physical file.IOException@Nonnull public abstract PhysicalFile pollFile(FileMergingSnapshotManager.SubtaskKey subtaskKey, CheckpointedStateScope scope) throws IOException
subtaskKey - the key of current subtask.scope - the scope of the checkpoint.IOExceptionprotected abstract Queue<PhysicalFile> createFileQueue()
protected Queue<PhysicalFile> getFileQueue(FileMergingSnapshotManager.SubtaskKey subtaskKey, CheckpointedStateScope scope)
subtaskKey - the key of current subtask.scope - the scope of the checkpoint.public boolean isEmpty()
public void close(FileMergingSnapshotManager.SubtaskKey subtaskKey) throws IOException
subtaskKey - the key of current subtask.IOException - if anything goes wrong when closing files.public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionCopyright © 2014–2025 The Apache Software Foundation. All rights reserved.