com.sleepycat.je.log.entry
Class LNLogEntry

java.lang.Object
  extended by com.sleepycat.je.log.entry.BaseEntry
      extended by com.sleepycat.je.log.entry.LNLogEntry
All Implemented Interfaces:
LogEntry, Cloneable
Direct Known Subclasses:
DeletedDupLNLogEntry, NameLNLogEntry

public class LNLogEntry
extends BaseEntry
implements LogEntry

LNLogEntry embodies all LN log entries. On disk, an LN log entry contains (pre version 6)

   LN
   databaseid
   key
   abortLsn          -- if transactional
   abortKnownDeleted -- if transactional
   txn               -- if transactional

 (version 6)
   databaseid
   abortLsn          -- if transactional
   abortKnownDeleted -- if transactional
   txn               -- if transactional
   LN
   key
 
Before version 6, a non-full-item read of a log entry only retrieved the node ID. After version 6, the database id, transaction id and node ID are all available.


Nested Class Summary
(package private) static class LNLogEntry.DupStatus
           
 
Field Summary
static int MIN_LOG_SIZE
          Used for computing the minimum log space used by an LNLogEntry.
 
Fields inherited from class com.sleepycat.je.log.entry.BaseEntry
entryType
 
Constructor Summary
LNLogEntry(Class<? extends LN> cls)
           
LNLogEntry(LogEntryType entryType, LN ln, DatabaseId dbId, byte[] key, long abortLsn, boolean abortKnownDeleted, Txn txn)
           
 
Method Summary
(package private)  byte[] combineDupKeyData()
          Combine old key and old LN's data into a new key, and set the LN's data to empty.
 StringBuilder dumpEntry(StringBuilder sb, boolean verbose)
          Print out the contents of an entry.
 void dumpRep(StringBuilder sb)
          Dump the contents of the log entry that are interesting for replication.
 boolean getAbortKnownDeleted()
           
 long getAbortLsn()
           
(package private)  int getBaseLNEntrySize(boolean keyIsLastSerializedField)
          Method shared by LNLogEntry subclasses.
 DatabaseId getDbId()
           
 byte[] getKey()
           
 int getLastLoggedSize()
          Returns the last logged size, saved by readEntry and writeEntry.
 LN getLN()
           
 LN getMainItem()
           
 int getSize()
          #see LogEntry#getSize
 long getTransactionId()
           
 Long getTxnId()
           
 int getUnconvertedDataLength()
          This method is only used when the converted length is not needed, for example by StatsFileReader.
 int getUnconvertedKeyLength()
          This method is only used when the converted length is not needed, for example by StatsFileReader.
 void getUserKeyData(DatabaseEntry keyParam, DatabaseEntry dataParam)
          Translates two-part keys in duplicate DBs back to the original user operation params.
 Txn getUserTxn()
           
 boolean isDeleted()
          Returns true for a deleted LN to count it immediately as obsolete.
 boolean logicalEquals(LogEntry other)
           
(package private)  LN newLNInstance(EnvironmentImpl envImpl)
          newLNInstance usually returns exactly the type of LN of the type that was contained in in the log.
 void postFetchInit(boolean isDupDb)
          Converts the key/data for old format LNs in a duplicates DB.
 void postFetchInit(DatabaseImpl dbImpl)
          See postFetchInit(boolean).
 void postLogWork(LogEntryHeader header, long justLoggedLsn)
          For LN entries, we need to record the latest LSN for that node with the owning transaction, within the protection of the log latch.
(package private)  void readBaseLNEntry(EnvironmentImpl envImpl, LogEntryHeader header, ByteBuffer entryBuffer, boolean keyIsLastSerializedField)
          Method shared by LNLogEntry subclasses.
 void readEntry(EnvironmentImpl envImpl, LogEntryHeader header, ByteBuffer entryBuffer)
          Read in a log entry.
(package private)  void writeBaseLNEntry(LogEntryHeader header, ByteBuffer destBuffer, boolean keyIsLastSerializedField)
          Method shared by LNLogEntry subclasses.
 void writeEntry(LogEntryHeader header, ByteBuffer destBuffer)
          Serialize this object into the buffer.
 
Methods inherited from class com.sleepycat.je.log.entry.BaseEntry
clone, getLogType, getNoArgsConstructor, getResolvedItem, newInstanceOfType, newInstanceOfType, setLogType, toString
 
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
clone, getLogType, getResolvedItem, setLogType
 

Field Detail

MIN_LOG_SIZE

public static final int MIN_LOG_SIZE
Used for computing the minimum log space used by an LNLogEntry.

See Also:
Constant Field Values
Constructor Detail

LNLogEntry

public LNLogEntry(Class<? extends LN> cls)

LNLogEntry

public LNLogEntry(LogEntryType entryType,
                  LN ln,
                  DatabaseId dbId,
                  byte[] key,
                  long abortLsn,
                  boolean abortKnownDeleted,
                  Txn txn)
Method Detail

readEntry

public void readEntry(EnvironmentImpl envImpl,
                      LogEntryHeader header,
                      ByteBuffer entryBuffer)
Description copied from interface: LogEntry
Read in a log entry.

