Search in sources :

Example 76 with TableName

use of org.apache.hadoop.hbase.TableName in project hbase by apache.

the class TestRemoteRestore method testFullRestoreRemote.

/**
   * Verify that a remote restore on a single table is successful.
   * @throws Exception
   */
@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();
}
Also used : TableName(org.apache.hadoop.hbase.TableName) HBaseAdmin(org.apache.hadoop.hbase.client.HBaseAdmin) Test(org.junit.Test)

Example 77 with TableName

use of org.apache.hadoop.hbase.TableName in project hbase by apache.

the class TestRestoreBoundaryTests method testFullRestoreMultipleEmpty.

/**
   * Verify that multiple tables are restored to new tables.
   * @throws Exception
   */
@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();
}
Also used : TableName(org.apache.hadoop.hbase.TableName) HBaseAdmin(org.apache.hadoop.hbase.client.HBaseAdmin) Test(org.junit.Test)

Example 78 with TableName

use of org.apache.hadoop.hbase.TableName in project hbase by apache.

the class TestBackupSystemTable method testBackupSetRemove.

@Test
public void testBackupSetRemove() throws IOException {
    try (BackupSystemTable table = new BackupSystemTable(conn)) {
        String[] tables = new String[] { "table1", "table2", "table3", "table4" };
        String setName = "name";
        table.addToBackupSet(setName, tables);
        String[] removeTables = new String[] { "table4", "table3" };
        table.removeFromBackupSet(setName, removeTables);
        List<TableName> tnames = table.describeBackupSet(setName);
        assertTrue(tnames != null);
        assertTrue(tnames.size() == tables.length - 2);
        for (int i = 0; i < tnames.size(); i++) {
            assertTrue(tnames.get(i).getNameAsString().equals("table" + (i + 1)));
        }
        cleanBackupTable();
    }
}
Also used : BackupSystemTable(org.apache.hadoop.hbase.backup.impl.BackupSystemTable) TableName(org.apache.hadoop.hbase.TableName) Test(org.junit.Test)

Example 79 with TableName

use of org.apache.hadoop.hbase.TableName in project hbase by apache.

the class TestFullRestore method testFullRestoreMultiple.

/**
   * Verify that multiple tables are restored to new tables.
   * @throws Exception
   */
@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();
}
Also used : TableName(org.apache.hadoop.hbase.TableName) HBaseAdmin(org.apache.hadoop.hbase.client.HBaseAdmin) Test(org.junit.Test)

Example 80 with TableName

use of org.apache.hadoop.hbase.TableName in project hbase by apache.

the class TestFullRestore method testFullRestoreSingle.

/**
   * Verify that a single table is restored to a new table
   * @throws Exception
   */
@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();
}
Also used : TableName(org.apache.hadoop.hbase.TableName) HBaseAdmin(org.apache.hadoop.hbase.client.HBaseAdmin) Test(org.junit.Test)

Aggregations

TableName (org.apache.hadoop.hbase.TableName)1029 Test (org.junit.Test)694 HTableDescriptor (org.apache.hadoop.hbase.HTableDescriptor)257 Table (org.apache.hadoop.hbase.client.Table)227 IOException (java.io.IOException)225 HRegionInfo (org.apache.hadoop.hbase.HRegionInfo)215 HColumnDescriptor (org.apache.hadoop.hbase.HColumnDescriptor)203 Result (org.apache.hadoop.hbase.client.Result)124 ArrayList (java.util.ArrayList)118 Put (org.apache.hadoop.hbase.client.Put)118 Path (org.apache.hadoop.fs.Path)113 Connection (org.apache.hadoop.hbase.client.Connection)103 Scan (org.apache.hadoop.hbase.client.Scan)97 ResultScanner (org.apache.hadoop.hbase.client.ResultScanner)88 ServerName (org.apache.hadoop.hbase.ServerName)85 Admin (org.apache.hadoop.hbase.client.Admin)85 Cell (org.apache.hadoop.hbase.Cell)77 HashMap (java.util.HashMap)75 Delete (org.apache.hadoop.hbase.client.Delete)65 InterruptedIOException (java.io.InterruptedIOException)63