Class RestoreTool

java.lang.Object
org.apache.hadoop.hbase.backup.util.RestoreTool

@Private public class RestoreTool extends Object
A collection for methods used by multiple classes to restore HBase tables.
  • Field Details

  • 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

      org.apache.hadoop.fs.Path getTableArchivePath(TableName tableName) throws IOException
      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

      ArrayList<org.apache.hadoop.fs.Path> getRegionList(TableName tableName) throws IOException
      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 connection
      tableBackupPath - backup path
      logDirs - : incremental backup folders, which contains WAL
      tableNames - : 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 path
      tableName - table name
      backupId - backup Id
      Returns:
      path for snapshot
    • getTableInfoPath

      org.apache.hadoop.fs.Path getTableInfoPath(TableName tableName) throws IOException
      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 from createTable method in BulkLoadHFilesTool.
      Parameters:
      conn - connection
      targetTableName - target table name
      regionDirList - region directory list
      htd - table descriptor
      truncateIfExists - truncates table if exists
      Throws:
      IOException - exception