com.sleepycat.je.log
Class ScavengerFileReader

java.lang.Object
  extended by com.sleepycat.je.log.FileReader
      extended by com.sleepycat.je.log.ScavengerFileReader

public abstract class ScavengerFileReader
extends FileReader

A ScavengerFileReader reads the log backwards. If it encounters a checksum error, it goes to the start of that log file and reads forward until it encounters a checksum error. It then continues the reading backwards in the log. The caller may set "dumpCorruptedBounds" to true if information about the start and finish of the corrupted portion should be displayed on stderr. The caller is expected to implement processEntryCallback. This method is called once for each entry that the ScavengerFileReader finds in the log.


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
ScavengerFileReader(EnvironmentImpl env, int readBufferSize, long startLsn, long finishLsn, long endOfFileLsn)
          Create this reader to start at a given LSN.
 
Method Summary
protected  boolean isTargetEntry(byte logEntryTypeNumber, byte logEntryTypeVersion)
           
protected  boolean processEntry(ByteBuffer entryBuffer)
          Each file reader implements this method to process the entry data.
protected abstract  void processEntryCallback(LogEntry entry, LogEntryType entryType)
           
 boolean readNextEntry()
          readNextEntry scans the log files until either it's reached the end of the log or has hit an invalid portion.
protected  boolean resyncReader(long nextGoodRecordPostCorruption, boolean showCorruptedBounds)
           
 void setDumpCorruptedBounds(boolean dumpCorruptedBounds)
          Set to true if corrupted boundaries should be dumped to stderr.
 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, initStartingPosition
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScavengerFileReader

public ScavengerFileReader(EnvironmentImpl env,
                           int readBufferSize,
                           long startLsn,
                           long finishLsn,
                           long endOfFileLsn)
                    throws IOException,
                           DatabaseException
Create this reader to start at a given LSN.

Throws:
IOException
DatabaseException
Method Detail

setDumpCorruptedBounds

public void setDumpCorruptedBounds(boolean dumpCorruptedBounds)
Set to true if corrupted boundaries should be dumped to stderr.


setTargetType

public void setTargetType(LogEntryType type)
Tell the reader that we are interested in these kind of entries.


processEntry

protected boolean processEntry(ByteBuffer entryBuffer)
                        throws DatabaseException
Description copied from class: FileReader
Each file reader implements this method to process the entry data.

Specified by:
processEntry in class FileReader
Returns:
true if this entry should be returned
Throws:
DatabaseException

processEntryCallback

protected abstract void processEntryCallback(LogEntry entry,
                                             LogEntryType entryType)
                                      throws DatabaseException
Throws:
DatabaseException

readNextEntry

public boolean readNextEntry()
                      throws DatabaseException,
                             IOException
Description copied from class: FileReader
readNextEntry scans the log files until either it's reached the end of the log or has hit an invalid portion. It then returns false.

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

resyncReader

protected boolean resyncReader(long nextGoodRecordPostCorruption,
                               boolean showCorruptedBounds)
                        throws DatabaseException,
                               IOException
Overrides:
resyncReader in class FileReader
Throws:
DatabaseException
IOException

isTargetEntry

protected boolean isTargetEntry(byte logEntryTypeNumber,
                                byte logEntryTypeVersion)
Overrides:
isTargetEntry in class FileReader
Returns:
true if this reader should process this entry, or just skip over it.


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