use of alluxio.master.journal.JournalReader in project alluxio by Alluxio.
the class UfsJournalReaderTest method resumeReadingWithinCheckpoint.
/**
* Reads checkpoint and logs from a non-zero sequence number. The given sequence number is within
* the checkpoint.
*/
@Test
public void resumeReadingWithinCheckpoint() throws Exception {
long fileSize = 10;
buildCheckpoint(fileSize * 3);
for (int i = 0; i < 10; i++) {
buildCompletedLog(i * fileSize, (i + 1) * fileSize);
}
try (JournalReader reader = new UfsJournalReader(mJournal, fileSize * 2, true)) {
while (reader.advance() != State.DONE) {
}
assertEquals(10 * fileSize, reader.getNextSequenceNumber());
}
}
use of alluxio.master.journal.JournalReader in project alluxio by Alluxio.
the class UfsJournalReaderTest method readCheckpointAndLogsSnMatch.
/**
* Reads checkpoint and logs. The checkpoint's last sequence number matches one of
* the logs' sequence number.
*/
@Test
public void readCheckpointAndLogsSnMatch() throws Exception {
long fileSize = 10;
buildCheckpoint(fileSize * 3);
for (int i = 0; i < 10; i++) {
buildCompletedLog(i * fileSize, (i + 1) * fileSize);
}
try (JournalReader reader = mJournal.getReader(true)) {
while (reader.advance() != State.DONE) {
}
assertEquals(10 * fileSize, reader.getNextSequenceNumber());
}
}
use of alluxio.master.journal.JournalReader in project alluxio by Alluxio.
the class UfsJournalReaderTest method resumeReadingAfterCheckpoint.
/**
* Reads checkpoint and logs from a non-zero sequence number. The given sequence number is after
* the checkpoint.
*/
@Test
public void resumeReadingAfterCheckpoint() throws Exception {
long fileSize = 10;
buildCheckpoint(fileSize * 3);
for (int i = 0; i < 10; i++) {
buildCompletedLog(i * fileSize, (i + 1) * fileSize);
}
try (JournalReader reader = new UfsJournalReader(mJournal, fileSize * 3 + 1, true)) {
while (reader.advance() != State.DONE) {
}
assertEquals(10 * fileSize, reader.getNextSequenceNumber());
}
}
use of alluxio.master.journal.JournalReader in project alluxio by Alluxio.
the class UfsJournalReaderTest method readCompletedLog.
/**
* Reads completed logs.
*/
@Test
public void readCompletedLog() throws Exception {
long fileSize = 10;
long endSN = 10 * fileSize;
for (long i = 0; i < endSN / fileSize; i++) {
buildCompletedLog(i * fileSize, i * fileSize + fileSize);
}
try (JournalReader reader = mJournal.getReader(true)) {
int sn = 0;
while (reader.advance() != State.DONE) {
assertEquals(sn, reader.getEntry().getSequenceNumber());
sn++;
}
assertEquals(endSN, sn);
assertEquals(sn, reader.getNextSequenceNumber());
// Further advances should return State.DONE
assertEquals(State.DONE, reader.advance());
}
}
use of alluxio.master.journal.JournalReader in project alluxio by Alluxio.
the class UfsJournalReaderTest method readNewLogs.
/**
* Reads logs created while reading the journal.
*/
@Test
public void readNewLogs() throws Exception {
long endSN = 10;
buildCompletedLog(0, endSN);
try (JournalReader reader = mJournal.getReader(true)) {
int sn = 0;
while (reader.advance() != State.DONE) {
assertEquals(sn, reader.getEntry().getSequenceNumber());
sn++;
}
assertEquals(endSN, sn);
assertEquals(sn, reader.getNextSequenceNumber());
// Write another two logs.
buildCompletedLog(endSN, endSN * 2);
buildIncompleteLog(endSN * 2, endSN * 2 + 1);
while (reader.advance() != State.DONE) {
assertEquals(sn, reader.getEntry().getSequenceNumber());
sn++;
}
assertEquals(endSN * 2 + 1, sn);
assertEquals(sn, reader.getNextSequenceNumber());
}
}
Aggregations