Search in sources :

Example 6 with HBaseFsck

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

the class TestMetaWithReplicas method stopMasterAndValidateReplicaCount.

private void stopMasterAndValidateReplicaCount(final int originalReplicaCount, final int newReplicaCount) throws Exception {
    ServerName sn = TEST_UTIL.getHBaseClusterInterface().getClusterStatus().getMaster();
    TEST_UTIL.getHBaseClusterInterface().stopMaster(sn);
    TEST_UTIL.getHBaseClusterInterface().waitForMasterToStop(sn, 60000);
    List<String> metaZnodes = TEST_UTIL.getZooKeeperWatcher().getMetaReplicaNodes();
    //we should have what was configured before
    assert (metaZnodes.size() == originalReplicaCount);
    TEST_UTIL.getHBaseClusterInterface().getConf().setInt(HConstants.META_REPLICAS_NUM, newReplicaCount);
    TEST_UTIL.getHBaseClusterInterface().startMaster(sn.getHostname(), 0);
    TEST_UTIL.getHBaseClusterInterface().waitForActiveAndReadyMaster();
    TEST_UTIL.waitFor(10000, predicateMetaHasReplicas(newReplicaCount));
    // also check if hbck returns without errors
    TEST_UTIL.getConfiguration().setInt(HConstants.META_REPLICAS_NUM, newReplicaCount);
    HBaseFsck hbck = HbckTestingUtil.doFsck(TEST_UTIL.getConfiguration(), false);
    HbckTestingUtil.assertNoErrors(hbck);
}
Also used : ServerName(org.apache.hadoop.hbase.ServerName) HBaseFsck(org.apache.hadoop.hbase.util.HBaseFsck)

Example 7 with HBaseFsck

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

the class HbckTestingUtil method doHFileQuarantine.

/**
   * Runs hbck with the -sidelineCorruptHFiles option
   * @param conf
   * @param table table constraint
   * @return <returncode, hbckInstance>
   * @throws Exception
   */
public static HBaseFsck doHFileQuarantine(Configuration conf, TableName table) throws Exception {
    String[] args = { "-sidelineCorruptHFiles", "-ignorePreCheckPermission", table.getNameAsString() };
    HBaseFsck hbck = new HBaseFsck(conf, exec);
    hbck.exec(exec, args);
    return hbck;
}
Also used : HBaseFsck(org.apache.hadoop.hbase.util.HBaseFsck)

Example 8 with HBaseFsck

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

the class TestOfflineMetaRebuildHole method testMetaRebuildHoleFail.

@Test(timeout = 120000)
public void testMetaRebuildHoleFail() throws Exception {
    // Fully remove a meta entry and hdfs region
    byte[] startKey = splits[1];
    byte[] endKey = splits[2];
    deleteRegion(conf, htbl, startKey, endKey);
    wipeOutMeta();
    // is meta really messed up?
    assertEquals(1, scanMeta());
    assertErrors(doFsck(conf, false), new ERROR_CODE[] { ERROR_CODE.NOT_IN_META_OR_DEPLOYED, ERROR_CODE.NOT_IN_META_OR_DEPLOYED, ERROR_CODE.NOT_IN_META_OR_DEPLOYED });
    // Note, would like to check # of tables, but this takes a while to time
    // out.
    // shutdown the minicluster
    TEST_UTIL.shutdownMiniHBaseCluster();
    TEST_UTIL.shutdownMiniZKCluster();
    // attempt to rebuild meta table from scratch
    HBaseFsck fsck = new HBaseFsck(conf);
    assertFalse(fsck.rebuildMeta(false));
    fsck.close();
    // bring up the minicluster
    // tables seem enabled by default
    TEST_UTIL.startMiniZKCluster();
    TEST_UTIL.restartHBaseCluster(3);
    LOG.info("Waiting for no more RIT");
    TEST_UTIL.waitUntilNoRegionsInTransition(60000);
    // Meta still messed up.
    assertEquals(1, scanMeta());
    HTableDescriptor[] htbls = getTables(TEST_UTIL.getConfiguration());
    LOG.info("Tables present after restart: " + Arrays.toString(htbls));
    // After HBASE-451 HBaseAdmin.listTables() gets table descriptors from FS,
    // so the table is still present and this should be 1.
    assertEquals(1, htbls.length);
    assertErrors(doFsck(conf, false), new ERROR_CODE[] { ERROR_CODE.NOT_IN_META_OR_DEPLOYED, ERROR_CODE.NOT_IN_META_OR_DEPLOYED, ERROR_CODE.NOT_IN_META_OR_DEPLOYED });
}
Also used : HBaseFsck(org.apache.hadoop.hbase.util.HBaseFsck) HTableDescriptor(org.apache.hadoop.hbase.HTableDescriptor) Test(org.junit.Test)

Example 9 with HBaseFsck

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

the class TestOfflineMetaRebuildOverlap method testMetaRebuildOverlapFail.

