Search in sources :

Example 11 with TableStateManager

use of org.apache.hadoop.hbase.master.TableStateManager in project hbase by apache.

the class TestAddToSerialReplicationPeer method testDisablingTable.

@Test
public void testDisablingTable() throws Exception {
    TableName tableName = createTable();
    try (Table table = UTIL.getConnection().getTable(tableName)) {
        for (int i = 0; i < 100; i++) {
            table.put(new Put(Bytes.toBytes(i)).addColumn(CF, CQ, Bytes.toBytes(i)));
        }
    }
    UTIL.getAdmin().disableTable(tableName);
    rollAllWALs();
    TableStateManager tsm = UTIL.getMiniHBaseCluster().getMaster().getTableStateManager();
    tsm.setTableState(tableName, TableState.State.DISABLING);
    Thread t = new Thread(() -> {
        try {
            addPeer(true);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    });
    t.start();
    Thread.sleep(5000);
    // we will wait on the disabling table so the thread should still be alive.
    assertTrue(t.isAlive());
    tsm.setTableState(tableName, TableState.State.DISABLED);
    t.join();
    UTIL.getAdmin().enableTable(tableName);
    try (Table table = UTIL.getConnection().getTable(tableName)) {
        for (int i = 0; i < 100; i++) {
            table.put(new Put(Bytes.toBytes(i)).addColumn(CF, CQ, Bytes.toBytes(i)));
        }
    }
    waitUntilReplicationDone(100);
    checkOrder(100);
}
Also used : TableName(org.apache.hadoop.hbase.TableName) TableStateManager(org.apache.hadoop.hbase.master.TableStateManager) Table(org.apache.hadoop.hbase.client.Table) IOException(java.io.IOException) Put(org.apache.hadoop.hbase.client.Put) Test(org.junit.Test)

Aggregations

TableStateManager (org.apache.hadoop.hbase.master.TableStateManager)11 TableName (org.apache.hadoop.hbase.TableName)6 IOException (java.io.IOException)4 Put (org.apache.hadoop.hbase.client.Put)3 RegionInfo (org.apache.hadoop.hbase.client.RegionInfo)3 TableState (org.apache.hadoop.hbase.client.TableState)3 Test (org.junit.Test)3 List (java.util.List)2 ServerName (org.apache.hadoop.hbase.ServerName)2 TableNotDisabledException (org.apache.hadoop.hbase.TableNotDisabledException)2 TableNotEnabledException (org.apache.hadoop.hbase.TableNotEnabledException)2 TableNotFoundException (org.apache.hadoop.hbase.TableNotFoundException)2 Table (org.apache.hadoop.hbase.client.Table)2 Pair (org.apache.hadoop.hbase.util.Pair)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1