com.sleepycat.je.log
Class LNFileReader

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

public class LNFileReader
extends FileReader

LNFileReader scans log files for LNs. Also, if it's going backwards for the undo phase in recovery, it reads transaction commit entries.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.sleepycat.je.log.FileReader
FileReader.EOFException, FileReader.ReadWindow
 
Field Summary
protected  Map<LogEntryType,LogEntry> targetEntryMap
           
protected  LogEntry targetLogEntry
           
 
Fields inherited from class com.sleepycat.je.log.FileReader
cksumValidator, currentEntryHeader, currentEntryOffset, currentEntryPrevOffset, envImpl, eof, fileManager, forward, logger, nextEntryOffset, startLsn, window
 
Constructor Summary
LNFileReader(EnvironmentImpl env, int readBufferSize, long startLsn, boolean redo, long endOfFileLsn, long finishLsn, Long singleFileNum, long ckptEnd)
          Create this reader to start at a given LSN.
 
Method Summary
 void addTargetType(LogEntryType entryType)
           
 String dumpCurrentHeader()
           
 boolean getAbortKnownDeleted()
          Get last abort known deleted seen by the reader.
 long getAbortLsn()
          Get last abort LSN seen by the reader (may be null).
 DatabaseId getDatabaseId()
          Get the last databaseId seen by the reader.
 byte[] getDupTreeKey()
          Get the last key seen by the reader.
 byte[] getKey()
          Get the last key seen by the reader.
 LN getLN()
          Get the last LN seen by the reader.
 LNLogEntry getLogEntry()
           
 Object getMainItem()
           
 MapLN getMapLN()
          Returns a MapLN if the LN is a MapLN, or null otherwise.
 long getNodeId()
          Get node id of current LN.
 long getTxnAbortId()
          Get the last txn abort id seen by the reader.
 long getTxnCommitId()
          Get the last txn commit id seen by the reader.
 Long getTxnId()
           
 long getTxnPrepareId()
          Get the last txn prepare id seen by the reader.
 Xid getTxnPrepareXid()
          Get the last txn prepare Xid seen by the reader.
 boolean isAbort()
           
 boolean isCommit()
           
 boolean isInvisible()
           
 boolean isLN()
           
 boolean isPrepare()
           
 boolean isRollbackEnd()
           
 boolean isRollbackStart()
           
protected  boolean isTargetEntry()
           
protected  boolean processEntry(ByteBuffer entryBuffer)
          This reader instantiates an LN and key for every LN entry.
 
Methods inherited from class com.sleepycat.je.log.FileReader
entryIsReplicated, getAndResetNReads, getLastEntrySize, getLastLsn, getNRepeatIteratorReads, getNumRead, initStartingPosition, makeWindow, readNextEntry, 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
 

Field Detail

targetEntryMap

protected Map<LogEntryType,LogEntry> targetEntryMap

targetLogEntry

protected LogEntry targetLogEntry
Constructor Detail

LNFileReader

public LNFileReader(EnvironmentImpl env,
                    int readBufferSize,
                    long startLsn,
                    boolean redo,
                    long endOfFileLsn,
                    long finishLsn,
                    Long singleFileNum,
                    long ckptEnd)
             throws DatabaseException
Create this reader to start at a given LSN.

Parameters:
env - The relevant EnvironmentImpl
readBufferSize - buffer size in bytes for reading in log
startLsn - where to start in the log
redo - If true, we're going to go forward from the start LSN to the end of the log. If false, we're going backwards from the end of the log to the start LSN.
finishLsn - the last LSN to read in the log. May be null if we want to read to the end of the log.
endOfFileLsn - the virtual LSN that marks the end of the log. (The one off the end of the log). Only used if we're reading backwards. Different from the startLsn because the startLsn tells us where the beginning of the start entry is, but not the length/end of the start entry. May be null if we're going foward.
Throws:
DatabaseException
Method Detail

addTargetType

public void addTargetType(LogEntryType entryType)
                   throws DatabaseException
Throws:
DatabaseException

isTargetEntry

protected boolean isTargetEntry()
Overrides:
isTargetEntry in class FileReader
Returns:
true if this is a transactional LN or Locker Commit entry.

processEntry

protected boolean processEntry(ByteBuffer entryBuffer)
                        throws DatabaseException
This reader instantiates an LN and key for every LN 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
Throws:
DatabaseException

isLN

public boolean isLN()
Returns:
true if the last entry was an LN.

getLN

public LN getLN()
Get the last LN seen by the reader.


getMapLN

public MapLN getMapLN()
Returns a MapLN if the LN is a MapLN, or null otherwise.


getDatabaseId

public DatabaseId getDatabaseId()
Get the last databaseId seen by the reader.


getKey

public byte[] getKey()
Get the last key seen by the reader.


getDupTreeKey

public byte[] getDupTreeKey()
Get the last key seen by the reader.


getTxnId

public Long getTxnId()
Returns:
the transaction id of the current entry.

isPrepare

public boolean isPrepare()

getTxnPrepareId

public long getTxnPrepareId()
Get the last txn prepare id seen by the reader.


getTxnPrepareXid

public Xid getTxnPrepareXid()
Get the last txn prepare Xid seen by the reader.


isCommit

public boolean isCommit()

isRollbackStart

public boolean isRollbackStart()

isRollbackEnd

public boolean isRollbackEnd()

getMainItem

public Object getMainItem()

dumpCurrentHeader

public String dumpCurrentHeader()

isAbort

public boolean isAbort()

getTxnAbortId

public long getTxnAbortId()
Get the last txn abort id seen by the reader.


getTxnCommitId

public long getTxnCommitId()
Get the last txn commit id seen by the reader.


getNodeId

public long getNodeId()
Get node id of current LN.


getAbortLsn

public long getAbortLsn()
Get last abort LSN seen by the reader (may be null).


getAbortKnownDeleted

public boolean getAbortKnownDeleted()
Get last abort known deleted seen by the reader.


getLogEntry

public LNLogEntry getLogEntry()

isInvisible

public boolean isInvisible()


Copyright (c) 2004-2010 Oracle. All rights reserved.