Search in sources :

Example 11 with LoadCounter

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);
}
Also used : FileStatus(org.apache.hadoop.fs.FileStatus) LoadCounter(org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility.LoadCounter) Test(org.junit.Test)

Example 12 with LoadCounter

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);
}
Also used : FileStatus(org.apache.hadoop.fs.FileStatus) LoadCounter(org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility.LoadCounter) SequentialProcedure(org.apache.hadoop.hbase.procedure2.SequentialProcedure) TestProcedure(org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility.TestProcedure) Procedure(org.apache.hadoop.hbase.procedure2.Procedure) Test(org.junit.Test)

Example 13 with LoadCounter

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());
}
Also used : LoadCounter(org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility.LoadCounter) Test(org.junit.Test)

Example 14 with LoadCounter

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());
}
Also used : FileStatus(org.apache.hadoop.fs.FileStatus) LoadCounter(org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility.LoadCounter) Test(org.junit.Test)

Aggregations

LoadCounter (org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility.LoadCounter)14 Test (org.junit.Test)11 FileStatus (org.apache.hadoop.fs.FileStatus)7 TestProcedure (org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility.TestProcedure)7 Path (org.apache.hadoop.fs.Path)3 Procedure (org.apache.hadoop.hbase.procedure2.Procedure)3 SequentialProcedure (org.apache.hadoop.hbase.procedure2.SequentialProcedure)3 HBaseCommonTestingUtility (org.apache.hadoop.hbase.HBaseCommonTestingUtility)2 Before (org.junit.Before)2 FileNotFoundException (java.io.FileNotFoundException)1 FileSystem (org.apache.hadoop.fs.FileSystem)1 ProcedureStoreTracker (org.apache.hadoop.hbase.procedure2.store.ProcedureStoreTracker)1