Specified by:
readEntry in interface LogEntry
See Also:
LogEntry.readEntry(com.sleepycat.je.dbi.EnvironmentImpl, com.sleepycat.je.log.LogEntryHeader, java.nio.ByteBuffer)

readBaseLNEntry

final void readBaseLNEntry(EnvironmentImpl envImpl,
                           LogEntryHeader header,
                           ByteBuffer entryBuffer,
                           boolean keyIsLastSerializedField)
Method shared by LNLogEntry subclasses.

Parameters:
keyIsLastSerializedField - specifies whether the key length can be omitted because the key is the last field. This should be false when an LNLogEntry subclass adds fields to the serialized format.

newLNInstance

LN newLNInstance(EnvironmentImpl envImpl)
newLNInstance usually returns exactly the type of LN of the type that was contained in in the log. For example, if a LNLogEntry holds a MapLN, newLNInstance will return that MapLN. There is one extra possibility for vanilla (data record) LNs. In that case, this method may either return a LN or a generated type, the VersionedLN, which adds the vlsn information from the log header to the LN object.


dumpEntry

public StringBuilder dumpEntry(StringBuilder sb,
                               boolean verbose)
Description copied from interface: LogEntry
Print out the contents of an entry.

Specified by:
dumpEntry in interface LogEntry
Specified by:
dumpEntry in class BaseEntry
See Also:
LogEntry.dumpEntry(java.lang.StringBuilder, boolean)

dumpRep

public void dumpRep(StringBuilder sb)
Description copied from interface: LogEntry
Dump the contents of the log entry that are interesting for replication.

Specified by:
dumpRep in interface LogEntry
See Also:
LogEntry.dumpRep(java.lang.StringBuilder)

getMainItem

public LN getMainItem()
Specified by:
getMainItem in interface LogEntry
Returns:
the first item of the log entry
See Also:
LogEntry.getMainItem()

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()
#see LogEntry#getSize

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

getBaseLNEntrySize

final int getBaseLNEntrySize(boolean keyIsLastSerializedField)
Method shared by LNLogEntry subclasses.

Parameters:
keyIsLastSerializedField - specifies whether the key length can be omitted because the key is the last field. This should be false when an LNLogEntry subclass adds fields to the serialized format.

getLastLoggedSize

public int getLastLoggedSize()
Returns the last logged size, saved by readEntry and writeEntry.

Specified by:
getLastLoggedSize in interface LogEntry
Overrides:
getLastLoggedSize in class BaseEntry
Returns:
total size of last logged entry, or zero if unknown. The last logged size is known for LNs, and is used for obsolete size counting.

writeEntry

public void writeEntry(LogEntryHeader header,
                       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)

writeBaseLNEntry

final void writeBaseLNEntry(LogEntryHeader header,
                            ByteBuffer destBuffer,
                            boolean keyIsLastSerializedField)
Method shared by LNLogEntry subclasses.

Parameters:
keyIsLastSerializedField - specifies whether the key length can be omitted because the key is the last field. This should be false when an LNLogEntry subclass adds fields to the serialized format.

isDeleted

public boolean isDeleted()
Returns true for a deleted LN to count it immediately as obsolete.

Specified by:
isDeleted in interface LogEntry
Overrides:
isDeleted in class BaseEntry
See Also:
LogEntry.isDeleted()

postLogWork

public void postLogWork(LogEntryHeader header,
                        long justLoggedLsn)
For LN entries, we need to record the latest LSN for that node with the owning transaction, within the protection of the log latch. This is a callback for the log manager to do that recording.

Specified by:
postLogWork in interface LogEntry
Overrides:
postLogWork in class BaseEntry
See Also:
LogEntry.postLogWork(com.sleepycat.je.log.LogEntryHeader, long)

postFetchInit

public void postFetchInit(DatabaseImpl dbImpl)
See postFetchInit(boolean).

Overrides:
postFetchInit in class BaseEntry

postFetchInit

public void postFetchInit(boolean isDupDb)
Converts the key/data for old format LNs in a duplicates DB. This method MUST be called before calling any of the following methods: getLN getKey getUserKeyData


combineDupKeyData

byte[] combineDupKeyData()
Combine old key and old LN's data into a new key, and set the LN's data to empty.


getUserKeyData

public void getUserKeyData(DatabaseEntry keyParam,
                           DatabaseEntry dataParam)
Translates two-part keys in duplicate DBs back to the original user operation params. postFetchInit must be called before calling this method.


getLN

public LN getLN()

getKey

public byte[] getKey()

getUnconvertedDataLength

public int getUnconvertedDataLength()
This method is only used when the converted length is not needed, for example by StatsFileReader.


getUnconvertedKeyLength

public int getUnconvertedKeyLength()
This method is only used when the converted length is not needed, for example by StatsFileReader.


getDbId

public DatabaseId getDbId()
Specified by:
getDbId in interface LogEntry
Returns:
the ID of the database containing this entry, or null if this entry type is not part of a database.

getAbortLsn

public long getAbortLsn()

getAbortKnownDeleted

public boolean getAbortKnownDeleted()

getTxnId

public Long getTxnId()

getUserTxn

public Txn getUserTxn()

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:
LogEntry.logicalEquals(com.sleepycat.je.log.entry.LogEntry)


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