Java 类org.apache.hadoop.hbase.util.hbck.HbckTestingUtil 实例源码

项目:ditb    文件:TestHBaseFsck.java   
/**
 * This creates a table and then corrupts an hfile.  Hbck should quarantine the file.
 */
@Test(timeout=180000)
public void testQuarantineCorruptHFile() throws Exception {
  TableName table = TableName.valueOf(name.getMethodName());
  try {
    setupTable(table);
    assertEquals(ROWKEYS.length, countRows());
    admin.flush(table); // flush is async.

    FileSystem fs = FileSystem.get(conf);
    Path hfile = getFlushedHFile(fs, table);

    // Mess it up by leaving a hole in the assignment, meta, and hdfs data
    admin.disableTable(table);

    // create new corrupt file called deadbeef (valid hfile name)
    Path corrupt = new Path(hfile.getParent(), "deadbeef");
    TestHFile.truncateFile(fs, hfile, corrupt);
    LOG.info("Created corrupted file " + corrupt);
    HBaseFsck.debugLsr(conf, FSUtils.getRootDir(conf));

    // we cannot enable here because enable never finished due to the corrupt region.
    HBaseFsck res = HbckTestingUtil.doHFileQuarantine(conf, table);
    assertEquals(res.getRetCode(), 0);
    HFileCorruptionChecker hfcc = res.getHFilecorruptionChecker();
    assertEquals(hfcc.getHFilesChecked(), 5);
    assertEquals(hfcc.getCorrupted().size(), 1);
    assertEquals(hfcc.getFailures().size(), 0);
    assertEquals(hfcc.getQuarantined().size(), 1);
    assertEquals(hfcc.getMissing().size(), 0);

    // Its been fixed, verify that we can enable.
    admin.enableTable(table);
  } finally {
    cleanupTable(table);
  }
}
项目:hbase    文件:TestMetaWithReplicas.java   
private void stopMasterAndValidateReplicaCount(final int originalReplicaCount,
    final int newReplicaCount)
    throws Exception {
  ServerName sn = TEST_UTIL.getHBaseClusterInterface().getClusterMetrics().getMasterName();
  TEST_UTIL.getHBaseClusterInterface().stopMaster(sn);
  TEST_UTIL.getHBaseClusterInterface().waitForMasterToStop(sn, 60000);
  List<String> metaZnodes = TEST_UTIL.getZooKeeperWatcher().getMetaReplicaNodes();
  assert(metaZnodes.size() == originalReplicaCount); //we should have what was configured before
  TEST_UTIL.getHBaseClusterInterface().getConf().setInt(HConstants.META_REPLICAS_NUM,
      newReplicaCount);
  if (TEST_UTIL.getHBaseCluster().countServedRegions() < newReplicaCount) {
    TEST_UTIL.getHBaseCluster().startRegionServer();
  }
  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);
}
项目:ditb    文件:TestMetaWithReplicas.java   
private void stopMasterAndValidateReplicaCount(int originalReplicaCount, 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();
  assert(metaZnodes.size() == originalReplicaCount); //we should have what was configured before
  TEST_UTIL.getHBaseClusterInterface().getConf().setInt(HConstants.META_REPLICAS_NUM,
      newReplicaCount);
  TEST_UTIL.getHBaseClusterInterface().startMaster(sn.getHostname(), 0);
  TEST_UTIL.getHBaseClusterInterface().waitForActiveAndReadyMaster();
  int count = 0;
  do {
    metaZnodes = TEST_UTIL.getZooKeeperWatcher().getMetaReplicaNodes();
    Thread.sleep(10);
    count++;
    // wait for the count to be different from the originalReplicaCount. When the
    // replica count is reduced, that will happen when the master unassigns excess
    // replica, and deletes the excess znodes
  } while (metaZnodes.size() == originalReplicaCount && count < 1000);
  assert(metaZnodes.size() == 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);
}
项目:ditb    文件:TestHBaseFsckEncryption.java   
@Test
public void testFsckWithEncryption() throws Exception {
  // Populate the table with some data
  Table table = new HTable(conf, htd.getTableName());
  try {
    byte[] values = { 'A', 'B', 'C', 'D' };
    for (int i = 0; i < values.length; i++) {
      for (int j = 0; j < values.length; j++) {
        Put put = new Put(new byte[] { values[i], values[j] });
        put.add(Bytes.toBytes("cf"), new byte[] {}, new byte[] { values[i],
          values[j] });
        table.put(put);
      }
    }
  } finally {
    table.close();
  }
  // Flush it
  TEST_UTIL.getHBaseAdmin().flush(htd.getTableName());

  // Verify we have encrypted store files on disk
  final List<Path> paths = findStorefilePaths(htd.getTableName());
  assertTrue(paths.size() > 0);
  for (Path path: paths) {
    assertTrue("Store file " + path + " has incorrect key",
      Bytes.equals(cfKey.getEncoded(), extractHFileKey(path)));
  }

  // Insure HBck doesn't consider them corrupt
  HBaseFsck res = HbckTestingUtil.doHFileQuarantine(conf, htd.getTableName());
  assertEquals(res.getRetCode(), 0);
  HFileCorruptionChecker hfcc = res.getHFilecorruptionChecker();
  assertEquals(hfcc.getCorrupted().size(), 0);
  assertEquals(hfcc.getFailures().size(), 0);
  assertEquals(hfcc.getQuarantined().size(), 0);
  assertEquals(hfcc.getMissing().size(), 0);
}
项目:LCIndex-HBase-0.94.16    文件:TestHBaseFsck.java   
/**
 * This creates a table and then corrupts an hfile.  Hbck should quarantine the file.
 */
