private void restore(RestoreRequest request, BackupAdmin client) throws IOException { client.restore(request); }
/** * Verify that restore fails on a single table that does not exist. * * @throws Exception if doing the backup or restoring it fails */ @Test(expected = IOException.class) public void testFullRestoreSingleDNE() throws Exception { LOG.info("test restore fails on a single table that does not exist"); List<TableName> tables = Lists.newArrayList(table1); String backupId = fullTableBackup(tables); assertTrue(checkSucceeded(backupId)); LOG.info("backup complete"); TableName[] tableset = new TableName[] { TableName.valueOf("faketable") }; TableName[] tablemap = new TableName[] { table1_restore }; BackupAdmin client = getBackupAdmin(); client.restore(BackupUtils.createRestoreRequest(BACKUP_ROOT_DIR, backupId, false, tableset, tablemap, false)); }
/** * Verify that restore fails on multiple tables that do not exist. * * @throws Exception if doing the backup or restoring it fails */ @Test(expected = IOException.class) public void testFullRestoreMultipleDNE() throws Exception { LOG.info("test restore fails on multiple tables that do not exist"); List<TableName> tables = Lists.newArrayList(table2, table3); String backupId = fullTableBackup(tables); assertTrue(checkSucceeded(backupId)); TableName[] restore_tableset = new TableName[] { TableName.valueOf("faketable1"), TableName.valueOf("faketable2") }; TableName[] tablemap = new TableName[] { table2_restore, table3_restore }; BackupAdmin client = getBackupAdmin(); client.restore(BackupUtils.createRestoreRequest(BACKUP_ROOT_DIR, backupId, false, restore_tableset, tablemap, false)); }
client.restore(BackupUtils.createRestoreRequest(backupRootDir, backupId, check, sTableArray, tTableArray, overwrite)); } catch (Exception e) {
/** * Verify that a single table is restored using overwrite. * * @throws Exception if doing the backup or restoring it fails */ @Test public void testFullRestoreSingleOverwrite() throws Exception { LOG.info("test full restore on a single table empty table"); List<TableName> tables = Lists.newArrayList(table1); String backupId = fullTableBackup(tables); assertTrue(checkSucceeded(backupId)); LOG.info("backup complete"); TableName[] tableset = new TableName[] { table1 }; BackupAdmin client = getBackupAdmin(); client.restore(BackupUtils.createRestoreRequest(BACKUP_ROOT_DIR, backupId, false, tableset, null, true)); }
/** * Verify that multiple tables are restored to new tables using overwrite. * * @throws Exception if doing the backup or restoring it fails */ @Test public void testFullRestoreMultipleOverwrite() throws Exception { LOG.info("create full backup image on multiple tables"); List<TableName> tables = Lists.newArrayList(table2, table3); String backupId = fullTableBackup(tables); assertTrue(checkSucceeded(backupId)); TableName[] restore_tableset = new TableName[] { table2, table3 }; BackupAdmin client = getBackupAdmin(); client.restore(BackupUtils.createRestoreRequest(BACKUP_ROOT_DIR, backupId, false, restore_tableset, null, true)); }
/** * Verify that a single empty table is restored to a new table. * * @throws Exception if doing the backup or an operation on the tables fails */ @Test public void testFullRestoreSingleEmpty() throws Exception { LOG.info("test full restore on a single table empty table"); String backupId = fullTableBackup(toList(table1.getNameAsString())); LOG.info("backup complete"); TableName[] tableset = new TableName[] { table1 }; TableName[] tablemap = new TableName[] { table1_restore }; getBackupAdmin().restore( BackupUtils.createRestoreRequest(BACKUP_ROOT_DIR, backupId, false, tableset, tablemap, false)); HBaseAdmin hba = TEST_UTIL.getHBaseAdmin(); assertTrue(hba.tableExists(table1_restore)); TEST_UTIL.deleteTable(table1_restore); }
client.restore(BackupUtils.createRestoreRequest(BACKUP_REMOTE_ROOT_DIR, backupId, false, tablesRestoreFull, tablesMapFull, false));
/** * Verify that a remote restore on a single table is successful. * * @throws Exception if doing the backup or an operation on the tables fails */ @Test public void testFullRestoreRemote() throws Exception { LOG.info("test remote full backup on a single table"); String backupId = backupTables(BackupType.FULL, toList(table1.getNameAsString()), BACKUP_REMOTE_ROOT_DIR); LOG.info("backup complete"); TableName[] tableset = new TableName[] { table1 }; TableName[] tablemap = new TableName[] { table1_restore }; getBackupAdmin().restore( BackupUtils.createRestoreRequest(BACKUP_REMOTE_ROOT_DIR, backupId, false, tableset, tablemap, false)); HBaseAdmin hba = TEST_UTIL.getHBaseAdmin(); assertTrue(hba.tableExists(table1_restore)); TEST_UTIL.deleteTable(table1_restore); hba.close(); } }
/** * Verify that a single table is restored to a new table. * * @throws Exception if doing the backup, restoring it or an operation on the tables fails */ @Test public void testFullRestoreSingle() throws Exception { LOG.info("test full restore on a single table empty table"); List<TableName> tables = Lists.newArrayList(table1); String backupId = fullTableBackup(tables); assertTrue(checkSucceeded(backupId)); LOG.info("backup complete"); TableName[] tableset = new TableName[] { table1 }; TableName[] tablemap = new TableName[] { table1_restore }; BackupAdmin client = getBackupAdmin(); client.restore(BackupUtils.createRestoreRequest(BACKUP_ROOT_DIR, backupId, false, tableset, tablemap, false)); HBaseAdmin hba = TEST_UTIL.getHBaseAdmin(); assertTrue(hba.tableExists(table1_restore)); TEST_UTIL.deleteTable(table1_restore); hba.close(); }
client.restore(BackupUtils.createRestoreRequest(BACKUP_ROOT_DIR, backupId, false, tableset, tablemap, true));
/** * Verify that multiple tables are restored to new tables. * * @throws Exception if doing the backup or an operation on the tables fails */ @Test public void testFullRestoreMultipleEmpty() throws Exception { LOG.info("create full backup image on multiple tables"); List<TableName> tables = toList(table2.getNameAsString(), table3.getNameAsString()); String backupId = fullTableBackup(tables); TableName[] restore_tableset = new TableName[] { table2, table3 }; TableName[] tablemap = new TableName[] { table2_restore, table3_restore }; getBackupAdmin().restore( BackupUtils.createRestoreRequest(BACKUP_ROOT_DIR, backupId, false, restore_tableset, tablemap, false)); HBaseAdmin hba = TEST_UTIL.getHBaseAdmin(); assertTrue(hba.tableExists(table2_restore)); assertTrue(hba.tableExists(table3_restore)); TEST_UTIL.deleteTable(table2_restore); TEST_UTIL.deleteTable(table3_restore); hba.close(); } }
/** * Verify that multiple tables are restored to new tables. * * @throws Exception if doing the backup, restoring it or an operation on the tables fails */ @Test public void testFullRestoreMultiple() throws Exception { LOG.info("create full backup image on multiple tables"); List<TableName> tables = Lists.newArrayList(table2, table3); String backupId = fullTableBackup(tables); assertTrue(checkSucceeded(backupId)); TableName[] restore_tableset = new TableName[] { table2, table3 }; TableName[] tablemap = new TableName[] { table2_restore, table3_restore }; BackupAdmin client = getBackupAdmin(); client.restore(BackupUtils.createRestoreRequest(BACKUP_ROOT_DIR, backupId, false, restore_tableset, tablemap, false)); HBaseAdmin hba = TEST_UTIL.getHBaseAdmin(); assertTrue(hba.tableExists(table2_restore)); assertTrue(hba.tableExists(table3_restore)); TEST_UTIL.deleteTable(table2_restore); TEST_UTIL.deleteTable(table3_restore); hba.close(); }