com.sleepycat.je.log
Class LogEntryHeader

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

public class LogEntryHeader
extends java.lang.Object

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


Field Summary
static int MAX_HEADER_SIZE
           
(package private) static int MIN_HEADER_SIZE
          Persistent fields.
 
Constructor Summary
LogEntryHeader(EnvironmentImpl envImpl, java.nio.ByteBuffer entryBuffer, boolean anticipateChecksumErrors)
          For reading a log entry.
LogEntryHeader(LogEntry entry, Provisional provisional, ReplicationContext repContext)
          For writing a log header.
 
Method Summary
 java.nio.ByteBuffer addPostMarshallingInfo(EnvironmentImpl envImpl, java.nio.ByteBuffer entryBuffer, long lastOffset, ReplicationContext repContext)
          Add those parts of the header that must be calculated later to the entryBuffer, and also assign the fields in this class.
(package private)  void convertCommitToAbort(java.nio.ByteBuffer entryBuffer)
          For use in special case where commits are transformed to aborts because of i/o errors during a logBuffer flush.
 void dumpLog(java.lang.StringBuffer sb, boolean verbose)
           
(package private)  void dumpLogNoTag(java.lang.StringBuffer sb, boolean verbose)
          Dump the header without enclosing
tags.
 long getChecksum()
           
(package private)  int getInvariantSizeMinusChecksum()
           
 int getItemSize()
           
 long getPrevOffset()
           
 Provisional getProvisional()
           
 boolean getReplicated()
           
 int getSize()
           
(package private)  int getSizeMinusChecksum()
           
 byte getType()
           
 int getVariablePortionSize()
           
 byte getVersion()
           
 VLSN getVLSN()
           
static VLSN getVLSN(java.nio.ByteBuffer buffer)
          Return the VLSN for the log entry header in this byte buffer.
static boolean isSyncPoint(java.nio.ByteBuffer buffer)
          Return whether the log entry represented by this byte buffer is a replication sync possible type log entry.
 boolean logicalEquals(LogEntryHeader other)
           
 void readVariablePortion(java.nio.ByteBuffer entryBuffer)
          Assumes this is called directly after the constructor, and that the entryBuffer is positioned right before the VLSN.
 java.lang.String toString()
           
 void writeToLog(java.nio.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, wait, wait, wait
 

Field Detail

MIN_HEADER_SIZE

static final int MIN_HEADER_SIZE
Persistent fields. Layout on disk is (invariant) checksum - 4 bytes (invariant) entry type - 1 byte (invariant) entry version and flags - 1 byte (invariant) offset of previous log entry - 4 bytes (invariant) item size (not counting header size) - 4 bytes (optional) vlsn - 8 bytes Flags: The provisional bit can be set for any log type in the log. It's an indication to recovery that the entry shouldn't be processed when rebuilding the tree. It's used to ensure the atomic logging of multiple entries. The replicated bit is set when this particular log entry is part of the replication stream and contains a VLSN in the header.

See Also:
Constant Field Values

MAX_HEADER_SIZE

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

LogEntryHeader

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

Parameters:
anticipateChecksumErrors - if true, invalidate the environment if the entry header is invalid.
Throws:
DbChecksumException - if the entry is invalid. If anticipateChecksumErrors is true and envImpl is not null, the environment is also invalidated.

LogEntryHeader

public LogEntryHeader(LogEntry entry,
                      Provisional provisional,
                      ReplicationContext repContext)
For writing a log header. public for unit tests.

Method Detail

getChecksum

public long getChecksum()

getType

public byte getType()

getVersion

public byte getVersion()

getPrevOffset

public long getPrevOffset()

getItemSize

public int getItemSize()

getVLSN

public VLSN getVLSN()

getReplicated

public boolean getReplicated()

getProvisional

public Provisional getProvisional()

getVariablePortionSize

public int getVariablePortionSize()

getSize

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

getSizeMinusChecksum

int getSizeMinusChecksum()
Returns:
the number of bytes used to store the header, excepting the checksum field.

getInvariantSizeMinusChecksum

int getInvariantSizeMinusChecksum()
Returns:
the number of bytes used to store the header, excepting the checksum field.

readVariablePortion

public void readVariablePortion(java.nio.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

public void writeToLog(java.nio.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. public for unit tests.


addPostMarshallingInfo

public java.nio.ByteBuffer addPostMarshallingInfo(EnvironmentImpl envImpl,
                                                  java.nio.ByteBuffer entryBuffer,
                                                  long lastOffset,
                                                  ReplicationContext repContext)
Add those parts of the header that must be calculated later to the entryBuffer, and also assign the fields in this class. 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 checksumVal, which must be added last, after all other fields are marshalled. (public for unit tests)


dumpLog

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

dumpLogNoTag

void dumpLogNoTag(java.lang.StringBuffer sb,
                  boolean verbose)
Dump the header without enclosing
tags. Used for DbPrintLog, to make the header attributes in the tag, for a more compact rendering.

Parameters:
sb - destination string buffer
verbose - if true, dump the full, verbose version

convertCommitToAbort

void convertCommitToAbort(java.nio.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.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

logicalEquals

public boolean logicalEquals(LogEntryHeader other)
Returns:
true if these two log headers are logically the same. Used for replication.

isSyncPoint

public static boolean isSyncPoint(java.nio.ByteBuffer buffer)
                           throws DbChecksumException
Return whether the log entry represented by this byte buffer is a replication sync possible type log entry. Leaves the byte buffer's position unchanged.

Throws:
DbChecksumException

getVLSN

public static VLSN getVLSN(java.nio.ByteBuffer buffer)
                    throws DatabaseException
Return the VLSN for the log entry header in this byte buffer. Leaves the byte buffer's position unchanged.

Throws:
DatabaseException


Copyright (c) 2004,2008 Oracle. All rights reserved.