public abstract class FileReader extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
FileReader.EOFException
Never seen by user, used to indicate that the file reader should stop.
|
protected static class |
FileReader.ReadWindow
A ReadWindow provides a swath of data read from the JE log.
|
| Modifier and Type | Field and Description |
|---|---|
protected ChecksumValidator |
cksumValidator |
protected LogEntryHeader |
currentEntryHeader |
protected long |
currentEntryOffset |
protected long |
currentEntryPrevOffset |
protected EnvironmentImpl |
envImpl |
protected boolean |
eof |
protected FileManager |
fileManager |
protected boolean |
forward |
protected Logger |
logger |
protected long |
nextEntryOffset |
protected long |
startLsn |
protected FileReader.ReadWindow |
window |
| Constructor and Description |
|---|
FileReader(EnvironmentImpl envImpl,
int readBufferSize,
boolean forward,
long startLsn,
Long singleFileNumber,
long endOfFileLsn,
long finishLsn) |
FileReader(EnvironmentImpl envImpl,
int readBufferSize,
boolean forward,
long startLsn,
Long singleFileNumber,
long endOfFileLsn,
long finishLsn,
boolean doChecksumOnRead) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
entryIsReplicated() |
int |
getAndResetNReads()
Returns the number of reads since the last time this method was called.
|
int |
getLastEntrySize()
Returns the total size (including header) of the last entry read.
|
long |
getLastLsn()
Get LSN of the last entry read.
|
VLSN |
getLastVlsn()
Returns the VLSN of the last entry read, or null if the entry has no
VLSN (not replicated and has no migrated VLSN).
|
int |
getLogVersion()
Returns the log version of the last entry read.
|
long |
getNRepeatIteratorReads() |
int |
getNumRead() |
protected void |
handleGapInBackwardsScan(long prevFileNum)
TBW
|
protected void |
initStartingPosition(long endOfFileLsn,
Long ignoreSingleFileNumber)
Helper for determining the starting position and opening up a file at
the desired location.
|
protected boolean |
isTargetEntry()
This method is called by readNextEntry() after the header of the current
logrec has been de-serialized, but not the body.
|
protected FileReader.ReadWindow |
makeWindow(int readBufferSize)
May be overridden by other FileReaders.
|
protected abstract boolean |
processEntry(ByteBuffer entryBuffer)
Each file reader implements this method to process the entry data.
|
boolean |
readNextEntry()
Scans the log files until either it has reached the end of the log or
has hit an invalid portion.
|
boolean |
readNextEntryAllowExceptions()
Variant of readNextEntry that throws FileNotFoundException and
ChecksumException, rather than wrapping them in an
EnvironmentFailureException and invalidating the enviornment.
|
void |
setAlwaysValidateChecksum(boolean validate)
Whether to always validate the checksum, even for non-target entries.
|
protected void |
setBackwardPosition()
Ensure that the next target is in the window.
|
protected void |
setForwardPosition()
Ensure that the next target is in the window.
|
void |
skipData(int amountToSkip) |
protected void |
skipEntry(ByteBuffer entryBuffer)
May be called by processEntry when it determines that the entry does not
need to be read/de-serialized.
|
protected final EnvironmentImpl envImpl
protected final FileManager fileManager
protected final FileReader.ReadWindow window
protected boolean eof
protected final boolean forward
protected LogEntryHeader currentEntryHeader
protected long currentEntryPrevOffset
protected long currentEntryOffset
protected long nextEntryOffset
protected long startLsn
protected ChecksumValidator cksumValidator
protected final Logger logger
public FileReader(EnvironmentImpl envImpl, int readBufferSize, boolean forward, long startLsn, Long singleFileNumber, long endOfFileLsn, long finishLsn) throws DatabaseException
DatabaseExceptionpublic FileReader(EnvironmentImpl envImpl, int readBufferSize, boolean forward, long startLsn, Long singleFileNumber, long endOfFileLsn, long finishLsn, boolean doChecksumOnRead) throws DatabaseException
DatabaseExceptionprotected FileReader.ReadWindow makeWindow(int readBufferSize) throws DatabaseException
DatabaseExceptionprotected void initStartingPosition(long endOfFileLsn,
Long ignoreSingleFileNumber)
public void setAlwaysValidateChecksum(boolean validate)
public int getNumRead()
public long getNRepeatIteratorReads()
public long getLastLsn()
public VLSN getLastVlsn()
public int getLastEntrySize()
public int getLogVersion()
public boolean readNextEntry()
EnvironmentFailureException - if a ChecksumException,
FileNotFoundException, or another internal problem occurs.public final boolean readNextEntryAllowExceptions()
throws FileNotFoundException,
ChecksumException
protected void skipEntry(ByteBuffer entryBuffer)
protected void setForwardPosition()
throws FileReader.EOFException,
DatabaseException,
ChecksumException,
FileNotFoundException
protected void setBackwardPosition()
throws ChecksumException,
FileNotFoundException,
FileReader.EOFException,
DatabaseException
public void skipData(int amountToSkip)
throws ChecksumException,
FileReader.EOFException,
FileNotFoundException,
DatabaseException
public int getAndResetNReads()
protected boolean isTargetEntry()
throws DatabaseException
DatabaseException - from subclasses.protected abstract boolean processEntry(ByteBuffer entryBuffer) throws DatabaseException
entryBuffer - A ByteBuffer that the logrec data and is positioned
at the start of the logrec body (i.e., just after the logrec header).DatabaseExceptionpublic boolean entryIsReplicated()
protected void handleGapInBackwardsScan(long prevFileNum)
Copyright © 2024. All rights reserved.