Search in sources :

Example 11 with HBaseFsck

use of org.apache.hadoop.hbase.util.HBaseFsck in project hbase by apache.

the class TestMetaWithReplicas method testHBaseFsckWithExcessMetaReplicas.

@Test
public void testHBaseFsckWithExcessMetaReplicas() throws Exception {
    // Create a meta replica (this will be the 4th one) and assign it
    HRegionInfo h = RegionReplicaUtil.getRegionInfoForReplica(HRegionInfo.FIRST_META_REGIONINFO, 3);
    // create in-memory state otherwise master won't assign
    TEST_UTIL.getMiniHBaseCluster().getMaster().getAssignmentManager().getRegionStates().createRegionState(h);
    TEST_UTIL.assignRegion(h);
    HBaseFsckRepair.waitUntilAssigned(TEST_UTIL.getAdmin(), h);
    // check that problem exists
    HBaseFsck hbck = doFsck(TEST_UTIL.getConfiguration(), false);
    assertErrors(hbck, new ERROR_CODE[] { ERROR_CODE.UNKNOWN, ERROR_CODE.SHOULD_NOT_BE_DEPLOYED });
    // fix the problem
    hbck = doFsck(TEST_UTIL.getConfiguration(), true);
    // run hbck again to make sure we don't see any errors
    hbck = doFsck(TEST_UTIL.getConfiguration(), false);
    assertErrors(hbck, new ERROR_CODE[] {});
}
Also used : HRegionInfo(org.apache.hadoop.hbase.HRegionInfo) HBaseFsck(org.apache.hadoop.hbase.util.HBaseFsck) Test(org.junit.Test)

Example 12 with HBaseFsck

use of org.apache.hadoop.hbase.util.HBaseFsck in project hbase by apache.

the class TestMetaWithReplicas method testHBaseFsckWithFewerMetaReplicas.

@Test
public void testHBaseFsckWithFewerMetaReplicas() throws Exception {
    ClusterConnection c = (ClusterConnection) ConnectionFactory.createConnection(TEST_UTIL.getConfiguration());
    RegionLocations rl = c.locateRegion(TableName.META_TABLE_NAME, HConstants.EMPTY_START_ROW, false, false);
    HBaseFsckRepair.closeRegionSilentlyAndWait(c, rl.getRegionLocation(1).getServerName(), rl.getRegionLocation(1).getRegionInfo());
    // check that problem exists
    HBaseFsck hbck = doFsck(TEST_UTIL.getConfiguration(), false);
    assertErrors(hbck, new ERROR_CODE[] { ERROR_CODE.UNKNOWN, ERROR_CODE.NO_META_REGION });
    // fix the problem
    hbck = doFsck(TEST_UTIL.getConfiguration(), true);
    // run hbck again to make sure we don't see any errors
    hbck = doFsck(TEST_UTIL.getConfiguration(), false);
    assertErrors(hbck, new ERROR_CODE[] {});
}
Also used : RegionLocations(org.apache.hadoop.hbase.RegionLocations) HBaseFsck(org.apache.hadoop.hbase.util.HBaseFsck) Test(org.junit.Test)

Aggregations

HBaseFsck (org.apache.hadoop.hbase.util.HBaseFsck)12 Test (org.junit.Test)7 HTableDescriptor (org.apache.hadoop.hbase.HTableDescriptor)3 RegionLocations (org.apache.hadoop.hbase.RegionLocations)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Configuration (org.apache.hadoop.conf.Configuration)1 Path (org.apache.hadoop.fs.Path)1 HBaseConfiguration (org.apache.hadoop.hbase.HBaseConfiguration)1 HRegionInfo (org.apache.hadoop.hbase.HRegionInfo)1 ServerName (org.apache.hadoop.hbase.ServerName)1 TableName (org.apache.hadoop.hbase.TableName)1 Admin (org.apache.hadoop.hbase.client.Admin)1 Connection (org.apache.hadoop.hbase.client.Connection)1 HbckInfo (org.apache.hadoop.hbase.util.HBaseFsck.HbckInfo)1 ZooKeeperWatcher (org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher)1 MultipleIOException (org.apache.hadoop.io.MultipleIOException)1