Java 类org.apache.hadoop.hbase.io.hfile.TestHFile 实例源码

项目: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);
  }
}
项目: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);
  }
}
项目: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);
  }
}
项目: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    文件:TestMobStoreScanner.java   
private void createRecordAndCorruptMobFile(TableName tn, byte[] row, byte[] family, byte[] qf,
  byte[] value) throws IOException {
  Put put1 = new Put(row);
  put1.addColumn(family, qf, value);
  table.put(put1);
  admin.flush(tn);
  Path mobFile = getFlushedMobFile(conf, fs, tn, Bytes.toString(family));
  Assert.assertNotNull(mobFile);
  // create new corrupt mob file.
  Path corruptFile = new Path(mobFile.getParent(), "dummy");
  TestHFile.truncateFile(fs, mobFile, corruptFile);
  fs.delete(mobFile, true);
  fs.rename(corruptFile, mobFile);
}
项目: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);
  }
}
项目: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);
  }
}
项目: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);
  }
}