@Test(timeout=180000)
public void testQuarantineCorruptHFile() throws Exception {
  String table = name.getMethodName();
  try {
    setupTable(table);
    assertEquals(ROWKEYS.length, countRows());
    TEST_UTIL.getHBaseAdmin().flush(table); // flush is async.

    FileSystem fs = FileSystem.get(conf);
    Path hfile = getFlushedHFile(fs, table);

    // Mess it up by leaving a hole in the assignment, meta, and hdfs data
    TEST_UTIL.getHBaseAdmin().disableTable(table);

    // create new corrupt file called deadbeef (valid hfile name)
    Path corrupt = new Path(hfile.getParent(), "deadbeef");
    TestHFile.truncateFile(fs, hfile, corrupt);
    LOG.info("Created corrupted file " + corrupt);
    HBaseFsck.debugLsr(conf, FSUtils.getRootDir(conf));

    // we cannot enable here because enable never finished due to the corrupt region.
    HBaseFsck res = HbckTestingUtil.doHFileQuarantine(conf, table);
    assertEquals(res.getRetCode(), 0);
    HFileCorruptionChecker hfcc = res.getHFilecorruptionChecker();
    assertEquals(hfcc.getHFilesChecked(), 5);
    assertEquals(hfcc.getCorrupted().size(), 1);
    assertEquals(hfcc.getFailures().size(), 0);
    assertEquals(hfcc.getQuarantined().size(), 1);
    assertEquals(hfcc.getMissing().size(), 0);

    // Its been fixed, verify that we can enable.
    TEST_UTIL.getHBaseAdmin().enableTable(table);
  } finally {
    deleteTable(table);
  }
}
项目:pbase    文件:TestHBaseFsck.java   
/**
 * This creates a table and then corrupts an hfile.  Hbck should quarantine the file.
 */
@Test(timeout=180000)
public void testQuarantineCorruptHFile() throws Exception {
  TableName table = TableName.valueOf(name.getMethodName());
  try {
    setupTable(table);
    assertEquals(ROWKEYS.length, countRows());
    admin.flush(table); // flush is async.

    FileSystem fs = FileSystem.get(conf);
    Path hfile = getFlushedHFile(fs, table);

    // Mess it up by leaving a hole in the assignment, meta, and hdfs data
    admin.disableTable(table);

    // create new corrupt file called deadbeef (valid hfile name)
    Path corrupt = new Path(hfile.getParent(), "deadbeef");
    TestHFile.truncateFile(fs, hfile, corrupt);
    LOG.info("Created corrupted file " + corrupt);
    HBaseFsck.debugLsr(conf, FSUtils.getRootDir(conf));

    // we cannot enable here because enable never finished due to the corrupt region.
    HBaseFsck res = HbckTestingUtil.doHFileQuarantine(conf, table);
    assertEquals(res.getRetCode(), 0);
    HFileCorruptionChecker hfcc = res.getHFilecorruptionChecker();
    assertEquals(hfcc.getHFilesChecked(), 5);
    assertEquals(hfcc.getCorrupted().size(), 1);
    assertEquals(hfcc.getFailures().size(), 0);
    assertEquals(hfcc.getQuarantined().size(), 1);
    assertEquals(hfcc.getMissing().size(), 0);

    // Its been fixed, verify that we can enable.
    admin.enableTable(table);
  } finally {
    cleanupTable(table);
  }
}
项目:pbase    文件:TestHBaseFsckEncryption.java   
@Test
public void testFsckWithEncryption() throws Exception {
  // Populate the table with some data
  Table table = new HTable(conf, htd.getTableName());
  try {
    byte[] values = { 'A', 'B', 'C', 'D' };
    for (int i = 0; i < values.length; i++) {
      for (int j = 0; j < values.length; j++) {
        Put put = new Put(new byte[] { values[i], values[j] });
        put.add(Bytes.toBytes("cf"), new byte[] {}, new byte[] { values[i],
          values[j] });
        table.put(put);
      }
    }
  } finally {
    table.close();
  }
  // Flush it
  TEST_UTIL.getHBaseAdmin().flush(htd.getTableName());

  // Verify we have encrypted store files on disk
  final List<Path> paths = findStorefilePaths(htd.getTableName());
  assertTrue(paths.size() > 0);
  for (Path path: paths) {
    assertTrue("Store file " + path + " has incorrect key",
      Bytes.equals(cfKey.getEncoded(), extractHFileKey(path)));
  }

  // Insure HBck doesn't consider them corrupt
  HBaseFsck res = HbckTestingUtil.doHFileQuarantine(conf, htd.getTableName());
  assertEquals(res.getRetCode(), 0);
  HFileCorruptionChecker hfcc = res.getHFilecorruptionChecker();
  assertEquals(hfcc.getCorrupted().size(), 0);
  assertEquals(hfcc.getFailures().size(), 0);
  assertEquals(hfcc.getQuarantined().size(), 0);
  assertEquals(hfcc.getMissing().size(), 0);
}
项目:HIndex    文件:TestHBaseFsck.java   
/**
 * This creates a table and then corrupts an hfile.  Hbck should quarantine the file.
 */
