本文整理汇总了Java中org.apache.hadoop.hbase.io.hfile.TestHFile类的典型用法代码示例。如果您正苦于以下问题:Java TestHFile类的具体用法?Java TestHFile怎么用?Java TestHFile使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TestHFile类属于org.apache.hadoop.hbase.io.hfile包,在下文中一共展示了TestHFile类的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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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);
}
}
示例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);
}
}