|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sleepycat.je.log.FileReader
public abstract class FileReader
A FileReader is an abstract class that traverses the log files, reading in chunks of the file at a time. Concrete subclasses perform a particular action to each entry.
Nested Class Summary | |
---|---|
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. |
Field Summary | |
---|---|
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 Summary | |
---|---|
FileReader(EnvironmentImpl envImpl,
int readBufferSize,
boolean forward,
long startLsn,
Long singleFileNumber,
long endOfFileLsn,
long finishLsn)
A FileReader just needs to know what size chunks to read in. |
Method Summary | |
---|---|
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,
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(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. |
(package private) static Buffer |
threadSafeBufferFlip(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(ByteBuffer buffer)
|
(package private) static Buffer |
threadSafeBufferPosition(ByteBuffer buffer,
int newPosition)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
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
Constructor Detail |
---|
public FileReader(EnvironmentImpl envImpl, int readBufferSize, boolean forward, long startLsn, Long singleFileNumber, long endOfFileLsn, long finishLsn) throws DatabaseException
endOfFileLsn
- indicates the end of the log file
DatabaseException
Method Detail |
---|
protected FileReader.ReadWindow makeWindow(int readBufferSize) throws DatabaseException
DatabaseException
protected void initStartingPosition(long endOfFileLsn, 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 FileNotFoundException, ChecksumException
FileNotFoundException
ChecksumException
protected boolean resyncReader(long nextGoodRecordPostCorruption, boolean dumpCorruptedBounds) throws DatabaseException
DatabaseException
protected void setForwardPosition() throws FileReader.EOFException, DatabaseException, ChecksumException, FileNotFoundException
DatabaseException
FileNotFoundException
ChecksumException
FileReader.EOFException
protected void setBackwardPosition() throws ChecksumException, FileNotFoundException, FileReader.EOFException, DatabaseException
DatabaseException
ChecksumException
FileNotFoundException
FileReader.EOFException
public int getAndResetNReads()
protected boolean isTargetEntry() throws DatabaseException
DatabaseException
- from subclasses.protected abstract boolean processEntry(ByteBuffer entryBuffer) throws DatabaseException
entryBuffer
- contains the entry data and is positioned at the
data
DatabaseException
public boolean entryIsReplicated()
static Buffer threadSafeBufferFlip(ByteBuffer buffer)
static int threadSafeBufferPosition(ByteBuffer buffer)
static Buffer threadSafeBufferPosition(ByteBuffer buffer, int newPosition)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |