use of org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility.LoadCounter in project hbase by apache.
the class TestWALProcedureStore method testRestartWithoutData.
@Test
public void testRestartWithoutData() throws Exception {
for (int i = 0; i < 10; ++i) {
final LoadCounter loader = new LoadCounter();
storeRestart(loader);
}
LOG.info("ACTIVE WALs " + procStore.getActiveLogs());
assertEquals(1, procStore.getActiveLogs().size());
FileStatus[] status = fs.listStatus(logDir);
assertEquals(1, status.length);
}
use of org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility.LoadCounter in project hbase by apache.
the class TestWALProcedureStore method testNoTrailerDoubleRestart.
@Test
public void testNoTrailerDoubleRestart() throws Exception {
// log-0001: proc 0, 1 and 2 are inserted
Procedure proc0 = new TestSequentialProcedure();
procStore.insert(proc0, null);
Procedure proc1 = new TestSequentialProcedure();
procStore.insert(proc1, null);
Procedure proc2 = new TestSequentialProcedure();
procStore.insert(proc2, null);
procStore.rollWriterForTesting();
// log-0002: proc 1 deleted
procStore.delete(proc1.getProcId());
procStore.rollWriterForTesting();
// log-0003: proc 2 is update
procStore.update(proc2);
procStore.rollWriterForTesting();
// log-0004: proc 2 deleted
procStore.delete(proc2.getProcId());
// stop the store and remove the trailer
procStore.stop(false);
FileStatus[] logs = fs.listStatus(logDir);
assertEquals(4, logs.length);
for (int i = 0; i < logs.length; ++i) {
corruptLog(logs[i], 4);
}
// Test Load 1
// Restart the store (avoid cleaning up the files, to check the rebuilded trackers)
htu.getConfiguration().setBoolean(WALProcedureStore.EXEC_WAL_CLEANUP_ON_LOAD_CONF_KEY, false);
LoadCounter loader = new LoadCounter();
storeRestart(loader);
assertEquals(1, loader.getLoadedCount());
assertEquals(0, loader.getCorruptedCount());
// Test Load 2
assertEquals(5, fs.listStatus(logDir).length);
loader = new LoadCounter();
storeRestart(loader);
assertEquals(1, loader.getLoadedCount());
assertEquals(0, loader.getCorruptedCount());
// remove proc-0
procStore.delete(proc0.getProcId());
procStore.periodicRollForTesting();
assertEquals(1, fs.listStatus(logDir).length);
storeRestart(loader);
}
use of org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility.LoadCounter in project hbase by apache.
the class TestWALProcedureStore method testEmptyLogLoad.
@Test
public void testEmptyLogLoad() throws Exception {
LoadCounter loader = new LoadCounter();
storeRestart(loader);
assertEquals(0, loader.getMaxProcId());
assertEquals(0, loader.getLoadedCount());
assertEquals(0, loader.getCorruptedCount());
}
use of org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility.LoadCounter in project hbase by apache.
the class TestWALProcedureStore method testCorruptedEntries.
@Test
public void testCorruptedEntries() throws Exception {
// Insert something
for (int i = 0; i < 100; ++i) {
procStore.insert(new TestSequentialProcedure(), null);
}
// Stop the store
procStore.stop(false);
// Remove some byte from the log
// (enough to cut the trailer and corrupt some entries)
FileStatus[] logs = fs.listStatus(logDir);
assertEquals(1, logs.length);
corruptLog(logs[0], 1823);
LoadCounter loader = new LoadCounter();
storeRestart(loader);
assertTrue(procStore.getCorruptedLogs() != null);
assertEquals(1, procStore.getCorruptedLogs().size());
assertEquals(85, loader.getLoadedCount());
assertEquals(0, loader.getCorruptedCount());
}
Aggregations