Class BackupManager
java.lang.Object
org.apache.hadoop.hbase.backup.impl.BackupManager
- All Implemented Interfaces:
Closeable
,AutoCloseable
- Direct Known Subclasses:
IncrementalBackupManager
Handles backup requests, creates backup info records in backup system table to keep track of
backup sessions, dispatches backup request.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
protected BackupInfo
protected org.apache.hadoop.conf.Configuration
protected final Connection
private static final int
private static final org.slf4j.Logger
protected BackupSystemTable
-
Constructor Summary
ConstructorDescriptionBackupManager
(Connection conn, org.apache.hadoop.conf.Configuration conf) Backup manager constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addIncrementalBackupTableSet
(Set<TableName> tables) Adds set of tables to overall incremental backup table setvoid
close()
Stop all the work of backup.createBackupInfo
(String backupId, BackupType type, List<TableName> tableList, String targetRootDir, int workers, long bandwidth, boolean noChecksumVerify) Creates a backup info based on input backup request.static void
decorateMasterConfiguration
(org.apache.hadoop.conf.Configuration conf) This method modifies the master's configuration in order to inject backup-related features (TESTs only)static void
decorateRegionServerConfiguration
(org.apache.hadoop.conf.Configuration conf) This method modifies the Region Server configuration in order to inject backup-related features TESTs only.void
deleteBulkLoadedRows
(List<byte[]> rows) void
Finishes active backup sessionGet all completed backup information (in desc order by time)getBackupHistory
(boolean completed) protected BackupInfo
Returns backup info(package private) org.apache.hadoop.conf.Configuration
getConf()
Get configurationReturn the current tables covered by incremental backup.private String
Check if any ongoing backup.void
Start the backup manager service.static boolean
isBackupEnabled
(org.apache.hadoop.conf.Configuration conf) Read the last backup start code (timestamp) of last successful backup.readBulkloadRows
(List<TableName> tableList) Read the timestamp for each region server log after the last successful backup.Get the RS log information after the last log roll from backup system table.void
setBackupInfo
(BackupInfo backupInfo) void
Starts new backup sessionvoid
updateBackupInfo
(BackupInfo context) Updates status (state) of a backup session in a persistent storevoid
writeBackupStartCode
(Long startCode) Write the start code (timestamp) to backup system table.void
Write the current timestamps for each regionserver to backup system table after a successful full or incremental backup.
-
Field Details
-
BACKUP_EXCLUSIVE_OPERATION_TIMEOUT_SECONDS_KEY
- See Also:
-
DEFAULT_BACKUP_EXCLUSIVE_OPERATION_TIMEOUT
- See Also:
-
LOG
-
conf
-
backupInfo
-
systemTable
-
conn
-
-
Constructor Details
-
BackupManager
Backup manager constructor.- Parameters:
conn
- connectionconf
- configuration- Throws:
IOException
- exception
-
-
Method Details
-
getBackupInfo
Returns backup info -
decorateMasterConfiguration
This method modifies the master's configuration in order to inject backup-related features (TESTs only)- Parameters:
conf
- configuration
-
decorateRegionServerConfiguration
This method modifies the Region Server configuration in order to inject backup-related features TESTs only.- Parameters:
conf
- configuration
-
isBackupEnabled
-
getConf
org.apache.hadoop.conf.Configuration getConf()Get configuration -
close
Stop all the work of backup.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
createBackupInfo
public BackupInfo createBackupInfo(String backupId, BackupType type, List<TableName> tableList, String targetRootDir, int workers, long bandwidth, boolean noChecksumVerify) throws BackupException Creates a backup info based on input backup request.- Parameters:
backupId
- backup idtype
- typetableList
- table listtargetRootDir
- root dirworkers
- number of parallel workersbandwidth
- bandwidth per worker in MB per sec- Throws:
BackupException
- exception
-
getOngoingBackupId
Check if any ongoing backup. Currently, we only reply on checking status in backup system table. We need to consider to handle the case of orphan records in the future. Otherwise, all the coming request will fail.- Returns:
- the ongoing backup id if on going backup exists, otherwise null
- Throws:
IOException
- exception
-
initialize
Start the backup manager service.- Throws:
IOException
- exception
-
setBackupInfo
-
updateBackupInfo
Updates status (state) of a backup session in a persistent store- Parameters:
context
- context- Throws:
IOException
- exception
-
startBackupSession
Starts new backup session- Throws:
IOException
- if active session already exists
-
finishBackupSession
Finishes active backup session- Throws:
IOException
- if no active session
-
readBackupStartCode
Read the last backup start code (timestamp) of last successful backup. Will return null if there is no startcode stored in backup system table or the value is of length 0. These two cases indicate there is no successful backup completed so far.- Returns:
- the timestamp of a last successful backup
- Throws:
IOException
- exception
-
writeBackupStartCode
Write the start code (timestamp) to backup system table. If passed in null, then write 0 byte.- Parameters:
startCode
- start code- Throws:
IOException
- exception
-
readRegionServerLastLogRollResult
Get the RS log information after the last log roll from backup system table.- Returns:
- RS log info
- Throws:
IOException
- exception
-
readBulkloadRows
public Pair<Map<TableName,Map<String, readBulkloadRowsMap<String, List<Pair<String, Boolean>>>>>, List<byte[]>> (List<TableName> tableList) throws IOException - Throws:
IOException
-
deleteBulkLoadedRows
- Throws:
IOException
-
getBackupHistory
Get all completed backup information (in desc order by time)- Returns:
- history info of BackupCompleteData
- Throws:
IOException
- exception
-
getBackupHistory
- Throws:
IOException
-
writeRegionServerLogTimestamp
public void writeRegionServerLogTimestamp(Set<TableName> tables, Map<String, Long> newTimestamps) throws IOExceptionWrite the current timestamps for each regionserver to backup system table after a successful full or incremental backup. Each table may have a different set of log timestamps. The saved timestamp is of the last log file that was backed up already.- Parameters:
tables
- tables- Throws:
IOException
- exception
-
readLogTimestampMap
Read the timestamp for each region server log after the last successful backup. Each table has its own set of the timestamps.- Returns:
- the timestamp for each region server. key: tableName value: RegionServer,PreviousTimeStamp
- Throws:
IOException
- exception
-
getIncrementalBackupTableSet
Return the current tables covered by incremental backup.- Returns:
- set of tableNames
- Throws:
IOException
- exception
-
addIncrementalBackupTableSet
Adds set of tables to overall incremental backup table set- Parameters:
tables
- tables- Throws:
IOException
- exception
-
getConnection
-