Class BackupAdminImpl
java.lang.Object
org.apache.hadoop.hbase.backup.impl.BackupAdminImpl
- All Implemented Interfaces:
Closeable,AutoCloseable,BackupAdmin
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringprivate final Connectionprivate static final org.slf4j.Logger -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddToBackupSet(String name, TableName[] tables) Add tables to backup set commandbackupTables(BackupRequest request) Backup given list of tables fully.private voidcheckIfValidForMerge(String[] backupIds, BackupSystemTable table) Verifies that backup images are valid for merge.private voidcleanupBackupDir(BackupInfo backupInfo, TableName table, org.apache.hadoop.conf.Configuration conf) Clean up the data at target directoryvoidclose()private intdeleteBackup(String backupId, BackupSystemTable sysTable) Delete single backup and all related backups
Algorithm:
Backup type: FULL or INCREMENTAL
Is this last backup session for table T: YES or NO
For every table T from table list 'tables':
if(FULL, YES) deletes only physical data (PD)
if(FULL, NO), deletes PD, scans all newer backups and removes T from backupInfo,
until we either reach the most recent backup for T in the system or FULL backup
which includes T
if(INCREMENTAL, YES) deletes only physical data (PD) if(INCREMENTAL, NO) deletes physical data and for table T scans all backup images between last
FULL backup, which is older than the backup being deleted and the next FULL backup (if exists)
or last one for a particular table T and removes T from list of backup tables.intdeleteBackups(String[] backupIds) Delete backup image commandbooleandeleteBackupSet(String name) Delete backup set commandexcludeNonExistingTables(List<TableName> tableList, List<TableName> nonExistingTableList) private voidfinalizeDelete(List<String> backupRoots, BackupSystemTable table) Updates incremental backup set for every backupRootprivate List<BackupInfo>getAffectedBackupSessions(BackupInfo backupInfo, TableName tn, BackupSystemTable table) getBackupInfo(String backupId) Describe backup image commandgetBackupSet(String name) Backup set describe command.getHistory(int n) Show backup history commandgetHistory(int n, BackupInfo.Filter... filters) Show backup history command with filtersprivate booleanisLastBackupSession(BackupSystemTable table, TableName tn, long startTime) Backup sets list command - list all backup sets.voidmergeBackups(String[] backupIds) Merge backup images commandvoidremoveFromBackupSet(String name, TableName[] tables) Remove tables from backup setprivate voidremoveTableFromBackupImage(BackupInfo info, TableName tn, BackupSystemTable sysTable) voidrestore(RestoreRequest request) Restore backupprivate String[]toStringArray(TableName[] list)
-
Field Details
-
CHECK_OK
- See Also:
-
CHECK_FAILED
- See Also:
-
LOG
-
conn
-
-
Constructor Details
-
BackupAdminImpl
-
-
Method Details
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
getBackupInfo
Description copied from interface:BackupAdminDescribe backup image command- Specified by:
getBackupInfoin interfaceBackupAdmin- Parameters:
backupId- backup id- Returns:
- backup info
- Throws:
IOException- exception
-
deleteBackups
Description copied from interface:BackupAdminDelete backup image command- Specified by:
deleteBackupsin interfaceBackupAdmin- Parameters:
backupIds- array of backup ids- Returns:
- total number of deleted sessions
- Throws:
IOException- exception
-
finalizeDelete
Updates incremental backup set for every backupRoot- Parameters:
backupRoots- backupRoots for which to revise the incremental backup settable- backup system table- Throws:
IOException- if a table operation fails
-
deleteBackup
Delete single backup and all related backups
Algorithm:
Backup type: FULL or INCREMENTAL
Is this last backup session for table T: YES or NO
For every table T from table list 'tables':
if(FULL, YES) deletes only physical data (PD)
if(FULL, NO), deletes PD, scans all newer backups and removes T from backupInfo,
until we either reach the most recent backup for T in the system or FULL backup
which includes T
if(INCREMENTAL, YES) deletes only physical data (PD) if(INCREMENTAL, NO) deletes physical data and for table T scans all backup images between last
FULL backup, which is older than the backup being deleted and the next FULL backup (if exists)
or last one for a particular table T and removes T from list of backup tables.- Parameters:
backupId- backup idsysTable- backup system table- Returns:
- total number of deleted backup images
- Throws:
IOException- if deleting the backup fails
-
removeTableFromBackupImage
private void removeTableFromBackupImage(BackupInfo info, TableName tn, BackupSystemTable sysTable) throws IOException - Throws:
IOException
-
getAffectedBackupSessions
private List<BackupInfo> getAffectedBackupSessions(BackupInfo backupInfo, TableName tn, BackupSystemTable table) throws IOException - Throws:
IOException
-
cleanupBackupDir
private void cleanupBackupDir(BackupInfo backupInfo, TableName table, org.apache.hadoop.conf.Configuration conf) throws IOException Clean up the data at target directory- Throws:
IOException- if cleaning up the backup directory fails
-
isLastBackupSession
private boolean isLastBackupSession(BackupSystemTable table, TableName tn, long startTime) throws IOException - Throws:
IOException
-
getHistory
Description copied from interface:BackupAdminShow backup history command- Specified by:
getHistoryin interfaceBackupAdmin- Parameters:
n- last n backup sessions- Returns:
- list of backup info objects
- Throws:
IOException- exception
-
getHistory
Description copied from interface:BackupAdminShow backup history command with filters- Specified by:
getHistoryin interfaceBackupAdmin- Parameters:
n- last n backup sessionsfilters- list of filters- Returns:
- list of backup info objects
- Throws:
IOException- exception
-
listBackupSets
Description copied from interface:BackupAdminBackup sets list command - list all backup sets. Backup set is a named group of tables.- Specified by:
listBackupSetsin interfaceBackupAdmin- Returns:
- all registered backup sets
- Throws:
IOException- exception
-
getBackupSet
Description copied from interface:BackupAdminBackup set describe command. Shows list of tables in this particular backup set.- Specified by:
getBackupSetin interfaceBackupAdmin- Parameters:
name- set name- Returns:
- backup set description or null
- Throws:
IOException- exception
-
deleteBackupSet
Description copied from interface:BackupAdminDelete backup set command- Specified by:
deleteBackupSetin interfaceBackupAdmin- Parameters:
name- backup set name- Returns:
- true, if success, false - otherwise
- Throws:
IOException- exception
-
addToBackupSet
Description copied from interface:BackupAdminAdd tables to backup set command- Specified by:
addToBackupSetin interfaceBackupAdmin- Parameters:
name- name of backup set.tables- array of tables to be added to this set.- Throws:
IOException- exception
-
removeFromBackupSet
Description copied from interface:BackupAdminRemove tables from backup set- Specified by:
removeFromBackupSetin interfaceBackupAdmin- Parameters:
name- name of backup set.tables- array of tables to be removed from this set.- Throws:
IOException- exception
-
toStringArray
-
restore
Description copied from interface:BackupAdminRestore backup- Specified by:
restorein interfaceBackupAdmin- Parameters:
request- restore request- Throws:
IOException- exception
-
backupTables
Description copied from interface:BackupAdminBackup given list of tables fully. This is a synchronous operation. It returns backup id on success or throw exception on failure.- Specified by:
backupTablesin interfaceBackupAdmin- Parameters:
request- BackupRequest instance- Returns:
- the backup Id
- Throws:
IOException
-
excludeNonExistingTables
-
mergeBackups
Description copied from interface:BackupAdminMerge backup images command- Specified by:
mergeBackupsin interfaceBackupAdmin- Parameters:
backupIds- array of backup ids of images to be merged The resulting backup image will have the same backup id as the most recent image from a list of images to be merged- Throws:
IOException- exception
-
checkIfValidForMerge
Verifies that backup images are valid for merge.- All backups MUST be in the same destination
- No FULL backups are allowed - only INCREMENTAL
- All backups must be in COMPLETE state
- No holes in backup list are allowed
- Parameters:
backupIds- list of backup idstable- backup system table- Throws:
IOException- if the backup image is not valid for merge
-