com.sleepycat.je.log.entry
Class INLogEntry

java.lang.Object
  extended by com.sleepycat.je.log.entry.INLogEntry
All Implemented Interfaces:
INContainingEntry, LogEntry, NodeLogEntry, java.lang.Cloneable

public class INLogEntry
extends java.lang.Object
implements LogEntry, NodeLogEntry, INContainingEntry

INLogEntry embodies all IN log entries. On disk, an IN log entry contains:

        IN
        database id
        obsolete LSN  -- in version 2
 


Constructor Summary
INLogEntry(java.lang.Class<? extends IN> INClass)
          Construct a log entry for reading.
INLogEntry(IN in)
          Construct a log entry for writing to the log.
 
Method Summary
 java.lang.Object clone()
           
 boolean countAsObsoleteWhenLogged()
          Returns true if this item should be counted as obsoleted when logged.
 java.lang.StringBuffer dumpEntry(java.lang.StringBuffer sb, boolean verbose)
          Print out the contents of an entry.
 DatabaseId getDbId()
          All node entries have a database ID.
 IN getIN(EnvironmentImpl env)
           
 int getLastLoggedSize()
          By default, return zero because the last logged size is unknown.
 LogEntryType getLogType()
           
 long getLsnOfIN(long lastReadLsn)
           
 java.lang.Object getMainItem()
           
 long getNodeId()
          Returns the node ID.
 long getObsoleteLsn()
          Returns the LSN of the prior version of this node.
 int getSize()
           
 long getTransactionId()
           
 boolean logicalEquals(LogEntry other)
           
 void postLogWork(long justLoggedLsn)
          Do any processing we need to do after logging, while under the logging latch.
 void readEntry(LogEntryHeader header, java.nio.ByteBuffer entryBuffer, boolean readFullItem)
          Read in an IN entry.
 void setLogType(LogEntryType entryType)
          Inform a BaseEntry instance of its corresponding LogEntryType.
 java.lang.String toString()
           
 void writeEntry(LogEntryHeader header, java.nio.ByteBuffer destBuffer)
          Serialize this object into the buffer.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.sleepycat.je.log.entry.LogEntry
countAsObsoleteWhenLogged, getLastLoggedSize, getLogType, postLogWork, setLogType
 

Constructor Detail

INLogEntry

public INLogEntry(java.lang.Class<? extends IN> INClass)
Construct a log entry for reading.


INLogEntry

public INLogEntry(IN in)
Construct a log entry for writing to the log.

Method Detail

readEntry

public void readEntry(LogEntryHeader header,
                      java.nio.ByteBuffer entryBuffer,
                      boolean readFullItem)
               throws DatabaseException
Read in an IN entry.

Specified by:
readEntry in interface LogEntry
Throws:
DatabaseException

getObsoleteLsn

public long getObsoleteLsn()
Returns the LSN of the prior version of this node. Used for counting the prior version as obsolete. If the offset of the LSN is zero, only the file number is known because we read a version 1 log entry.


dumpEntry

public java.lang.StringBuffer dumpEntry(java.lang.StringBuffer sb,
                                        boolean verbose)
Print out the contents of an entry.

Specified by:
dumpEntry in interface LogEntry

getMainItem

public java.lang.Object getMainItem()
Specified by:
getMainItem in interface LogEntry
Returns:
the item in the log entry

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Specified by:
clone in interface LogEntry
Overrides:
clone in class java.lang.Object
Returns:
a shallow clone.
Throws:
java.lang.CloneNotSupportedException

getTransactionId

public long getTransactionId()
Specified by:
getTransactionId in interface LogEntry
Returns:
return the transaction id if this log entry is transactional, 0 otherwise.
See Also:
LogEntry.getTransactionId()

getSize

public int getSize()
Specified by:
getSize in interface LogEntry
Returns:
size of byte buffer needed to store this entry.

writeEntry

public void writeEntry(LogEntryHeader header,
                       java.nio.ByteBuffer destBuffer)
Description copied from interface: LogEntry
Serialize this object into the buffer.

Specified by:
writeEntry in interface LogEntry
destBuffer - is the destination buffer
See Also:
LogEntry.writeEntry(com.sleepycat.je.log.LogEntryHeader, java.nio.ByteBuffer)

getIN

public IN getIN(EnvironmentImpl env)
         throws DatabaseException
Specified by:
getIN in interface INContainingEntry
Returns:
the IN held within this log entry.
Throws:
DatabaseException

getNodeId

public long getNodeId()
Description copied from interface: NodeLogEntry
Returns the node ID. This value is redundant with the main item (Node) of a log entry. It is returned separately so that it can be obtained when the entry's main item (Node) is not loaded. Partial loading is an optimization for recovery.

Specified by:
getNodeId in interface NodeLogEntry
See Also:
NodeLogEntry.getNodeId()

getDbId

public DatabaseId getDbId()
Description copied from interface: NodeLogEntry
All node entries have a database ID.

Specified by:
getDbId in interface INContainingEntry
Specified by:
getDbId in interface NodeLogEntry
Returns:
the database id held within this log entry.
See Also:
INContainingEntry.getDbId()

getLsnOfIN

public long getLsnOfIN(long lastReadLsn)
Specified by:
getLsnOfIN in interface INContainingEntry
Returns:
the LSN that represents this IN. For a vanilla IN entry, it's the last lsn read by the log reader.

logicalEquals

public boolean logicalEquals(LogEntry other)
Specified by:
logicalEquals in interface LogEntry
Returns:
true if these two log entries are logically the same. Used for replication.
See Also:
INs from two different environments are never considered equal, because they have lsns that are environment-specific.

setLogType

public void setLogType(LogEntryType entryType)
Inform a BaseEntry instance of its corresponding LogEntryType.


getLogType

public LogEntryType getLogType()
Returns:
the type of log entry

getLastLoggedSize

public int getLastLoggedSize()
By default, return zero because the last logged size is unknown. This method is overridden by LNLogEntry.


countAsObsoleteWhenLogged

public boolean countAsObsoleteWhenLogged()
Returns true if this item should be counted as obsoleted when logged. This currently applies to deleted LNs only.


postLogWork

public void postLogWork(long justLoggedLsn)
                 throws DatabaseException
Do any processing we need to do after logging, while under the logging latch.

Throws:
DatabaseException

toString

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