Search in sources :

Example 6 with TestProcedure

use of org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility.TestProcedure in project hbase by apache.

the class TestWALProcedureStore method testWalReplayOrder_ABC_BAD.

@Test(timeout = 60000)
public void testWalReplayOrder_ABC_BAD() throws Exception {
    /*
     * | A B C | -> | B A D |
     */
    TestProcedure a = new TestProcedure(1, 0);
    TestProcedure b = new TestProcedure(2, 1);
    TestProcedure c = new TestProcedure(3, 2);
    TestProcedure d = new TestProcedure(4, 0);
    procStore.insert(a, null);
    a.addStackId(0);
    procStore.update(a);
    procStore.insert(a, new Procedure[] { b });
    b.addStackId(1);
    procStore.update(b);
    procStore.insert(b, new Procedure[] { c });
    b.addStackId(2);
    procStore.update(b);
    procStore.rollWriterForTesting();
    b.addStackId(3);
    procStore.update(b);
    a.addStackId(4);
    procStore.update(a);
    procStore.insert(d, null);
    d.addStackId(0);
    procStore.update(d);
    storeRestart(new ProcedureStore.ProcedureLoader() {

        @Override
        public void setMaxProcId(long maxProcId) {
            assertEquals(4, maxProcId);
        }

        @Override
        public void load(ProcedureIterator procIter) throws IOException {
            assertTrue(procIter.hasNext());
            assertEquals(4, procIter.nextAsProcedureInfo().getProcId());
            // TODO: This will be multiple call once we do fast-start
            //assertFalse(procIter.hasNext());
            assertTrue(procIter.hasNext());
            assertEquals(1, procIter.nextAsProcedureInfo().getProcId());
            assertTrue(procIter.hasNext());
            assertEquals(2, procIter.nextAsProcedureInfo().getProcId());
            assertTrue(procIter.hasNext());
            assertEquals(3, procIter.nextAsProcedureInfo().getProcId());
            assertFalse(procIter.hasNext());
        }

        @Override
        public void handleCorrupted(ProcedureIterator procIter) throws IOException {
            assertFalse(procIter.hasNext());
        }
    });
}
Also used : TestProcedure(org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility.TestProcedure) ProcedureStore(org.apache.hadoop.hbase.procedure2.store.ProcedureStore) ProcedureIterator(org.apache.hadoop.hbase.procedure2.store.ProcedureStore.ProcedureIterator) IOException(java.io.IOException) Test(org.junit.Test)

Example 7 with TestProcedure

use of org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility.TestProcedure in project hbase by apache.

the class TestWALProcedureStore method testFileNotFoundDuringLeaseRecovery.

@Test
public void testFileNotFoundDuringLeaseRecovery() throws IOException {
    final TestProcedure[] procs = new TestProcedure[3];
    for (int i = 0; i < procs.length; ++i) {
        procs[i] = new TestProcedure(i + 1, 0);
        procStore.insert(procs[i], null);
    }
    procStore.rollWriterForTesting();
    for (int i = 0; i < procs.length; ++i) {
        procStore.update(procs[i]);
        procStore.rollWriterForTesting();
    }
    procStore.stop(false);
    FileStatus[] status = fs.listStatus(logDir);
    assertEquals(procs.length + 1, status.length);
    // simulate another active master removing the wals
    procStore = new WALProcedureStore(htu.getConfiguration(), fs, logDir, new WALProcedureStore.LeaseRecovery() {

        private int count = 0;

        @Override
        public void recoverFileLease(FileSystem fs, Path path) throws IOException {
            if (++count <= 2) {
                fs.delete(path, false);
                LOG.debug("Simulate FileNotFound at count=" + count + " for " + path);
                throw new FileNotFoundException("test file not found " + path);
            }
            LOG.debug("Simulate recoverFileLease() at count=" + count + " for " + path);
        }
    });
    final LoadCounter loader = new LoadCounter();
    procStore.start(PROCEDURE_STORE_SLOTS);
    procStore.recoverLease();
    procStore.load(loader);
    assertEquals(procs.length, loader.getMaxProcId());
    assertEquals(1, loader.getRunnableCount());
    assertEquals(0, loader.getCompletedCount());
    assertEquals(0, loader.getCorruptedCount());
}
Also used : Path(org.apache.hadoop.fs.Path) TestProcedure(org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility.TestProcedure) FileStatus(org.apache.hadoop.fs.FileStatus) LoadCounter(org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility.LoadCounter) FileSystem(org.apache.hadoop.fs.FileSystem) FileNotFoundException(java.io.FileNotFoundException) Test(org.junit.Test)

Example 8 with TestProcedure

