public abstract class FileReader
extends java.lang.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 swathe 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 java.util.logging.Logger |
logger |
protected long |
nextEntryOffset |
protected long |
startLsn |
protected FileReader.ReadWindow |
window |
Constructor and Description |
---|
FileReader(EnvironmentImpl envImpl,
int readBufferSize,
boolean forward,
long startLsn,
java.lang.Long singleFileNumber,
long endOfFileLsn,
long finishLsn)
A FileReader just needs to know what size chunks to read in.
|
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.
|
long |
getNRepeatIteratorReads() |
int |
getNumRead() |
protected void |
initStartingPosition(long endOfFileLsn,
java.lang.Long ignoreSingleFileNumber)
Helper for determining the starting position and opening up a file at
the desired location.
|
protected boolean |
isTargetEntry() |
protected FileReader.ReadWindow |
makeWindow(int readBufferSize)
May be overridden by other FileReaders.
|
protected abstract boolean |
processEntry(java.nio.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.
|
protected boolean |
resyncReader(long nextGoodRecordPostCorruption,
boolean dumpCorruptedBounds) |
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(java.nio.ByteBuffer entryBuffer)
May be called by processEntry when it determines that the entry does not
need to be read/de-serialized.
|
(package private) static java.nio.Buffer |
threadSafeBufferFlip(java.nio.ByteBuffer buffer)
Note that we catch Exception here because it is possible that
another thread is modifying the state of buffer simultaneously.
|
(package private) static int |
threadSafeBufferPosition(java.nio.ByteBuffer buffer) |
(package private) static java.nio.Buffer |
threadSafeBufferPosition(java.nio.ByteBuffer buffer,
int newPosition) |
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 java.util.logging.Logger logger
public FileReader(EnvironmentImpl envImpl, int readBufferSize, boolean forward, long startLsn, java.lang.Long singleFileNumber, long endOfFileLsn, long finishLsn) throws DatabaseException
endOfFileLsn
- indicates the end of the log fileDatabaseException
protected FileReader.ReadWindow makeWindow(int readBufferSize) throws DatabaseException
DatabaseException
protected void initStartingPosition(long endOfFileLsn, java.lang.Long ignoreSingleFileNumber)
public void setAlwaysValidateChecksum(boolean validate)
public int getNumRead()
public long getNRepeatIteratorReads()
public long getLastLsn()
public int getLastEntrySize()
public boolean readNextEntry()
EnvironmentFailureException
- if a ChecksumException,
FileNotFoundException, or another internal problem occurs.public final boolean readNextEntryAllowExceptions() throws java.io.FileNotFoundException, ChecksumException
java.io.FileNotFoundException
ChecksumException
protected void skipEntry(java.nio.ByteBuffer entryBuffer)
protected boolean resyncReader(long nextGoodRecordPostCorruption, boolean dumpCorruptedBounds) throws DatabaseException
DatabaseException
protected void setForwardPosition() throws FileReader.EOFException, DatabaseException, ChecksumException, java.io.FileNotFoundException
DatabaseException
java.io.FileNotFoundException
ChecksumException
FileReader.EOFException
protected void setBackwardPosition() throws ChecksumException, java.io.FileNotFoundException, FileReader.EOFException, DatabaseException
DatabaseException
ChecksumException
java.io.FileNotFoundException
FileReader.EOFException
public void skipData(int amountToSkip) throws ChecksumException, FileReader.EOFException, java.io.FileNotFoundException, DatabaseException
ChecksumException
FileReader.EOFException
java.io.FileNotFoundException
DatabaseException
public int getAndResetNReads()
protected boolean isTargetEntry() throws DatabaseException
DatabaseException
- from subclasses.protected abstract boolean processEntry(java.nio.ByteBuffer entryBuffer) throws DatabaseException
entryBuffer
- contains the entry data and is positioned at the
dataDatabaseException
public boolean entryIsReplicated()
static java.nio.Buffer threadSafeBufferFlip(java.nio.ByteBuffer buffer)
static int threadSafeBufferPosition(java.nio.ByteBuffer buffer)
static java.nio.Buffer threadSafeBufferPosition(java.nio.ByteBuffer buffer, int newPosition)
Copyright (c) 2004-2012 Oracle. All rights reserved.