Class FileCleanupTaskHandler

java.lang.Object
org.apache.polaris.service.task.FileCleanupTaskHandler
All Implemented Interfaces:
TaskHandler
Direct Known Subclasses:
BatchFileCleanupTaskHandler, ManifestFileCleanupTaskHandler

public abstract class FileCleanupTaskHandler extends Object implements TaskHandler
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 Details

  • Constructor Details

  • Method Details

    • canHandleTask

      public abstract boolean canHandleTask(org.apache.polaris.core.entity.TaskEntity task)
      Specified by:
      canHandleTask in interface TaskHandler
    • 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:
      handleTask in interface TaskHandler
    • 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 to MAX_ATTEMPTS times before failing.
      Parameters:
      tableId - The identifier of the table associated with the file.
      fileIO - The FileIO instance 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 CompletableFuture representing 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 to MAX_ATTEMPTS times before failing.
      Parameters:
      tableId - The identifier of the table associated with the files.
      fileIO - The FileIO instance 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 CompletableFuture representing the asynchronous batch deletion operation.