当前位置: 首页>>代码示例>>Java>>正文


Java TestHFile.truncateFile方法代码示例

本文整理汇总了Java中org.apache.hadoop.hbase.io.hfile.TestHFile.truncateFile方法的典型用法代码示例。如果您正苦于以下问题:Java TestHFile.truncateFile方法的具体用法?Java TestHFile.truncateFile怎么用?Java TestHFile.truncateFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.hbase.io.hfile.TestHFile的用法示例。


在下文中一共展示了TestHFile.truncateFile方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testQuarantineCorruptHFile

import org.apache.hadoop.hbase.io.hfile.TestHFile; //导入方法依赖的package包/类
/**
 * 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);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:40,代码来源:TestHBaseFsck.java

示例2: testQuarantineCorruptHFile

import org.apache.hadoop.hbase.io.hfile.TestHFile; //导入方法依赖的package包/类
/**
 * 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);
  }
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:40,代码来源:TestHBaseFsck.java

示例3: testQuarantineCorruptHFile

import org.apache.hadoop.hbase.io.hfile.TestHFile; //导入方法依赖的package包/类
/**
 * 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);
  }
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:40,代码来源:TestHBaseFsck.java

示例4: createRecordAndCorruptMobFile

import org.apache.hadoop.hbase.io.hfile.TestHFile; //导入方法依赖的package包/类
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);
}
 
开发者ID:apache,项目名称:hbase,代码行数:15,代码来源:TestMobStoreScanner.java

示例5: testQuarantineCorruptHFile

import org.apache.hadoop.hbase.io.hfile.TestHFile; //导入方法依赖的package包/类
/**
 * 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);
  }
}
 
开发者ID:zwqjsj0404,项目名称:HBase-Research,代码行数:40,代码来源:TestHBaseFsck.java

示例6: testQuarantineCorruptMobFile

import org.apache.hadoop.hbase.io.hfile.TestHFile; //导入方法依赖的package包/类
/**
 * 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);
  }
}
 
开发者ID:apache,项目名称:hbase,代码行数:44,代码来源:TestHBaseFsckMOB.java


注:本文中的org.apache.hadoop.hbase.io.hfile.TestHFile.truncateFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。