@InterfaceAudience.Private public class BackupAdminImpl extends Object implements BackupAdmin
Modifier and Type | Field and Description |
---|---|
static String |
CHECK_FAILED |
static String |
CHECK_OK |
private Connection |
conn |
private static org.slf4j.Logger |
LOG |
Constructor and Description |
---|
BackupAdminImpl(Connection conn) |
Modifier and Type | Method and Description |
---|---|
void |
addToBackupSet(String name,
TableName[] tables)
Add tables to backup set command
|
String |
backupTables(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 directory
|
void |
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 command
|
boolean |
deleteBackupSet(String name)
Delete backup set command
|
private List<TableName> |
excludeNonExistingTables(List<TableName> tableList,
List<TableName> nonExistingTableList) |
private void |
finalizeDelete(Map<String,HashSet<TableName>> tablesMap,
BackupSystemTable table)
Updates incremental backup set for every backupRoot
|
private List<BackupInfo> |
getAffectedBackupSessions(BackupInfo backupInfo,
TableName tn,
BackupSystemTable table) |
BackupInfo |
getBackupInfo(String backupId)
Describe backup image command
|
BackupSet |
getBackupSet(String name)
Backup set describe command.
|
List<BackupInfo> |
getHistory(int n)
Show backup history command
|
List<BackupInfo> |
getHistory(int n,
BackupInfo.Filter... filters)
Show backup history command with filters
|
private boolean |
isLastBackupSession(BackupSystemTable table,
TableName tn,
long startTime) |
List<BackupSet> |
listBackupSets()
Backup sets list command - list all backup sets.
|
void |
mergeBackups(String[] backupIds)
Merge backup images command
|
void |
removeFromBackupSet(String name,
TableName[] tables)
Remove tables from backup set
|
private void |
removeTableFromBackupImage(BackupInfo info,
TableName tn,
BackupSystemTable sysTable) |
void |
restore(RestoreRequest request)
Restore backup
|
private String[] |
toStringArray(TableName[] list) |
public static final String CHECK_OK
public static final String CHECK_FAILED
private static final org.slf4j.Logger LOG
private final Connection conn
public BackupAdminImpl(Connection conn)
public void close()
close
in interface Closeable
close
in interface AutoCloseable
public BackupInfo getBackupInfo(String backupId) throws IOException
BackupAdmin
getBackupInfo
in interface BackupAdmin
backupId
- backup idIOException
- exceptionpublic int deleteBackups(String[] backupIds) throws IOException
BackupAdmin
deleteBackups
in interface BackupAdmin
backupIds
- array of backup idsIOException
- exceptionprivate void finalizeDelete(Map<String,HashSet<TableName>> tablesMap, BackupSystemTable table) throws IOException
tablesMap
- map [backupRoot: Set<TableName>
]table
- backup system tableIOException
- if a table operation failsprivate int deleteBackup(String backupId, BackupSystemTable sysTable) throws IOException
backupId
- backup idsysTable
- backup system tableIOException
- if deleting the backup failsprivate void removeTableFromBackupImage(BackupInfo info, TableName tn, BackupSystemTable sysTable) throws IOException
IOException
private List<BackupInfo> getAffectedBackupSessions(BackupInfo backupInfo, TableName tn, BackupSystemTable table) throws IOException
IOException
private void cleanupBackupDir(BackupInfo backupInfo, TableName table, org.apache.hadoop.conf.Configuration conf) throws IOException
IOException
- if cleaning up the backup directory failsprivate boolean isLastBackupSession(BackupSystemTable table, TableName tn, long startTime) throws IOException
IOException
public List<BackupInfo> getHistory(int n) throws IOException
BackupAdmin
getHistory
in interface BackupAdmin
n
- last n backup sessionsIOException
- exceptionpublic List<BackupInfo> getHistory(int n, BackupInfo.Filter... filters) throws IOException
BackupAdmin
getHistory
in interface BackupAdmin
n
- last n backup sessionsfilters
- list of filtersIOException
- exceptionpublic List<BackupSet> listBackupSets() throws IOException
BackupAdmin
listBackupSets
in interface BackupAdmin
IOException
- exceptionpublic BackupSet getBackupSet(String name) throws IOException
BackupAdmin
getBackupSet
in interface BackupAdmin
name
- set nameIOException
- exceptionpublic boolean deleteBackupSet(String name) throws IOException
BackupAdmin
deleteBackupSet
in interface BackupAdmin
name
- backup set nameIOException
- exceptionpublic void addToBackupSet(String name, TableName[] tables) throws IOException
BackupAdmin
addToBackupSet
in interface BackupAdmin
name
- name of backup set.tables
- array of tables to be added to this set.IOException
- exceptionpublic void removeFromBackupSet(String name, TableName[] tables) throws IOException
BackupAdmin
removeFromBackupSet
in interface BackupAdmin
name
- name of backup set.tables
- array of tables to be removed from this set.IOException
- exceptionprivate String[] toStringArray(TableName[] list)
public void restore(RestoreRequest request) throws IOException
BackupAdmin
restore
in interface BackupAdmin
request
- restore requestIOException
- exceptionpublic String backupTables(BackupRequest request) throws IOException
BackupAdmin
backupTables
in interface BackupAdmin
request
- BackupRequest instanceIOException
private List<TableName> excludeNonExistingTables(List<TableName> tableList, List<TableName> nonExistingTableList)
public void mergeBackups(String[] backupIds) throws IOException
BackupAdmin
mergeBackups
in interface BackupAdmin
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
mergedIOException
- exceptionprivate void checkIfValidForMerge(String[] backupIds, BackupSystemTable table) throws IOException
backupIds
- list of backup idstable
- backup system tableIOException
- if the backup image is not valid for mergeCopyright © 2007–2020 The Apache Software Foundation. All rights reserved.