@NotThreadSafe public final class UfsJournalReader extends Object implements JournalReader
JournalReader
that reads journal entries from a UFS. It can optionally
read after a given sequence number. By default, it starts from 0 sequence number.
If this reader runs in a primary master, it reads the incomplete log.
If this reader runs in a standby master, it does not read the incomplete log.JournalReader.State
Constructor and Description |
---|
UfsJournalReader(UfsJournal journal,
boolean readIncompleteLog)
Creates a new instance of
UfsJournalReader . |
UfsJournalReader(UfsJournal journal,
long startSequenceId,
boolean readIncompleteLog)
Creates a new instance of
UfsJournalReader . |
Modifier and Type | Method and Description |
---|---|
JournalReader.State |
advance()
Advances the reader to the next element.
|
void |
close() |
CheckpointInputStream |
getCheckpoint()
Returns the input stream for reading a checkpoint.
|
Journal.JournalEntry |
getEntry()
Returns the next entry in the journal.
|
static OptionalLong |
getLastSN(UfsJournal journal)
Iterates over the journal files searching for the greatest SN of all the files.
|
long |
getNextSequenceNumber()
Gets the the sequence number of the next journal log entry to read.
|
public UfsJournalReader(UfsJournal journal, boolean readIncompleteLog)
UfsJournalReader
.journal
- the handle to the journalreadIncompleteLog
- whether to read incomplete logspublic UfsJournalReader(UfsJournal journal, long startSequenceId, boolean readIncompleteLog)
UfsJournalReader
.journal
- the handle to the journalstartSequenceId
- the sequence ID to start reading fromreadIncompleteLog
- whether to read incomplete logspublic void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
public long getNextSequenceNumber()
JournalReader
getNextSequenceNumber
in interface JournalReader
public CheckpointInputStream getCheckpoint()
JournalReader
JournalReader.advance()
returned JournalReader.State.CHECKPOINT
.
Multiple calls to getCheckpoint without calling advance will return the same stream.getCheckpoint
in interface JournalReader
public Journal.JournalEntry getEntry()
JournalReader
JournalReader.advance()
returned JournalReader.State.LOG
.
Multiple calls to getEntry without calling advance will return the same entry.getEntry
in interface JournalReader
public JournalReader.State advance() throws IOException
JournalReader
advance
in interface JournalReader
JournalReader.State
IOException
public static OptionalLong getLastSN(UfsJournal journal)
journal
- the UFS journal to get the final sequence numberCopyright © 2023. All Rights Reserved.