Search in sources :

Example 1 with State

use of alluxio.master.journal.JournalReader.State in project alluxio by Alluxio.

the class UfsJournalReaderTest method readCheckpoint.

/**
 * Reads checkpoint.
 */
@Test
public void readCheckpoint() throws Exception {
    long endSN = CHECKPOINT_SIZE;
    byte[] checkpointBytes = buildCheckpoint(endSN);
    try (JournalReader reader = mJournal.getReader(true)) {
        State state;
        boolean foundCheckpoint = false;
        while ((state = reader.advance()) != State.DONE) {
            switch(state) {
                case CHECKPOINT:
                    foundCheckpoint = true;
                    assertArrayEquals(checkpointBytes, IOUtils.toByteArray(reader.getCheckpoint()));
                    break;
                case LOG:
                case DONE:
                default:
                    throw new IllegalStateException("Unexpected state: " + state);
            }
        }
        assertTrue(foundCheckpoint);
        assertEquals(endSN, reader.getNextSequenceNumber());
    }
}
Also used : State(alluxio.master.journal.JournalReader.State) JournalReader(alluxio.master.journal.JournalReader) Test(org.junit.Test)

Aggregations

JournalReader (alluxio.master.journal.JournalReader)1 State (alluxio.master.journal.JournalReader.State)1 Test (org.junit.Test)1