com.sleepycat.je.log
Class LastFileReader
java.lang.Object
com.sleepycat.je.log.FileReader
com.sleepycat.je.log.LastFileReader
public class LastFileReader
- extends FileReader
LastFileReader traverses the last log file, doing checksums and looking for
the end of the log. Different log types can be registered with it and it
will remember the last occurrence of targeted entry types.
Fields inherited from class com.sleepycat.je.log.FileReader |
cksumValidator, currentEntryHeader, currentEntryOffset, currentEntryPrevOffset, envImpl, eof, fileManager, forward, logger, nextEntryOffset, startLsn, window |
Methods inherited from class com.sleepycat.je.log.FileReader |
entryIsReplicated, getAndResetNReads, getLastEntrySize, getLastLsn, getNRepeatIteratorReads, getNumRead, initStartingPosition, isTargetEntry, makeWindow, readNextEntryAllowExceptions, resyncReader, setAlwaysValidateChecksum, setBackwardPosition, setForwardPosition, threadSafeBufferFlip, threadSafeBufferPosition, threadSafeBufferPosition |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
LastFileReader
public LastFileReader(EnvironmentImpl envImpl,
int readBufferSize)
throws DatabaseException
- This file reader is always positioned at the last file.
If no valid files exist (and invalid files do not contain data and can
be moved away), we will not throw an exception. We will return false
from the first call (all calls) to readNextEntry.
- Throws:
DatabaseException
- if the last file contains data and is invalid.
LastFileReader
LastFileReader(EnvironmentImpl envImpl,
int readBufferSize,
Long specificFileNumber)
throws ChecksumException,
DatabaseException
- Ctor which allows passing in the file number we want to read to the end
of. This is used by the ScavengerFileReader when it encounters a bad
log record in the middle of a file.
- Throws:
ChecksumException
- rather than wrapping it, to allow
ScavengerFileReader to handle it specially -- we should not invalidate
the environment with EnvironmentFailureException.
DatabaseException
setEndOfFile
public void setEndOfFile()
throws IOException,
DatabaseException
- Throws:
IOException
DatabaseException
getEndOfLog
public long getEndOfLog()
- Returns:
- The LSN to be used for the next log entry.
getLastValidLsn
public long getLastValidLsn()
getPrevOffset
public long getPrevOffset()
getEntryType
public LogEntryType getEntryType()
setTargetType
public void setTargetType(LogEntryType type)
- Tell the reader that we are interested in these kind of entries.
getLastSeen
public long getLastSeen(LogEntryType type)
- Returns:
- The last LSN seen in the log for this kind of entry, or null.
processEntry
protected boolean processEntry(ByteBuffer entryBuffer)
- Validate the checksum on each entry, see if we should remember the LSN
of this entry.
- Specified by:
processEntry
in class FileReader
- Parameters:
entryBuffer
- contains the entry data and is positioned at the
data
- Returns:
- true if this entry should be returned
readNextEntry
public boolean readNextEntry()
- readNextEntry will stop at a bad entry.
- Overrides:
readNextEntry
in class FileReader
- Returns:
- true if an element has been read.
Copyright (c) 2004-2010 Oracle. All rights reserved.