@Test(timeout=180000)
public void testQuarantineCorruptHFile() throws Exception {
  TableName table = TableName.valueOf(name.getMethodName());
  try {
    setupTable(table);
    assertEquals(ROWKEYS.length, countRows());
    TEST_UTIL.getHBaseAdmin().flush(table.getName()); // flush is async.

    FileSystem fs = FileSystem.get(conf);
    Path hfile = getFlushedHFile(fs, table);

    // Mess it up by leaving a hole in the assignment, meta, and hdfs data
    TEST_UTIL.getHBaseAdmin().disableTable(table);

    // create new corrupt file called deadbeef (valid hfile name)
    Path corrupt = new Path(hfile.getParent(), "deadbeef");
    TestHFile.truncateFile(fs, hfile, corrupt);
    LOG.info("Created corrupted file " + corrupt);
    HBaseFsck.debugLsr(conf, FSUtils.getRootDir(conf));

    // we cannot enable here because enable never finished due to the corrupt region.
    HBaseFsck res = HbckTestingUtil.doHFileQuarantine(conf, table);
    assertEquals(res.getRetCode(), 0);
    HFileCorruptionChecker hfcc = res.getHFilecorruptionChecker();
    assertEquals(hfcc.getHFilesChecked(), 5);
    assertEquals(hfcc.getCorrupted().size(), 1);
    assertEquals(hfcc.getFailures().size(), 0);
    assertEquals(hfcc.getQuarantined().size(), 1);
    assertEquals(hfcc.getMissing().size(), 0);

    // Its been fixed, verify that we can enable.
    TEST_UTIL.getHBaseAdmin().enableTable(table);
  } finally {
    deleteTable(table);
  }
}
项目:HIndex    文件:TestHBaseFsckEncryption.java   
@Test
public void testFsckWithEncryption() throws Exception {
  // Populate the table with some data
  HTable table = new HTable(conf, htd.getName());
  try {
    byte[] values = { 'A', 'B', 'C', 'D' };
    for (int i = 0; i < values.length; i++) {
      for (int j = 0; j < values.length; j++) {
        Put put = new Put(new byte[] { values[i], values[j] });
        put.add(Bytes.toBytes("cf"), new byte[] {}, new byte[] { values[i],
          values[j] });
        table.put(put);
      }
    }
  } finally {
    table.close();
  }
  // Flush it
  TEST_UTIL.getHBaseAdmin().flush(htd.getName());

  // Verify we have encrypted store files on disk
  final List<Path> paths = findStorefilePaths(htd.getName());
  assertTrue(paths.size() > 0);
  for (Path path: paths) {
    assertTrue("Store file " + path + " has incorrect key",
      Bytes.equals(cfKey.getEncoded(), extractHFileKey(path)));
  }

  // Insure HBck doesn't consider them corrupt
  HBaseFsck res = HbckTestingUtil.doHFileQuarantine(conf, htd.getTableName());
  assertEquals(res.getRetCode(), 0);
  HFileCorruptionChecker hfcc = res.getHFilecorruptionChecker();
  assertEquals(hfcc.getCorrupted().size(), 0);
  assertEquals(hfcc.getFailures().size(), 0);
  assertEquals(hfcc.getQuarantined().size(), 0);
  assertEquals(hfcc.getMissing().size(), 0);
}
项目:IRIndex    文件:TestHBaseFsck.java   
/**
 * This creates a table and then corrupts an hfile.  Hbck should quarantine the file.
 */
@Test(timeout=180000)
public void testQuarantineCorruptHFile() throws Exception {
  String table = name.getMethodName();
  try {
    setupTable(table);
    assertEquals(ROWKEYS.length, countRows());
    TEST_UTIL.getHBaseAdmin().flush(table); // flush is async.

    FileSystem fs = FileSystem.get(conf);
    Path hfile = getFlushedHFile(fs, table);

    // Mess it up by leaving a hole in the assignment, meta, and hdfs data
    TEST_UTIL.getHBaseAdmin().disableTable(table);

    // create new corrupt file called deadbeef (valid hfile name)
    Path corrupt = new Path(hfile.getParent(), "deadbeef");
    TestHFile.truncateFile(fs, hfile, corrupt);
    LOG.info("Created corrupted file " + corrupt);
    HBaseFsck.debugLsr(conf, FSUtils.getRootDir(conf));

    // we cannot enable here because enable never finished due to the corrupt region.
    HBaseFsck res = HbckTestingUtil.doHFileQuarantine(conf, table);
    assertEquals(res.getRetCode(), 0);
    HFileCorruptionChecker hfcc = res.getHFilecorruptionChecker();
    assertEquals(hfcc.getHFilesChecked(), 5);
    assertEquals(hfcc.getCorrupted().size(), 1);
    assertEquals(hfcc.getFailures().size(), 0);
    assertEquals(hfcc.getQuarantined().size(), 1);
    assertEquals(hfcc.getMissing().size(), 0);

    // Its been fixed, verify that we can enable.
    TEST_UTIL.getHBaseAdmin().enableTable(table);
  } finally {
    deleteTable(table);
  }
}
项目:hbase    文件:TestHBaseFsckEncryption.java   
@Test
public void testFsckWithEncryption() throws Exception {
  // Populate the table with some data
  Table table = TEST_UTIL.getConnection().getTable(htd.getTableName());
  try {
    byte[] values = { 'A', 'B', 'C', 'D' };
    for (int i = 0; i < values.length; i++) {
      for (int j = 0; j < values.length; j++) {
        Put put = new Put(new byte[] { values[i], values[j] });
        put.addColumn(Bytes.toBytes("cf"), new byte[]{}, new byte[]{values[i],
                values[j]});
        table.put(put);
      }
    }
  } finally {
    table.close();
  }
  // Flush it
  TEST_UTIL.getAdmin().flush(htd.getTableName());

  // Verify we have encrypted store files on disk
  final List<Path> paths = findStorefilePaths(htd.getTableName());
  assertTrue(paths.size() > 0);
  for (Path path: paths) {
    assertTrue("Store file " + path + " has incorrect key",
      Bytes.equals(cfKey.getEncoded(), extractHFileKey(path)));
  }

  // Insure HBck doesn't consider them corrupt
  HBaseFsck res = HbckTestingUtil.doHFileQuarantine(conf, htd.getTableName());
  assertEquals(0, res.getRetCode());
  HFileCorruptionChecker hfcc = res.getHFilecorruptionChecker();
  assertEquals(0, hfcc.getCorrupted().size());
  assertEquals(0, hfcc.getFailures().size());
  assertEquals(0, hfcc.getQuarantined().size());
  assertEquals(0, hfcc.getMissing().size());
}
项目:PyroDB    文件:TestHBaseFsck.java   
/**
 * This creates a table and then corrupts an hfile.  Hbck should quarantine the file.
 */
