com.sleepycat.je.log
Class FileReader

java.lang.Object
  extended by com.sleepycat.je.log.FileReader
Direct Known Subclasses:
CheckpointFileReader, CleanerFileReader, DumpFileReader, INFileReader, LastFileReader, LNFileReader, ScavengerFileReader, SearchFileReader

public abstract class FileReader
extends Object

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.


Field Summary
protected  boolean anticipateChecksumErrors
           
protected  ChecksumValidator cksumValidator
           
protected  long currentEntryChecksum
           
protected  long currentEntryOffset
           
protected  long currentEntryPrevOffset
           
protected  int currentEntrySize
           
protected  byte currentEntryTypeNum
           
protected  byte currentEntryTypeVersion
           
protected  EnvironmentImpl env
           
protected  boolean eof
           
protected  FileManager fileManager
           
protected  long nextEntryOffset
           
protected  long readBufferFileEnd
           
protected  long readBufferFileNum
           
protected  long readBufferFileStart
           
protected  long startLsn
           
 
Constructor Summary
FileReader(EnvironmentImpl env, 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
 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(byte logEntryTypeNumber, byte logEntryTypeVersion)
           
protected abstract  boolean processEntry(ByteBuffer entryBuffer)
          Each file reader implements this method to process the entry data.
 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 dumpCorruptedBounds)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

env

protected EnvironmentImpl env

fileManager

protected FileManager fileManager

eof

protected boolean eof

readBufferFileNum

protected long readBufferFileNum

readBufferFileStart

protected long readBufferFileStart

readBufferFileEnd

protected long readBufferFileEnd

currentEntryTypeNum

protected byte currentEntryTypeNum

currentEntryTypeVersion

protected byte currentEntryTypeVersion

currentEntryPrevOffset

protected long currentEntryPrevOffset

currentEntrySize

protected int currentEntrySize

currentEntryChecksum

protected long currentEntryChecksum

currentEntryOffset

protected long currentEntryOffset

nextEntryOffset

protected long nextEntryOffset

startLsn

protected long startLsn

cksumValidator

protected ChecksumValidator cksumValidator

anticipateChecksumErrors

protected boolean anticipateChecksumErrors
Constructor Detail

FileReader

public FileReader(EnvironmentImpl env,
                  int readBufferSize,
                  boolean forward,
                  long startLsn,
                  Long singleFileNumber,
                  long endOfFileLsn,
                  long finishLsn)
           throws IOException,
                  DatabaseException
A FileReader just needs to know what size chunks to read in.

Parameters:
endOfFileLsn - indicates the end of the log file
Throws:
IOException
DatabaseException
Method Detail

initStartingPosition

protected void initStartingPosition(long endOfFileLsn,
                                    Long ignoreSingleFileNumber)
                             throws IOException,
                                    DatabaseException
Helper for determining the starting position and opening up a file at the desired location.

Throws:
IOException
DatabaseException

getNumRead

public int getNumRead()
Returns:
the number of entries processed by this reader.

getNRepeatIteratorReads

public long getNRepeatIteratorReads()

getLastLsn

public long getLastLsn()
Get LSN of the last entry read.


readNextEntry

public boolean readNextEntry()
                      throws DatabaseException,
                             IOException
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.

Returns:
true if an element has been read
Throws:
DatabaseException
IOException

resyncReader

protected boolean resyncReader(long nextGoodRecordPostCorruption,
                               boolean dumpCorruptedBounds)
                        throws DatabaseException,
                               IOException
Throws:
DatabaseException
IOException

isTargetEntry

protected boolean isTargetEntry(byte logEntryTypeNumber,
                                byte logEntryTypeVersion)
                         throws DatabaseException
Returns:
true if this reader should process this entry, or just skip over it.
Throws:
DatabaseException

processEntry

protected abstract boolean processEntry(ByteBuffer entryBuffer)
                                 throws DatabaseException
Each file reader implements this method to process the entry data.

Parameters:
enteryBuffer - contains the entry data and is positioned at the data
Returns:
true if this entry should be returned
Throws:
DatabaseException


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