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
-
Field Summary
Fields inherited from class org.apache.hadoop.hbase.backup.impl.BackupCommands.Command
cmdline, conn -
Constructor Summary
ConstructorsConstructorDescriptionDeleteCommand(org.apache.hadoop.conf.Configuration conf, org.apache.hbase.thirdparty.org.apache.commons.cli.CommandLine cmdline) -
Method Summary
Modifier and TypeMethodDescriptionprivate booleancanAnyOtherBackupCover(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.private voidCleans up Write-Ahead Logs (WALs) that are no longer required for PITR after a successful backup deletion.private String[]convertToBackupIds(List<BackupInfo> history) private voiddeleteAllBackupWALFiles(org.apache.hadoop.conf.Configuration conf, String backupWalDir) (package private) voiddeleteOldWALFiles(org.apache.hadoop.conf.Configuration conf, String backupWalDir, long cutoffTime) Cleans up old WAL and bulk-loaded files based on the determined cutoff timestamp.(package private) longDetermines the cutoff time for cleaning WAL files.private voidvoidexecute()private voidexecuteDeleteListOfBackups(org.apache.hbase.thirdparty.org.apache.commons.cli.CommandLine cmdline, boolean isForceDelete) private voidexecuteDeleteOlderThan(org.apache.hbase.thirdparty.org.apache.commons.cli.CommandLine cmdline, boolean isForceDelete) 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.getTablesDependentOnBackupForPITR(String backupId) Identifies tables that rely on the specified backup for PITR (Point-In-Time Recovery).private longparseDayDirectory(String dayDir, SimpleDateFormat dateFormat) protected voidprivate voidprotected booleanThe command can't be run if active backup session is in progress(package private) voidupdateBackupTableStartTimes(BackupSystemTable sysTable, long cutoffTimestamp) Updates the start time for continuous backups if older than cutoff timestamp.private voidvalidatePITRBackupDeletion(String[] backupIds, boolean isForceDelete) Validates whether the specified backups can be deleted while preserving Point-In-Time Recovery (PITR) capabilities.Methods inherited from class org.apache.hadoop.hbase.backup.impl.BackupCommands.Command
finish, requiresConsistentStateMethods inherited from class org.apache.hadoop.conf.Configured
getConf, setConf
-
Constructor Details
-
DeleteCommand
DeleteCommand(org.apache.hadoop.conf.Configuration conf, org.apache.hbase.thirdparty.org.apache.commons.cli.CommandLine cmdline)
-
-
Method Details
-
requiresNoActiveSession
Description copied from class:BackupCommands.CommandThe command can't be run if active backup session is in progress- Overrides:
requiresNoActiveSessionin classBackupCommands.Command- Returns:
- true if no active sessions are in progress
-
execute
- Overrides:
executein classBackupCommands.Command- Throws:
IOException
-
executeDeleteOlderThan
private void executeDeleteOlderThan(org.apache.hbase.thirdparty.org.apache.commons.cli.CommandLine cmdline, boolean isForceDelete) throws IOException - Throws:
IOException
-
convertToBackupIds
-
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:
trueif any backup (excluding the current one) fully covers the target PITR window;falseotherwise.
-
cleanUpUnusedBackupWALs
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 tablecutoffTimestamp- 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
- Throws:
ParseException
-
printUsage
- Specified by:
printUsagein classBackupCommands.Command
-