Class RestoreTool
java.lang.Object
org.apache.hadoop.hbase.backup.util.RestoreTool
A collection for methods used by multiple classes to restore HBase tables.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionRestoreTool
(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.Path backupRootPath, org.apache.hadoop.fs.Path restoreRootDir, String backupId) -
Method Summary
Modifier and TypeMethodDescriptionprivate void
checkAndCreateTable
(Connection conn, TableName targetTableName, ArrayList<org.apache.hadoop.fs.Path> regionDirList, TableDescriptor htd, boolean truncateIfExists) Prepare the table for bulkload, most codes copied fromcreateTable
method inBulkLoadHFilesTool
.private void
createAndRestoreTable
(Connection conn, TableName tableName, TableName newTableName, org.apache.hadoop.fs.Path tableBackupPath, boolean truncateIfExists, String lastIncrBackupId) void
fullRestoreTable
(Connection conn, org.apache.hadoop.fs.Path tableBackupPath, TableName tableName, TableName newTableName, boolean truncateIfExists, String lastIncrBackupId) (package private) byte[][]
generateBoundaryKeys
(ArrayList<org.apache.hadoop.fs.Path> regionDirList) Calculate region boundaries and add all the column families to the table descriptor(package private) ArrayList<org.apache.hadoop.fs.Path>
getRegionList
(org.apache.hadoop.fs.Path tableArchivePath) Gets region list(package private) ArrayList<org.apache.hadoop.fs.Path>
getRegionList
(TableName tableName) Gets region list(package private) org.apache.hadoop.fs.Path
getTableArchivePath
(TableName tableName) return value represent path for: ".../user/biadmin/backup1/default/t1_dn/backup_1396650096738/archive/data/default/t1_dn"(package private) TableDescriptor
getTableDesc
(TableName tableName) Get table descriptorprivate TableDescriptor
getTableDescriptor
(org.apache.hadoop.fs.FileSystem fileSys, TableName tableName, String lastIncrBackupId) (package private) org.apache.hadoop.fs.Path
getTableInfoPath
(TableName tableName) Returns value represent path for: ""/$USER/SBACKUP_ROOT/backup_id/namespace/table/.hbase-snapshot/ snapshot_1396650097621_namespace_table" this path contains .snapshotinfo, .tabledesc (0.96 and 0.98) this path contains .snapshotinfo, .data.manifest (trunk)(package private) org.apache.hadoop.fs.Path
getTableSnapshotPath
(org.apache.hadoop.fs.Path backupRootPath, TableName tableName, String backupId) Returns value represent path for path to backup table snapshot directory: "/$USER/SBACKUP_ROOT/backup_id/namespace/table/.hbase-snapshot"void
incrementalRestoreTable
(Connection conn, org.apache.hadoop.fs.Path tableBackupPath, org.apache.hadoop.fs.Path[] logDirs, TableName[] tableNames, TableName[] newTableNames, String incrBackupId) During incremental backup operation.(package private) void
modifyTableSync
(Connection conn, TableDescriptor desc)
-
Field Details
-
LOG
-
TABLE_AVAILABILITY_WAIT_TIME
- See Also:
-
ignoreDirs
-
conf
-
backupRootPath
-
restoreRootDir
-
backupId
-
fs
-
snapshotMap
-
-
Constructor Details
-
RestoreTool
public RestoreTool(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.Path backupRootPath, org.apache.hadoop.fs.Path restoreRootDir, String backupId) throws IOException - Throws:
IOException
-
-
Method Details
-
getTableArchivePath
return value represent path for: ".../user/biadmin/backup1/default/t1_dn/backup_1396650096738/archive/data/default/t1_dn"- Parameters:
tableName
- table name- Returns:
- path to table archive
- Throws:
IOException
- exception
-
getRegionList
Gets region list- Parameters:
tableName
- table name- Returns:
- RegionList region list
- Throws:
IOException
- exception
-
modifyTableSync
- Throws:
IOException
-
incrementalRestoreTable
public void incrementalRestoreTable(Connection conn, org.apache.hadoop.fs.Path tableBackupPath, org.apache.hadoop.fs.Path[] logDirs, TableName[] tableNames, TableName[] newTableNames, String incrBackupId) throws IOException During incremental backup operation. Call WalPlayer to replay WAL in backup image Currently tableNames and newTablesNames only contain single table, will be expanded to multiple tables in the future- Parameters:
conn
- HBase connectiontableBackupPath
- backup pathlogDirs
- : incremental backup folders, which contains WALtableNames
- : source tableNames(table names were backuped)newTableNames
- : target tableNames(table names to be restored to)incrBackupId
- incremental backup Id- Throws:
IOException
- exception
-
fullRestoreTable
public void fullRestoreTable(Connection conn, org.apache.hadoop.fs.Path tableBackupPath, TableName tableName, TableName newTableName, boolean truncateIfExists, String lastIncrBackupId) throws IOException - Throws:
IOException
-
getTableSnapshotPath
org.apache.hadoop.fs.Path getTableSnapshotPath(org.apache.hadoop.fs.Path backupRootPath, TableName tableName, String backupId) Returns value represent path for path to backup table snapshot directory: "/$USER/SBACKUP_ROOT/backup_id/namespace/table/.hbase-snapshot"- Parameters:
backupRootPath
- backup root pathtableName
- table namebackupId
- backup Id- Returns:
- path for snapshot
-
getTableInfoPath
Returns value represent path for: ""/$USER/SBACKUP_ROOT/backup_id/namespace/table/.hbase-snapshot/ snapshot_1396650097621_namespace_table" this path contains .snapshotinfo, .tabledesc (0.96 and 0.98) this path contains .snapshotinfo, .data.manifest (trunk)- Parameters:
tableName
- table name- Returns:
- path to table info
- Throws:
IOException
- exception
-
getTableDesc
Get table descriptor- Parameters:
tableName
- is the table backed up- Returns:
TableDescriptor
saved in backup image of the table- Throws:
IOException
-
getTableDescriptor
private TableDescriptor getTableDescriptor(org.apache.hadoop.fs.FileSystem fileSys, TableName tableName, String lastIncrBackupId) throws IOException - Throws:
IOException
-
createAndRestoreTable
private void createAndRestoreTable(Connection conn, TableName tableName, TableName newTableName, org.apache.hadoop.fs.Path tableBackupPath, boolean truncateIfExists, String lastIncrBackupId) throws IOException - Throws:
IOException
-
getRegionList
ArrayList<org.apache.hadoop.fs.Path> getRegionList(org.apache.hadoop.fs.Path tableArchivePath) throws IOException Gets region list- Parameters:
tableArchivePath
- table archive path- Returns:
- RegionList region list
- Throws:
IOException
- exception
-
generateBoundaryKeys
byte[][] generateBoundaryKeys(ArrayList<org.apache.hadoop.fs.Path> regionDirList) throws IOException Calculate region boundaries and add all the column families to the table descriptor- Parameters:
regionDirList
- region dir list- Returns:
- a set of keys to store the boundaries
- Throws:
IOException
-
checkAndCreateTable
private void checkAndCreateTable(Connection conn, TableName targetTableName, ArrayList<org.apache.hadoop.fs.Path> regionDirList, TableDescriptor htd, boolean truncateIfExists) throws IOException Prepare the table for bulkload, most codes copied fromcreateTable
method inBulkLoadHFilesTool
.- Parameters:
conn
- connectiontargetTableName
- target table nameregionDirList
- region directory listhtd
- table descriptortruncateIfExists
- truncates table if exists- Throws:
IOException
- exception
-