use of org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility.TestProcedure in project hbase by apache.

the class TestWALProcedureStore method trackersLoadedForAllOldLogs.

/**
   * Tests that tracker for all old logs are loaded back after procedure store is restarted.
   */
@Test
public void trackersLoadedForAllOldLogs() throws Exception {
    for (int i = 0; i <= 20; ++i) {
        procStore.insert(new TestProcedure(i), null);
        if (i > 0 && (i % 5) == 0) {
            LoadCounter loader = new LoadCounter();
            storeRestart(loader);
        }
    }
    assertEquals(5, procStore.getActiveLogs().size());
    for (int i = 0; i < procStore.getActiveLogs().size() - 1; ++i) {
        ProcedureStoreTracker tracker = procStore.getActiveLogs().get(i).getTracker();
        assertTrue(tracker != null && !tracker.isEmpty());
    }
}
Also used : TestProcedure(org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility.TestProcedure) LoadCounter(org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility.LoadCounter) ProcedureStoreTracker(org.apache.hadoop.hbase.procedure2.store.ProcedureStoreTracker) Test(org.junit.Test)

Example 9 with TestProcedure

use of org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility.TestProcedure in project hbase by apache.

the class TestWALProcedureStore method testLoadChildren.

@Test
public void testLoadChildren() throws Exception {
    TestProcedure a = new TestProcedure(1, 0);
    TestProcedure b = new TestProcedure(2, 1);
    TestProcedure c = new TestProcedure(3, 1);
    // INIT
    procStore.insert(a, null);
    // Run A first step
    a.addStackId(0);
    procStore.update(a);
    // Run A second step
    a.addStackId(1);
    procStore.insert(a, new Procedure[] { b, c });
    // Run B first step
    b.addStackId(2);
    procStore.update(b);
    // Run C first and last step
    c.addStackId(3);
    procStore.update(c);
    // Run B second setp
    b.addStackId(4);
    procStore.update(b);
    // back to A
    a.addStackId(5);
    a.setFinishedState();
    procStore.delete(a, new long[] { b.getProcId(), c.getProcId() });
    restartAndAssert(3, 0, 1, 0);
}
Also used : TestProcedure(org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility.TestProcedure) Test(org.junit.Test)

Example 10 with TestProcedure

use of org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility.TestProcedure in project hbase by apache.

the class TestWALProcedureStoreOnHDFS method testWalRollOnLowReplication.

@Test(timeout = 60000)
public void testWalRollOnLowReplication() throws Exception {
    initConfig(UTIL.getConfiguration());
    UTIL.getConfiguration().setInt("dfs.namenode.replication.min", 1);
    setup();
    try {
        int dnCount = 0;
        store.insert(new TestProcedure(1, -1), null);
        UTIL.getDFSCluster().restartDataNode(dnCount);
        for (long i = 2; i < 100; ++i) {
            store.insert(new TestProcedure(i, -1), null);
            waitForNumReplicas(3);
            Thread.sleep(100);
            if ((i % 30) == 0) {
                LOG.info("Restart Data Node");
                UTIL.getDFSCluster().restartDataNode(++dnCount % 3);
            }
        }
        assertTrue(store.isRunning());
    } finally {
        tearDown();
    }
}
Also used : TestProcedure(org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility.TestProcedure) Test(org.junit.Test)

Aggregations

TestProcedure (org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility.TestProcedure)16 Test (org.junit.Test)15 LoadCounter (org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility.LoadCounter)5 ProcedureStore (org.apache.hadoop.hbase.procedure2.store.ProcedureStore)4 IOException (java.io.IOException)3 FileStatus (org.apache.hadoop.fs.FileStatus)2 Procedure (org.apache.hadoop.hbase.procedure2.Procedure)2 ProcedureIterator (org.apache.hadoop.hbase.procedure2.store.ProcedureStore.ProcedureIterator)2 WALProcedureStore (org.apache.hadoop.hbase.procedure2.store.wal.WALProcedureStore)2 FileNotFoundException (java.io.FileNotFoundException)1 Random (java.util.Random)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 FileSystem (org.apache.hadoop.fs.FileSystem)1 Path (org.apache.hadoop.fs.Path)1 ProcedureInfo (org.apache.hadoop.hbase.ProcedureInfo)1 HMaster (org.apache.hadoop.hbase.master.HMaster)1 SequentialProcedure (org.apache.hadoop.hbase.procedure2.SequentialProcedure)1 ProcedureStoreTracker (org.apache.hadoop.hbase.procedure2.store.ProcedureStoreTracker)1 ProcedureProtos (org.apache.hadoop.hbase.shaded.protobuf.generated.ProcedureProtos)1