@Test(timeout=180000)
public void testQuarantineCorruptHFile() throws Exception {
  TableName table = TableName.valueOf(name.getMethodName());
  try {
    setupTable(table);
    assertEquals(ROWKEYS.length, countRows());
    TEST_UTIL.getHBaseAdmin().flush(table.getName()); // flush is async.

    FileSystem fs = FileSystem.get(conf);
    Path hfile = getFlushedHFile(fs, table);

    // Mess it up by leaving a hole in the assignment, meta, and hdfs data
    TEST_UTIL.getHBaseAdmin().disableTable(table);

    // create new corrupt file called deadbeef (valid hfile name)
    Path corrupt = new Path(hfile.getParent(), "deadbeef");
    TestHFile.truncateFile(fs, hfile, corrupt);
    LOG.info("Created corrupted file " + corrupt);
    HBaseFsck.debugLsr(conf, FSUtils.getRootDir(conf));

    // we cannot enable here because enable never finished due to the corrupt region.
    HBaseFsck res = HbckTestingUtil.doHFileQuarantine(conf, table);
    assertEquals(res.getRetCode(), 0);
    HFileCorruptionChecker hfcc = res.getHFilecorruptionChecker();
    assertEquals(hfcc.getHFilesChecked(), 5);
    assertEquals(hfcc.getCorrupted().size(), 1);
    assertEquals(hfcc.getFailures().size(), 0);
    assertEquals(hfcc.getQuarantined().size(), 1);
    assertEquals(hfcc.getMissing().size(), 0);

    // Its been fixed, verify that we can enable.
    TEST_UTIL.getHBaseAdmin().enableTable(table);
  } finally {
    deleteTable(table);
  }
}
项目:PyroDB    文件:TestHBaseFsckEncryption.java   
@Test
public void testFsckWithEncryption() throws Exception {
  // Populate the table with some data
  HTable table = new HTable(conf, htd.getName());
  try {
    byte[] values = { 'A', 'B', 'C', 'D' };
    for (int i = 0; i < values.length; i++) {
      for (int j = 0; j < values.length; j++) {
        Put put = new Put(new byte[] { values[i], values[j] });
        put.add(Bytes.toBytes("cf"), new byte[] {}, new byte[] { values[i],
          values[j] });
        table.put(put);
      }
    }
  } finally {
    table.close();
  }
  // Flush it
  TEST_UTIL.getHBaseAdmin().flush(htd.getName());

  // Verify we have encrypted store files on disk
  final List<Path> paths = findStorefilePaths(htd.getName());
  assertTrue(paths.size() > 0);
  for (Path path: paths) {
    assertTrue("Store file " + path + " has incorrect key",
      Bytes.equals(cfKey.getEncoded(), extractHFileKey(path)));
  }

  // Insure HBck doesn't consider them corrupt
  HBaseFsck res = HbckTestingUtil.doHFileQuarantine(conf, htd.getTableName());
  assertEquals(res.getRetCode(), 0);
  HFileCorruptionChecker hfcc = res.getHFilecorruptionChecker();
  assertEquals(hfcc.getCorrupted().size(), 0);
  assertEquals(hfcc.getFailures().size(), 0);
  assertEquals(hfcc.getQuarantined().size(), 0);
  assertEquals(hfcc.getMissing().size(), 0);
}
项目:c5    文件:TestHBaseFsck.java   
/**
 * This creates a table and then corrupts an hfile.  Hbck should quarantine the file.
 */
@Test(timeout=180000)
public void testQuarantineCorruptHFile() throws Exception {
  TableName table = TableName.valueOf(name.getMethodName());
  try {
    setupTable(table);
    assertEquals(ROWKEYS.length, countRows());
    TEST_UTIL.getHBaseAdmin().flush(table.getName()); // flush is async.

    FileSystem fs = FileSystem.get(conf);
    Path hfile = getFlushedHFile(fs, table);

    // Mess it up by leaving a hole in the assignment, meta, and hdfs data
    TEST_UTIL.getHBaseAdmin().disableTable(table);

    // create new corrupt file called deadbeef (valid hfile name)
    Path corrupt = new Path(hfile.getParent(), "deadbeef");
    TestHFile.truncateFile(fs, hfile, corrupt);
    LOG.info("Created corrupted file " + corrupt);
    HBaseFsck.debugLsr(conf, FSUtils.getRootDir(conf));

    // we cannot enable here because enable never finished due to the corrupt region.
    HBaseFsck res = HbckTestingUtil.doHFileQuarantine(conf, table);
    assertEquals(res.getRetCode(), 0);
    HFileCorruptionChecker hfcc = res.getHFilecorruptionChecker();
    assertEquals(hfcc.getHFilesChecked(), 5);
    assertEquals(hfcc.getCorrupted().size(), 1);
    assertEquals(hfcc.getFailures().size(), 0);
    assertEquals(hfcc.getQuarantined().size(), 1);
    assertEquals(hfcc.getMissing().size(), 0);

    // Its been fixed, verify that we can enable.
    TEST_UTIL.getHBaseAdmin().enableTable(table);
  } finally {
    deleteTable(table);
  }
}
项目:HBase-Research    文件:TestHBaseFsck.java   
/**
 * This creates a table and then corrupts an hfile.  Hbck should quarantine the file.
 */
