Class BackupCommands.DeleteCommand

java.lang.Object
org.apache.hadoop.conf.Configured
org.apache.hadoop.hbase.backup.impl.BackupCommands.Command
org.apache.hadoop.hbase.backup.impl.BackupCommands.DeleteCommand
All Implemented Interfaces:
org.apache.hadoop.conf.Configurable
Enclosing class:
BackupCommands

  • Constructor Details

    • DeleteCommand

      DeleteCommand(org.apache.hadoop.conf.Configuration conf, org.apache.hbase.thirdparty.org.apache.commons.cli.CommandLine cmdline)
  • Method Details

    • requiresNoActiveSession

      protected boolean requiresNoActiveSession()
      Description copied from class: BackupCommands.Command
      The command can't be run if active backup session is in progress
      Overrides:
      requiresNoActiveSession in class BackupCommands.Command
      Returns:
      true if no active sessions are in progress
    • execute

      public void execute() throws IOException
      Overrides:
      execute in class BackupCommands.Command
      Throws:
      IOException
    • executeDeleteOlderThan

      private void executeDeleteOlderThan(org.apache.hbase.thirdparty.org.apache.commons.cli.CommandLine cmdline, boolean isForceDelete) throws IOException
      Throws:
      IOException
    • convertToBackupIds

      private String[] convertToBackupIds(List<BackupInfo> history)
    • executeDeleteListOfBackups

      private void executeDeleteListOfBackups(org.apache.hbase.thirdparty.org.apache.commons.cli.CommandLine cmdline, boolean isForceDelete) throws IOException
      Throws:
      IOException
    • validatePITRBackupDeletion

      private void validatePITRBackupDeletion(String[] backupIds, boolean isForceDelete) throws IOException
      Validates whether the specified backups can be deleted while preserving Point-In-Time Recovery (PITR) capabilities. If a backup is the only remaining full backup enabling PITR for certain tables, deletion is prevented unless forced.
      Parameters:
      backupIds - Array of backup IDs to validate.
      isForceDelete - Flag indicating whether deletion should proceed regardless of PITR constraints.
      Throws:
      IOException - If a backup is essential for PITR and force deletion is not enabled.
    • getTablesDependentOnBackupForPITR

      Identifies tables that rely on the specified backup for PITR (Point-In-Time Recovery). A table is considered dependent on the backup if it does not have any other valid full backups that can cover the PITR window enabled by the specified backup.
      Parameters:
      backupId - The ID of the backup being evaluated for PITR coverage.
      Returns:
      A list of tables that are dependent on the specified backup for PITR recovery.
      Throws:
      IOException - If there is an error retrieving the backup metadata or backup system table.
    • getCoveredPitrWindowForTable

      private Optional<Pair<Long,Long>> getCoveredPitrWindowForTable(BackupInfo backupInfo, long continuousBackupStartTime, long maxAllowedPITRTime, long currentTime)
      Calculates the PITR (Point-In-Time Recovery) window that the given backup enables for a table.
      Parameters:
      backupInfo - Metadata of the backup being evaluated.
      continuousBackupStartTime - When continuous backups started for the table.
      maxAllowedPITRTime - The earliest timestamp from which PITR is supported in the cluster.
      currentTime - Current time.
      Returns:
      Optional PITR window as a pair (start, end), or empty if backup is not useful for PITR.
    • canAnyOtherBackupCover

      private boolean canAnyOtherBackupCover(List<BackupInfo> allBackups, BackupInfo currentBackup, TableName table, Pair<Long,Long> targetWindow, long continuousBackupStartTime, long maxAllowedPITRTime, long currentTime)
      Checks if any backup (excluding the current backup) can cover the specified PITR window for the given table. A backup can cover the PITR window if it fully encompasses the target time range specified.
      Parameters:
      allBackups - List of all backups available.
      currentBackup - The current backup that should not be considered for coverage.
      table - The table for which we need to check backup coverage.
      targetWindow - A pair representing the target PITR window (start and end times).
      continuousBackupStartTime - When continuous backups started for the table.
      maxAllowedPITRTime - The earliest timestamp from which PITR is supported in the cluster.
      currentTime - Current time.
      Returns:
      true if any backup (excluding the current one) fully covers the target PITR window; false otherwise.
    • cleanUpUnusedBackupWALs

      private void cleanUpUnusedBackupWALs() throws IOException
      Cleans up Write-Ahead Logs (WALs) that are no longer required for PITR after a successful backup deletion. If no full backups are present, all WALs are deleted, tables are removed from continuous backup metadata, and the associated replication peer is disabled.
      Throws:
      IOException
    • determineWALCleanupCutoffTime

      Determines the cutoff time for cleaning WAL files.
      Parameters:
      sysTable - Backup system table
      Returns:
      cutoff timestamp or 0 if not found
      Throws:
      IOException
    • disableContinuousBackupReplicationPeer

      Throws:
      IOException
    • updateBackupTableStartTimes

      void updateBackupTableStartTimes(BackupSystemTable sysTable, long cutoffTimestamp) throws IOException
      Updates the start time for continuous backups if older than cutoff timestamp.
      Parameters:
      sysTable - Backup system table
      cutoffTimestamp - Timestamp before which WALs are no longer needed
      Throws:
      IOException
    • removeAllTablesFromContinuousBackup

      Throws:
      IOException
    • deleteAllBackupWALFiles

      private void deleteAllBackupWALFiles(org.apache.hadoop.conf.Configuration conf, String backupWalDir) throws IOException
      Throws:
      IOException
    • deleteOldWALFiles

      void deleteOldWALFiles(org.apache.hadoop.conf.Configuration conf, String backupWalDir, long cutoffTime) throws IOException
      Cleans up old WAL and bulk-loaded files based on the determined cutoff timestamp.
      Throws:
      IOException
    • parseDayDirectory

      private long parseDayDirectory(String dayDir, SimpleDateFormat dateFormat) throws ParseException
      Throws:
      ParseException
    • printUsage

      protected void printUsage()
      Specified by:
      printUsage in class BackupCommands.Command