com.sleepycat.je.log
Class LastFileReader

java.lang.Object
  extended by com.sleepycat.je.log.FileReader
      extended by 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 targetted entry types.


Field Summary
 
Fields inherited from class com.sleepycat.je.log.FileReader
anticipateChecksumErrors, cksumValidator, currentEntryChecksum, currentEntryOffset, currentEntryPrevOffset, currentEntrySize, currentEntryTypeNum, currentEntryTypeVersion, env, eof, fileManager, nextEntryOffset, readBufferFileEnd, readBufferFileNum, readBufferFileStart, startLsn
 
Constructor Summary
LastFileReader(EnvironmentImpl env, int readBufferSize)
          This file reader is always positioned at the last file.
LastFileReader(EnvironmentImpl env, int readBufferSize, Long specificFileNumber)
          Ctor which allows passing in the file number we want to read to the end of.
 
Method Summary
 long getEndOfLog()
           
 LogEntryType getEntryType()
           
 long getLastSeen(LogEntryType type)
           
 long getLastValidLsn()
           
 long getPrevOffset()
           
protected  void initStartingPosition(long endOfFileLsn, Long singleFileNum)
          Override so that we always start at the last file.
protected  boolean processEntry(ByteBuffer entryBuffer)
          Validate the checksum on each entry, see if we should remember the LSN of this entry.
 boolean readNextEntry()
          readNextEntry will stop at a bad entry.
 void setEndOfFile()
           
 void setTargetType(LogEntryType type)
          Tell the reader that we are interested in these kind of entries.
 
Methods inherited from class com.sleepycat.je.log.FileReader
getLastLsn, getNRepeatIteratorReads, getNumRead, isTargetEntry, resyncReader
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LastFileReader

public LastFileReader(EnvironmentImpl env,
                      int readBufferSize)
               throws IOException,
                      DatabaseException
This file reader is always positioned at the last file.

Throws:
IOException
DatabaseException

LastFileReader

public LastFileReader(EnvironmentImpl env,
                      int readBufferSize,
                      Long specificFileNumber)
               throws IOException,
                      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:
IOException
DatabaseException
Method Detail

initStartingPosition

protected void initStartingPosition(long endOfFileLsn,
                                    Long singleFileNum)
                             throws IOException,
                                    DatabaseException
Override so that we always start at the last file.

Overrides:
initStartingPosition in class FileReader
Throws:
IOException
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
Returns:
true if this entry should be returned

readNextEntry

public boolean readNextEntry()
                      throws DatabaseException,
                             IOException
readNextEntry will stop at a bad entry.

Overrides:
readNextEntry in class FileReader
Returns:
true if an element has been read.
Throws:
DatabaseException
IOException


Copyright 2004-2005 Sleepycat, Inc. All Rights Reserved.