@Test(timeout=120000)
public void testQuarantineCorruptHFile() throws Exception {
  String table = name.getMethodName();
  try {
    setupTable(table);
    assertEquals(ROWKEYS.length, countRows());
    TEST_UTIL.getHBaseAdmin().flush(table); // flush is async.

    FileSystem fs = FileSystem.get(conf);
    Path hfile = getFlushedHFile(fs, table);

    // Mess it up by leaving a hole in the assignment, meta, and hdfs data
    TEST_UTIL.getHBaseAdmin().disableTable(table);

    // create new corrupt file called deadbeef (valid hfile name)
    Path corrupt = new Path(hfile.getParent(), "deadbeef");
    TestHFile.truncateFile(fs, hfile, corrupt);
    LOG.info("Created corrupted file " + corrupt);
    HBaseFsck.debugLsr(conf, FSUtils.getRootDir(conf));

    // we cannot enable here because enable never finished due to the corrupt region.
    HBaseFsck res = HbckTestingUtil.doHFileQuarantine(conf, table);
    assertEquals(res.getRetCode(), 0);
    HFileCorruptionChecker hfcc = res.getHFilecorruptionChecker();
    assertEquals(hfcc.getHFilesChecked(), 5);
    assertEquals(hfcc.getCorrupted().size(), 1);
    assertEquals(hfcc.getFailures().size(), 0);
    assertEquals(hfcc.getQuarantined().size(), 1);
    assertEquals(hfcc.getMissing().size(), 0);

    // Its been fixed, verify that we can enable.
    TEST_UTIL.getHBaseAdmin().enableTable(table);
  } finally {
    deleteTable(table);
  }
}
项目:hbase-0.94.8-qod    文件:TestHBaseFsck.java   
/**
 * This creates a table and then corrupts an hfile.  Hbck should quarantine the file.
 */
@Test(timeout=120000)
public void testQuarantineCorruptHFile() throws Exception {
  String table = name.getMethodName();
  try {
    setupTable(table);
    assertEquals(ROWKEYS.length, countRows());
    TEST_UTIL.getHBaseAdmin().flush(table); // flush is async.

    FileSystem fs = FileSystem.get(conf);
    Path hfile = getFlushedHFile(fs, table);

    // Mess it up by leaving a hole in the assignment, meta, and hdfs data
    TEST_UTIL.getHBaseAdmin().disableTable(table);

    // create new corrupt file called deadbeef (valid hfile name)
    Path corrupt = new Path(hfile.getParent(), "deadbeef");
    TestHFile.truncateFile(fs, hfile, corrupt);
    LOG.info("Created corrupted file " + corrupt);
    HBaseFsck.debugLsr(conf, FSUtils.getRootDir(conf));

    // we cannot enable here because enable never finished due to the corrupt region.
    HBaseFsck res = HbckTestingUtil.doHFileQuarantine(conf, table);
    assertEquals(res.getRetCode(), 0);
    HFileCorruptionChecker hfcc = res.getHFilecorruptionChecker();
    assertEquals(hfcc.getHFilesChecked(), 5);
    assertEquals(hfcc.getCorrupted().size(), 1);
    assertEquals(hfcc.getFailures().size(), 0);
    assertEquals(hfcc.getQuarantined().size(), 1);
    assertEquals(hfcc.getMissing().size(), 0);

    // Its been fixed, verify that we can enable.
    TEST_UTIL.getHBaseAdmin().enableTable(table);
  } finally {
    deleteTable(table);
  }
}
项目:hbase-0.94.8-qod    文件:TestHBaseFsck.java   
/**
 * This creates a table and then corrupts an hfile.  Hbck should quarantine the file.
 */
@Test(timeout=120000)
public void testQuarantineCorruptHFile() throws Exception {
  String table = name.getMethodName();
  try {
    setupTable(table);
    assertEquals(ROWKEYS.length, countRows());
    TEST_UTIL.getHBaseAdmin().flush(table); // flush is async.

    FileSystem fs = FileSystem.get(conf);
    Path hfile = getFlushedHFile(fs, table);

    // Mess it up by leaving a hole in the assignment, meta, and hdfs data
    TEST_UTIL.getHBaseAdmin().disableTable(table);

    // create new corrupt file called deadbeef (valid hfile name)
    Path corrupt = new Path(hfile.getParent(), "deadbeef");
    TestHFile.truncateFile(fs, hfile, corrupt);
    LOG.info("Created corrupted file " + corrupt);
    HBaseFsck.debugLsr(conf, FSUtils.getRootDir(conf));

    // we cannot enable here because enable never finished due to the corrupt region.
    HBaseFsck res = HbckTestingUtil.doHFileQuarantine(conf, table);
    assertEquals(res.getRetCode(), 0);
    HFileCorruptionChecker hfcc = res.getHFilecorruptionChecker();
    assertEquals(hfcc.getHFilesChecked(), 5);
    assertEquals(hfcc.getCorrupted().size(), 1);
    assertEquals(hfcc.getFailures().size(), 0);
    assertEquals(hfcc.getQuarantined().size(), 1);
    assertEquals(hfcc.getMissing().size(), 0);

    // Its been fixed, verify that we can enable.
    TEST_UTIL.getHBaseAdmin().enableTable(table);
  } finally {
    deleteTable(table);
  }
}
项目:DominoHBase    文件:TestHBaseFsck.java   
/**
 * This creates a table and then corrupts an hfile.  Hbck should quarantine the file.
 */
@Test(timeout=120000)
public void testQuarantineCorruptHFile() throws Exception {
  String table = name.getMethodName();
  try {
    setupTable(table);
    assertEquals(ROWKEYS.length, countRows());
    TEST_UTIL.getHBaseAdmin().flush(table); // flush is async.

    FileSystem fs = FileSystem.get(conf);
    Path hfile = getFlushedHFile(fs, table);

    // Mess it up by leaving a hole in the assignment, meta, and hdfs data
    TEST_UTIL.getHBaseAdmin().disableTable(table);

    // create new corrupt file called deadbeef (valid hfile name)
    Path corrupt = new Path(hfile.getParent(), "deadbeef");
    TestHFile.truncateFile(fs, hfile, corrupt);
    LOG.info("Created corrupted file " + corrupt);
    HBaseFsck.debugLsr(conf, FSUtils.getRootDir(conf));

    // we cannot enable here because enable never finished due to the corrupt region.
    HBaseFsck res = HbckTestingUtil.doHFileQuarantine(conf, table);
    assertEquals(res.getRetCode(), 0);
    HFileCorruptionChecker hfcc = res.getHFilecorruptionChecker();
    assertEquals(hfcc.getHFilesChecked(), 5);
    assertEquals(hfcc.getCorrupted().size(), 1);
    assertEquals(hfcc.getFailures().size(), 0);
    assertEquals(hfcc.getQuarantined().size(), 1);
    assertEquals(hfcc.getMissing().size(), 0);

    // Its been fixed, verify that we can enable.
    TEST_UTIL.getHBaseAdmin().enableTable(table);
  } finally {
    deleteTable(table);
  }
}
项目:hindex    文件:TestHBaseFsck.java   
/**
 * This creates a table and then corrupts an hfile.  Hbck should quarantine the file.
 */
@Test(timeout=120000)
public void testQuarantineCorruptHFile() throws Exception {
  String table = name.getMethodName();
  try {
    setupTable(table);
    assertEquals(ROWKEYS.length, countRows());
    TEST_UTIL.getHBaseAdmin().flush(table); // flush is async.

    FileSystem fs = FileSystem.get(conf);
    Path hfile = getFlushedHFile(fs, table);

    // Mess it up by leaving a hole in the assignment, meta, and hdfs data
    TEST_UTIL.getHBaseAdmin().disableTable(table);

    // create new corrupt file called deadbeef (valid hfile name)
    Path corrupt = new Path(hfile.getParent(), "deadbeef");
    TestHFile.truncateFile(fs, hfile, corrupt);
    LOG.info("Created corrupted file " + corrupt);
    HBaseFsck.debugLsr(conf, FSUtils.getRootDir(conf));

    // we cannot enable here because enable never finished due to the corrupt region.
    HBaseFsck res = HbckTestingUtil.doHFileQuarantine(conf, table);
    assertEquals(res.getRetCode(), 0);
    HFileCorruptionChecker hfcc = res.getHFilecorruptionChecker();
    assertEquals(hfcc.getHFilesChecked(), 5);
    assertEquals(hfcc.getCorrupted().size(), 1);
    assertEquals(hfcc.getFailures().size(), 0);
    assertEquals(hfcc.getQuarantined().size(), 1);
    assertEquals(hfcc.getMissing().size(), 0);

    // Its been fixed, verify that we can enable.
    TEST_UTIL.getHBaseAdmin().enableTable(table);
  } finally {
    deleteTable(table);
  }
}
项目:ditb    文件:TestMetaWithReplicas.java   
@Test
public void testHBaseFsckWithMetaReplicas() throws Exception {
  HBaseFsck hbck = HbckTestingUtil.doFsck(TEST_UTIL.getConfiguration(), false);
  HbckTestingUtil.assertNoErrors(hbck);
}
项目:hbase    文件:TestMetaWithReplicas.java   
@Ignore @Test
public void testHBaseFsckWithMetaReplicas() throws Exception {
  HBaseFsck hbck = HbckTestingUtil.doFsck(TEST_UTIL.getConfiguration(), false);
  HbckTestingUtil.assertNoErrors(hbck);
}
项目:hbase    文件:TestHBaseFsckMOB.java   
/**
 * This creates a table and then corrupts a mob file.  Hbck should quarantine the file.
 */
