Package org.apache.polaris.service.task
Class FileCleanupTaskHandler
java.lang.Object
org.apache.polaris.service.task.FileCleanupTaskHandler
- All Implemented Interfaces:
TaskHandler
- Direct Known Subclasses:
BatchFileCleanupTaskHandler,ManifestFileCleanupTaskHandler
Abstract base class for handling file cleanup tasks within Apache Polaris.
This class is for performing asynchronous file deletions with retry logic.
Subclasses must implement canHandleTask(TaskEntity) and handleTask(TaskEntity, CallContext) to define task-specific handling logic.
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal ExecutorServicestatic final intfinal TaskFileIOSupplierstatic final int -
Constructor Summary
ConstructorsConstructorDescriptionFileCleanupTaskHandler(TaskFileIOSupplier fileIOSupplier, ExecutorService executorService) -
Method Summary
Modifier and TypeMethodDescriptionabstract booleancanHandleTask(org.apache.polaris.core.entity.TaskEntity task) abstract voidhandleTask(org.apache.polaris.core.entity.TaskEntity task, org.apache.polaris.core.context.CallContext callContext) Handles the provided task.tryDelete(org.apache.iceberg.catalog.TableIdentifier tableId, org.apache.iceberg.io.FileIO fileIO, Iterable<String> files, String type, Boolean isConcurrent, Throwable e, int attempt) Attempts to delete multiple files in a batch operation with retry logic.tryDelete(org.apache.iceberg.catalog.TableIdentifier tableId, org.apache.iceberg.io.FileIO fileIO, String baseFile, String file, Throwable e, int attempt) Attempts to delete a single file with retry logic.
-
Field Details
-
MAX_ATTEMPTS
public static final int MAX_ATTEMPTS- See Also:
-
FILE_DELETION_RETRY_MILLIS
public static final int FILE_DELETION_RETRY_MILLIS- See Also:
-
fileIOSupplier
-
executorService
-
-
Constructor Details
-
FileCleanupTaskHandler
-
-
Method Details
-
canHandleTask
public abstract boolean canHandleTask(org.apache.polaris.core.entity.TaskEntity task) - Specified by:
canHandleTaskin interfaceTaskHandler
-
handleTask
public abstract void handleTask(org.apache.polaris.core.entity.TaskEntity task, org.apache.polaris.core.context.CallContext callContext) Handles the provided task. A normal return indicates success and the task entity will be dropped; throwing indicates failure and triggers the task retry path.- Specified by:
handleTaskin interfaceTaskHandler
-
tryDelete
public CompletableFuture<Void> tryDelete(org.apache.iceberg.catalog.TableIdentifier tableId, org.apache.iceberg.io.FileIO fileIO, String baseFile, String file, Throwable e, int attempt) Attempts to delete a single file with retry logic. If the file does not exist, it logs a message and does not retry. If an error occurs, it retries up toMAX_ATTEMPTStimes before failing.- Parameters:
tableId- The identifier of the table associated with the file.fileIO- TheFileIOinstance used for file operations.baseFile- An optional base file associated with the file being deleted (can be null).file- The path of the file to be deleted.e- The exception from the previous attempt, if any.attempt- The current retry attempt count.- Returns:
- A
CompletableFuturerepresenting the asynchronous deletion operation.
-
tryDelete
public CompletableFuture<Void> tryDelete(org.apache.iceberg.catalog.TableIdentifier tableId, org.apache.iceberg.io.FileIO fileIO, Iterable<String> files, String type, Boolean isConcurrent, Throwable e, int attempt) Attempts to delete multiple files in a batch operation with retry logic. If an error occurs, it retries up toMAX_ATTEMPTStimes before failing.- Parameters:
tableId- The identifier of the table associated with the files.fileIO- TheFileIOinstance used for file operations.files- The list of file paths to be deleted.type- The type of files being deleted (e.g., data files, metadata files).isConcurrent- Whether the deletion should be performed concurrently.e- The exception from the previous attempt, if any.attempt- The current retry attempt count.- Returns:
- A
CompletableFuturerepresenting the asynchronous batch deletion operation.
-