com.sleepycat.je.log
Class LogEntryHeader

java.lang.Object
  extended by com.sleepycat.je.log.LogEntryHeader

public class LogEntryHeader
extends Object

A LogEntryHeader embodies the header information at the beginning of each log entry file.


Field Summary
(package private) static int MAX_HEADER_SIZE
           
(package private) static int MIN_HEADER_SIZE
          Persistent fields.
 
Constructor Summary
LogEntryHeader(EnvironmentImpl envImpl, ByteBuffer entryBuffer, boolean anticipateChecksumErrors)
          For reading a log entry.
LogEntryHeader(LogEntry entry, boolean isProvisional, boolean replicate)
          For writing a log header.
 
Method Summary
(package private)  ByteBuffer addPostMarshallingInfo(EnvironmentImpl envImpl, ByteBuffer entryBuffer, long lastOffset)
          Add those parts of the header that must be calculated later.
(package private)  void convertCommitToAbort(ByteBuffer entryBuffer)
          For use in special case where commits are transformed to aborts because of i/o errors during a logBuffer flush.
 void dumpLog(StringBuffer sb, boolean verbose)
           
(package private)  long getChecksum()
           
 int getItemSize()
           
(package private)  long getPrevOffset()
           
 boolean getReplicate()
           
 int getSize()
           
(package private)  int getSizeMinusChecksum()
           
 byte getType()
           
(package private)  int getVariablePortionSize()
           
 byte getVersion()
           
(package private)  void readVariablePortion(ByteBuffer entryBuffer)
          Assumes this is called directly after the constructor, and that the entryBuffer is positioned right before the VLSN.
(package private)  void writeToLog(ByteBuffer entryBuffer)
          Serialize this object into the buffer and leave the buffer positioned in the right place to write the following item.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MIN_HEADER_SIZE

static final int MIN_HEADER_SIZE
Persistent fields. Layout on disk is checksum - 4 bytes entry type - 1 byte entry version and flags - 1 byte offset of previous log entry - 4 bytes item size (not counting header size) - 4 bytes vlsn (optional) - 16 bytes

See Also:
Constant Field Values

MAX_HEADER_SIZE

static final int MAX_HEADER_SIZE
See Also:
Constant Field Values
Constructor Detail

LogEntryHeader

public LogEntryHeader(EnvironmentImpl envImpl,
                      ByteBuffer entryBuffer,
                      boolean anticipateChecksumErrors)
               throws DatabaseException
For reading a log entry.

Throws:
DatabaseException

LogEntryHeader

LogEntryHeader(LogEntry entry,
               boolean isProvisional,
               boolean replicate)
For writing a log header.

Method Detail

getChecksum

long getChecksum()

getType

public byte getType()

getVersion

public byte getVersion()

getPrevOffset

long getPrevOffset()

getItemSize

public int getItemSize()

getReplicate

public boolean getReplicate()

getVariablePortionSize

int getVariablePortionSize()

getSize

public int getSize()
Returns:
number of bytes used to store this header

getSizeMinusChecksum

int getSizeMinusChecksum()

readVariablePortion

void readVariablePortion(ByteBuffer entryBuffer)
                   throws LogException
Assumes this is called directly after the constructor, and that the entryBuffer is positioned right before the VLSN.

Throws:
LogException

writeToLog

void writeToLog(ByteBuffer entryBuffer)
Serialize this object into the buffer and leave the buffer positioned in the right place to write the following item. The checksum, prevEntry, and vlsn values will filled in later on.


addPostMarshallingInfo

ByteBuffer addPostMarshallingInfo(EnvironmentImpl envImpl,
                                  ByteBuffer entryBuffer,
                                  long lastOffset)
Add those parts of the header that must be calculated later. That's - the prev offset, which must be done within the log write latch to be sure what that lsn is - the VLSN, for the same reason - the checksum, which must be added last, after all other fields are marshalled.


dumpLog

public void dumpLog(StringBuffer sb,
                    boolean verbose)
Parameters:
sb - destination string buffer
verbose - if true, dump the full, verbose version

convertCommitToAbort

void convertCommitToAbort(ByteBuffer entryBuffer)
For use in special case where commits are transformed to aborts because of i/o errors during a logBuffer flush. See [11271]. Assumes that the entryBuffer is positioned at the start of the item. Return with the entryBuffer positioned to the end of the log entry.



Copyright 2004,2008 Oracle. All rights reserved.