@Test(timeout=180000)
public void testQuarantineCorruptMobFile() throws Exception {
  TableName table = TableName.valueOf(name.getMethodName());
  try {
    setupMobTable(table);
    assertEquals(ROWKEYS.length, countRows());
    admin.flush(table);

    FileSystem fs = FileSystem.get(conf);
    Path mobFile = getFlushedMobFile(fs, table);
    admin.disableTable(table);
    // create new corrupt mob file.
    String corruptMobFile = createMobFileName(mobFile.getName());
    Path corrupt = new Path(mobFile.getParent(), corruptMobFile);
    TestHFile.truncateFile(fs, mobFile, corrupt);
    LOG.info("Created corrupted mob file " + corrupt);
    HBaseFsck.debugLsr(conf, FSUtils.getRootDir(conf));
    HBaseFsck.debugLsr(conf, MobUtils.getMobHome(conf));

    // A corrupt mob file doesn't abort the start of regions, so we can enable the table.
    admin.enableTable(table);
    HBaseFsck res = HbckTestingUtil.doHFileQuarantine(conf, table);
    assertEquals(0, res.getRetCode());
    HFileCorruptionChecker hfcc = res.getHFilecorruptionChecker();
    assertEquals(4, hfcc.getHFilesChecked());
    assertEquals(0, hfcc.getCorrupted().size());
    assertEquals(0, hfcc.getFailures().size());
    assertEquals(0, hfcc.getQuarantined().size());
    assertEquals(0, hfcc.getMissing().size());
    assertEquals(5, hfcc.getMobFilesChecked());
    assertEquals(1, hfcc.getCorruptedMobFiles().size());
    assertEquals(0, hfcc.getFailureMobFiles().size());
    assertEquals(1, hfcc.getQuarantinedMobFiles().size());
    assertEquals(0, hfcc.getMissedMobFiles().size());
    String quarantinedMobFile = hfcc.getQuarantinedMobFiles().iterator().next().getName();
    assertEquals(corruptMobFile, quarantinedMobFile);
  } finally {
    cleanupTable(table);
  }
}
项目:hbase    文件:TestHBaseFsckReplication.java   
@Test
public void test() throws Exception {
  ReplicationPeerStorage peerStorage = ReplicationStorageFactory
      .getReplicationPeerStorage(UTIL.getZooKeeperWatcher(), UTIL.getConfiguration());
  ReplicationQueueStorage queueStorage = ReplicationStorageFactory
      .getReplicationQueueStorage(UTIL.getZooKeeperWatcher(), UTIL.getConfiguration());

  String peerId1 = "1";
  String peerId2 = "2";
  peerStorage.addPeer(peerId1, ReplicationPeerConfig.newBuilder().setClusterKey("key").build(),
    true);
  peerStorage.addPeer(peerId2, ReplicationPeerConfig.newBuilder().setClusterKey("key").build(),
    true);
  for (int i = 0; i < 10; i++) {
    queueStorage.addWAL(ServerName.valueOf("localhost", 10000 + i, 100000 + i), peerId1,
      "file-" + i);
  }
  queueStorage.addWAL(ServerName.valueOf("localhost", 10000, 100000), peerId2, "file");
  HBaseFsck fsck = HbckTestingUtil.doFsck(UTIL.getConfiguration(), true);
  HbckTestingUtil.assertNoErrors(fsck);

  // should not remove anything since the replication peer is still alive
  assertEquals(10, queueStorage.getListOfReplicators().size());
  peerStorage.removePeer(peerId1);
  // there should be orphan queues
  assertEquals(10, queueStorage.getListOfReplicators().size());
  fsck = HbckTestingUtil.doFsck(UTIL.getConfiguration(), false);
  HbckTestingUtil.assertErrors(fsck, Stream.generate(() -> {
    return ERROR_CODE.UNDELETED_REPLICATION_QUEUE;
  }).limit(10).toArray(ERROR_CODE[]::new));

  // should not delete anything when fix is false
  assertEquals(10, queueStorage.getListOfReplicators().size());

  fsck = HbckTestingUtil.doFsck(UTIL.getConfiguration(), true);
  HbckTestingUtil.assertErrors(fsck, Stream.generate(() -> {
    return ERROR_CODE.UNDELETED_REPLICATION_QUEUE;
  }).limit(10).toArray(ERROR_CODE[]::new));

  List<ServerName> replicators = queueStorage.getListOfReplicators();
  // should not remove the server with queue for peerId2
  assertEquals(1, replicators.size());
  assertEquals(ServerName.valueOf("localhost", 10000, 100000), replicators.get(0));
  for (String queueId : queueStorage.getAllQueues(replicators.get(0))) {
    assertEquals(peerId2, queueId);
  }
}