@Test(timeout = 120000)
public void testMetaRebuildOverlapFail() throws Exception {
    // Add a new .regioninfo meta entry in hdfs
    byte[] startKey = splits[0];
    byte[] endKey = splits[2];
    createRegion(conf, htbl, startKey, endKey);
    wipeOutMeta();
    // is meta really messed up?
    assertEquals(1, scanMeta());
    assertErrors(doFsck(conf, false), new ERROR_CODE[] { ERROR_CODE.NOT_IN_META_OR_DEPLOYED, ERROR_CODE.NOT_IN_META_OR_DEPLOYED, ERROR_CODE.NOT_IN_META_OR_DEPLOYED, ERROR_CODE.NOT_IN_META_OR_DEPLOYED });
    // Note, would like to check # of tables, but this takes a while to time
    // out.
    // shutdown the minicluster
    TEST_UTIL.shutdownMiniHBaseCluster();
    TEST_UTIL.shutdownMiniZKCluster();
    // attempt to rebuild meta table from scratch
    HBaseFsck fsck = new HBaseFsck(conf);
    assertFalse(fsck.rebuildMeta(false));
    Multimap<byte[], HbckInfo> problems = fsck.getOverlapGroups(table);
    assertEquals(1, problems.keySet().size());
    assertEquals(3, problems.size());
    // bring up the minicluster
    // tables seem enabled by default
    TEST_UTIL.startMiniZKCluster();
    TEST_UTIL.restartHBaseCluster(3);
    LOG.info("Waiting for no more RIT");
    TEST_UTIL.waitUntilNoRegionsInTransition(60000);
    LOG.info("No more RIT in ZK, now doing final test verification");
    // Meta still messed up.
    assertEquals(1, scanMeta());
    HTableDescriptor[] htbls = getTables(TEST_UTIL.getConfiguration());
    LOG.info("Tables present after restart: " + Arrays.toString(htbls));
    // After HBASE-451 HBaseAdmin.listTables() gets table descriptors from FS,
    // so the table is still present and this should be 1.
    assertEquals(1, htbls.length);
    assertErrors(doFsck(conf, false), new ERROR_CODE[] { ERROR_CODE.NOT_IN_META_OR_DEPLOYED, ERROR_CODE.NOT_IN_META_OR_DEPLOYED, ERROR_CODE.NOT_IN_META_OR_DEPLOYED, ERROR_CODE.NOT_IN_META_OR_DEPLOYED });
}
Also used : HBaseFsck(org.apache.hadoop.hbase.util.HBaseFsck) HbckInfo(org.apache.hadoop.hbase.util.HBaseFsck.HbckInfo) HTableDescriptor(org.apache.hadoop.hbase.HTableDescriptor) Test(org.junit.Test)

Example 10 with HBaseFsck

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

the class OfflineMetaRepair method main.

/**
   * Main program
   *
   * @param args
   * @throws Exception
   */
public static void main(String[] args) throws Exception {
    // create a fsck object
    Configuration conf = HBaseConfiguration.create();
    // Cover both bases, the old way of setting default fs and the new.
    // We're supposed to run on 0.20 and 0.21 anyways.
    FSUtils.setFsDefault(conf, FSUtils.getRootDir(conf));
    HBaseFsck fsck = new HBaseFsck(conf);
    boolean fixHoles = false;
    // Process command-line args.
    for (int i = 0; i < args.length; i++) {
        String cmd = args[i];
        if (cmd.equals("-details")) {
            HBaseFsck.setDisplayFullReport();
        } else if (cmd.equals("-base")) {
            if (i == args.length - 1) {
                System.err.println("OfflineMetaRepair: -base needs an HDFS path.");
                printUsageAndExit();
            }
            // update hbase root dir to user-specified base
            i++;
            FSUtils.setRootDir(conf, new Path(args[i]));
            FSUtils.setFsDefault(conf, FSUtils.getRootDir(conf));
        } else if (cmd.equals("-sidelineDir")) {
            if (i == args.length - 1) {
                System.err.println("OfflineMetaRepair: -sidelineDir needs an HDFS path.");
                printUsageAndExit();
            }
            // set the hbck sideline dir to user-specified one
            i++;
            fsck.setSidelineDir(args[i]);
        } else if (cmd.equals("-fixHoles")) {
            fixHoles = true;
        } else if (cmd.equals("-fix")) {
            // make all fix options true
            fixHoles = true;
        } else {
            String str = "Unknown command line option : " + cmd;
            LOG.info(str);
            System.out.println(str);
            printUsageAndExit();
        }
    }
    System.out.println("OfflineMetaRepair command line options: " + StringUtils.join(args, " "));
    // Fsck doesn't shutdown and and doesn't provide a way to shutdown its
    // threads cleanly, so we do a System.exit.
    boolean success = false;
    try {
        success = fsck.rebuildMeta(fixHoles);
    } catch (MultipleIOException mioes) {
        for (IOException ioe : mioes.getExceptions()) {
            LOG.error("Bailed out due to:", ioe);
        }
    } catch (Exception e) {
        LOG.error("Bailed out due to: ", e);
    } finally {
        System.exit(success ? 0 : 1);
    }
}
Also used : Path(org.apache.hadoop.fs.Path) HBaseConfiguration(org.apache.hadoop.hbase.HBaseConfiguration) Configuration(org.apache.hadoop.conf.Configuration) HBaseFsck(org.apache.hadoop.hbase.util.HBaseFsck) IOException(java.io.IOException) MultipleIOException(org.apache.hadoop.io.MultipleIOException) MultipleIOException(org.apache.hadoop.io.MultipleIOException) IOException(java.io.IOException) MultipleIOException(org.apache.hadoop.io.MultipleIOException)

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