本文整理汇总了Java中org.apache.hadoop.hbase.wal.WAL.Reader方法的典型用法代码示例。如果您正苦于以下问题:Java WAL.Reader方法的具体用法?Java WAL.Reader怎么用?Java WAL.Reader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.hbase.wal.WAL
的用法示例。
在下文中一共展示了WAL.Reader方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: transformFile
import org.apache.hadoop.hbase.wal.WAL; //导入方法依赖的package包/类
private static void transformFile(Path input, Path output)
throws IOException {
Configuration conf = HBaseConfiguration.create();
FileSystem inFS = input.getFileSystem(conf);
FileSystem outFS = output.getFileSystem(conf);
WAL.Reader in = WALFactory.createReaderIgnoreCustomClass(inFS, input, conf);
WALProvider.Writer out = null;
try {
if (!(in instanceof ReaderBase)) {
System.err.println("Cannot proceed, invalid reader type: " + in.getClass().getName());
return;
}
boolean compress = ((ReaderBase)in).hasCompression();
conf.setBoolean(HConstants.ENABLE_WAL_COMPRESSION, !compress);
out = WALFactory.createWALWriter(outFS, output, conf);
WAL.Entry e = null;
while ((e = in.next()) != null) out.append(e);
} finally {
in.close();
if (out != null) {
out.close();
out = null;
}
}
}
示例2: testLogMoving
import org.apache.hadoop.hbase.wal.WAL; //导入方法依赖的package包/类
/**
* Sanity check that we can move logs around while we are reading
* from them. Should this test fail, ReplicationSource would have a hard
* time reading logs that are being archived.
* @throws Exception
*/
@Test
public void testLogMoving() throws Exception{
Path logPath = new Path(logDir, "log");
if (!FS.exists(logDir)) FS.mkdirs(logDir);
if (!FS.exists(oldLogDir)) FS.mkdirs(oldLogDir);
WALProvider.Writer writer = WALFactory.createWALWriter(FS, logPath,
TEST_UTIL.getConfiguration());
for(int i = 0; i < 3; i++) {
byte[] b = Bytes.toBytes(Integer.toString(i));
KeyValue kv = new KeyValue(b,b,b);
WALEdit edit = new WALEdit();
edit.add(kv);
WALKey key = new WALKey(b, TableName.valueOf(b), 0, 0,
HConstants.DEFAULT_CLUSTER_ID);
writer.append(new WAL.Entry(key, edit));
writer.sync();
}
writer.close();
WAL.Reader reader = WALFactory.createReader(FS, logPath, TEST_UTIL.getConfiguration());
WAL.Entry entry = reader.next();
assertNotNull(entry);
Path oldLogPath = new Path(oldLogDir, "log");
FS.rename(logPath, oldLogPath);
entry = reader.next();
assertNotNull(entry);
entry = reader.next();
entry = reader.next();
assertNull(entry);
reader.close();
}
示例3: verifyWALCount
import org.apache.hadoop.hbase.wal.WAL; //导入方法依赖的package包/类
private void verifyWALCount(WALFactory wals, WAL log, int expected) throws Exception {
Path walPath = DefaultWALProvider.getCurrentFileName(log);
WAL.Reader reader = wals.createReader(FS, walPath);
int count = 0;
WAL.Entry entry = new WAL.Entry();
while (reader.next(entry) != null) count++;
reader.close();
assertEquals(expected, count);
}
示例4: verifyAllEditsMadeItIn
import org.apache.hadoop.hbase.wal.WAL; //导入方法依赖的package包/类
/**
* @param fs
* @param conf
* @param edits
* @param region
* @return Return how many edits seen.
* @throws IOException
*/
private int verifyAllEditsMadeItIn(final FileSystem fs, final Configuration conf,
final Path edits, final HRegion region)
throws IOException {
int count = 0;
// Based on HRegion#replayRecoveredEdits
WAL.Reader reader = null;
try {
reader = WALFactory.createReader(fs, edits, conf);
WAL.Entry entry;
while ((entry = reader.next()) != null) {
WALKey key = entry.getKey();
WALEdit val = entry.getEdit();
count++;
// Check this edit is for this region.
if (!Bytes.equals(key.getEncodedRegionName(),
region.getRegionInfo().getEncodedNameAsBytes())) {
continue;
}
Cell previous = null;
for (Cell cell: val.getCells()) {
if (CellUtil.matchingFamily(cell, WALEdit.METAFAMILY)) continue;
if (previous != null && CellComparator.compareRows(previous, cell) == 0) continue;
previous = cell;
Get g = new Get(CellUtil.cloneRow(cell));
Result r = region.get(g);
boolean found = false;
for (CellScanner scanner = r.cellScanner(); scanner.advance();) {
Cell current = scanner.current();
if (CellComparator.compare(cell, current, true) == 0) {
found = true;
break;
}
}
assertTrue("Failed to find " + cell, found);
}
}
} finally {
if (reader != null) reader.close();
}
return count;
}
示例5: createWALReaderForPrimary
import org.apache.hadoop.hbase.wal.WAL; //导入方法依赖的package包/类
WAL.Reader createWALReaderForPrimary() throws FileNotFoundException, IOException {
return wals.createReader(TEST_UTIL.getTestFileSystem(),
DefaultWALProvider.getCurrentFileName(walPrimary),
TEST_UTIL.getConfiguration());
}