use of alluxio.master.MockMaster in project alluxio by Alluxio.
the class UfsJournalCheckpointThreadTest method catchupState.
/**
* Makes sure the catchup state get updated.
*/
@Test
public void catchupState() throws Exception {
ServerConfiguration.set(PropertyKey.MASTER_JOURNAL_CHECKPOINT_PERIOD_ENTRIES, "15");
ServerConfiguration.set(PropertyKey.MASTER_JOURNAL_TAILER_SLEEP_TIME_MS, "200ms");
buildCompletedLog(0, 10);
buildIncompleteLog(10, 15);
MockMaster mockMaster = new MockMaster();
UfsJournalCheckpointThread checkpointThread = new UfsJournalCheckpointThread(mockMaster, mJournal, Collections::emptySet);
Assert.assertEquals(UfsJournalCheckpointThread.CatchupState.NOT_STARTED, checkpointThread.getCatchupState());
checkpointThread.start();
CommonUtils.waitFor("catchup done", () -> checkpointThread.getCatchupState() == UfsJournalCheckpointThread.CatchupState.DONE, WaitForOptions.defaults().setTimeoutMs(6000));
checkpointThread.awaitTermination(true);
Assert.assertEquals(10, checkpointThread.getNextSequenceNumber());
}
use of alluxio.master.MockMaster in project alluxio by Alluxio.
the class UfsJournalCheckpointThreadTest method catchStateShutdown.
/**
* Makes sure the replay state get updated if shutdown.
*/
@Test
public void catchStateShutdown() throws Exception {
ServerConfiguration.set(PropertyKey.MASTER_JOURNAL_CHECKPOINT_PERIOD_ENTRIES, "15");
ServerConfiguration.set(PropertyKey.MASTER_JOURNAL_TAILER_SLEEP_TIME_MS, "200ms");
buildCompletedLog(0, 10);
buildIncompleteLog(10, 15);
MockMaster mockMaster = new MockMaster();
UfsJournalCheckpointThread checkpointThread = new UfsJournalCheckpointThread(mockMaster, mJournal, Collections::emptySet);
Assert.assertEquals(UfsJournalCheckpointThread.CatchupState.NOT_STARTED, checkpointThread.getCatchupState());
checkpointThread.start();
checkpointThread.awaitTermination(true);
Assert.assertEquals(UfsJournalCheckpointThread.CatchupState.DONE, checkpointThread.getCatchupState());
}
use of alluxio.master.MockMaster in project alluxio by Alluxio.
the class UfsJournalCheckpointThreadTest method checkpointAfterShutdown.
/**
* The checkpoint thread replays all the logs before shutting down.
*/
@Test
public void checkpointAfterShutdown() throws Exception {
ServerConfiguration.set(PropertyKey.MASTER_JOURNAL_CHECKPOINT_PERIOD_ENTRIES, "2");
buildCompletedLog(0, 10);
buildIncompleteLog(10, 15);
MockMaster mockMaster = new MockMaster();
UfsJournalCheckpointThread checkpointThread = new UfsJournalCheckpointThread(mockMaster, mJournal, Collections::emptySet);
checkpointThread.start();
checkpointThread.awaitTermination(true);
Assert.assertEquals(UfsJournalCheckpointThread.CatchupState.DONE, checkpointThread.getCatchupState());
// Make sure all the journal entries have been processed. Note that it is not necessary that
// the they are checkpointed.
CloseableIterator<Journal.JournalEntry> it = mockMaster.getJournalEntryIterator();
Assert.assertEquals(10, Iterators.size(it.get()));
}
use of alluxio.master.MockMaster in project alluxio by Alluxio.
the class UfsJournalCheckpointThreadTest method checkpointBeforeShutdown.
/**
* The checkpoint thread replays all the logs and checkpoints periodically if not shutdown.
*/
@Test
public void checkpointBeforeShutdown() throws Exception {
ServerConfiguration.set(PropertyKey.MASTER_JOURNAL_CHECKPOINT_PERIOD_ENTRIES, "2");
buildCompletedLog(0, 10);
buildIncompleteLog(10, 15);
MockMaster mockMaster = new MockMaster();
UfsJournalCheckpointThread checkpointThread = new UfsJournalCheckpointThread(mockMaster, mJournal, Collections::emptySet);
checkpointThread.start();
CommonUtils.waitFor("checkpoint", () -> {
try {
UfsJournalSnapshot snapshot = UfsJournalSnapshot.getSnapshot(mJournal);
if (!snapshot.getCheckpoints().isEmpty() && snapshot.getCheckpoints().get(snapshot.getCheckpoints().size() - 1).getEnd() == 10) {
return true;
}
} catch (IOException e) {
return false;
}
return false;
}, WaitForOptions.defaults().setTimeoutMs(20000));
Assert.assertEquals(UfsJournalCheckpointThread.CatchupState.DONE, checkpointThread.getCatchupState());
UfsJournalSnapshot snapshot = UfsJournalSnapshot.getSnapshot(mJournal);
Assert.assertEquals(1, snapshot.getCheckpoints().size());
Assert.assertEquals(10, snapshot.getCheckpoints().get(0).getEnd());
checkpointThread.awaitTermination(true);
}
Aggregations