Class BackupAdminImpl
java.lang.Object
org.apache.hadoop.hbase.backup.impl.BackupAdminImpl
- All Implemented Interfaces:
Closeable
,AutoCloseable
,BackupAdmin
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
static final String
private final Connection
private static final org.slf4j.Logger
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addToBackupSet
(String name, TableName[] tables) Add tables to backup set commandbackupTables
(BackupRequest request) Backup given list of tables fully.private void
checkIfValidForMerge
(String[] backupIds, BackupSystemTable table) Verifies that backup images are valid for merge.private void
cleanupBackupDir
(BackupInfo backupInfo, TableName table, org.apache.hadoop.conf.Configuration conf) Clean up the data at target directoryvoid
close()
private int
deleteBackup
(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.int
deleteBackups
(String[] backupIds) Delete backup image commandboolean
deleteBackupSet
(String name) Delete backup set commandexcludeNonExistingTables
(List<TableName> tableList, List<TableName> nonExistingTableList) private void
finalizeDelete
(Map<String, HashSet<TableName>> tablesMap, 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 boolean
isLastBackupSession
(BackupSystemTable table, TableName tn, long startTime) Backup sets list command - list all backup sets.void
mergeBackups
(String[] backupIds) Merge backup images commandvoid
removeFromBackupSet
(String name, TableName[] tables) Remove tables from backup setprivate void
removeTableFromBackupImage
(BackupInfo info, TableName tn, BackupSystemTable sysTable) void
restore
(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:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
getBackupInfo
Description copied from interface:BackupAdmin
Describe backup image command- Specified by:
getBackupInfo
in interfaceBackupAdmin
- Parameters:
backupId
- backup id- Returns:
- backup info
- Throws:
IOException
- exception
-
deleteBackups
Description copied from interface:BackupAdmin
Delete backup image command- Specified by:
deleteBackups
in interfaceBackupAdmin
- Parameters:
backupIds
- array of backup ids- Returns:
- total number of deleted sessions
- Throws:
IOException
- exception
-
finalizeDelete
private void finalizeDelete(Map<String, HashSet<TableName>> tablesMap, BackupSystemTable table) throws IOExceptionUpdates incremental backup set for every backupRoot- Parameters:
tablesMap
- map [backupRoot:Set<TableName>
]table
- 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:BackupAdmin
Show backup history command- Specified by:
getHistory
in interfaceBackupAdmin
- Parameters:
n
- last n backup sessions- Returns:
- list of backup info objects
- Throws:
IOException
- exception
-
getHistory
Description copied from interface:BackupAdmin
Show backup history command with filters- Specified by:
getHistory
in interfaceBackupAdmin
- Parameters:
n
- last n backup sessionsfilters
- list of filters- Returns:
- list of backup info objects
- Throws:
IOException
- exception
-
listBackupSets
Description copied from interface:BackupAdmin
Backup sets list command - list all backup sets. Backup set is a named group of tables.- Specified by:
listBackupSets
in interfaceBackupAdmin
- Returns:
- all registered backup sets
- Throws:
IOException
- exception
-
getBackupSet
Description copied from interface:BackupAdmin
Backup set describe command. Shows list of tables in this particular backup set.- Specified by:
getBackupSet
in interfaceBackupAdmin
- Parameters:
name
- set name- Returns:
- backup set description or null
- Throws:
IOException
- exception
-
deleteBackupSet
Description copied from interface:BackupAdmin
Delete backup set command- Specified by:
deleteBackupSet
in interfaceBackupAdmin
- Parameters:
name
- backup set name- Returns:
- true, if success, false - otherwise
- Throws:
IOException
- exception
-
addToBackupSet
Description copied from interface:BackupAdmin
Add tables to backup set command- Specified by:
addToBackupSet
in 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:BackupAdmin
Remove tables from backup set- Specified by:
removeFromBackupSet
in 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:BackupAdmin
Restore backup- Specified by:
restore
in interfaceBackupAdmin
- Parameters:
request
- restore request- Throws:
IOException
- exception
-
backupTables
Description copied from interface:BackupAdmin
Backup given list of tables fully. This is a synchronous operation. It returns backup id on success or throw exception on failure.- Specified by:
backupTables
in interfaceBackupAdmin
- Parameters:
request
- BackupRequest instance- Returns:
- the backup Id
- Throws:
IOException
-
excludeNonExistingTables
-
mergeBackups
Description copied from interface:BackupAdmin
Merge backup images command- Specified by:
mergeBackups
in 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
-