com.sleepycat.je.log
Class LogManager

java.lang.Object
  extended by com.sleepycat.je.log.LogManager
Direct Known Subclasses:
LatchedLogManager, SyncedLogManager

public abstract class LogManager
extends java.lang.Object

The LogManager supports reading and writing to the JE log.


Nested Class Summary
(package private) static class LogManager.LogResult
          LogResult holds the multivalue return from logInternal.
 
Field Summary
protected  EnvironmentImpl envImpl
           
protected  LogBufferPool logBufferPool
           
protected  Latch logWriteLatch
           
 
Constructor Summary
LogManager(EnvironmentImpl envImpl, boolean readOnly)
          There is a single log manager per database environment.
 
Method Summary
abstract  void countObsoleteINs(java.util.List lsnList)
          Counts the given obsolete IN LSNs under the log write latch.
protected  void countObsoleteINsInternal(java.util.List lsnList)
           
abstract  void countObsoleteNode(long lsn, LogEntryType type, int size)
          Count node as obsolete under the log write latch.
protected  void countObsoleteNodeInternal(UtilizationTracker tracker, long lsn, LogEntryType type, int size)
           
abstract  void countObsoleteNodes(java.util.Collection summaries)
          Counts file summary info under the log write latch.
protected  void countObsoleteNodesInternal(UtilizationTracker tracker, java.util.Collection summaries)
           
 void flush()
          Flush all log entries, fsync the log file.
protected abstract  void flushInternal()
           
 void flushNoSync()
          May be used to avoid sync to speed unit tests.
 java.lang.Object get(long lsn)
          Fault in the first object in the log entry log entry at this LSN.
 boolean getChecksumOnRead()
           
 long getLastLsnAtRecovery()
           
 LogEntry getLogEntry(long lsn)
          Instantiate all the objects in the log entry at this LSN.
(package private)  LogEntry getLogEntry(long lsn, java.io.RandomAccessFile file)
           
 LogSource getLogSource(long lsn)
          Find the LSN, whether in a file or still in the log buffers.
abstract  TrackedFileSummary getUnflushableTrackedSummary(long file)
          Returns a tracked summary for the given file which will not be flushed.
protected  TrackedFileSummary getUnflushableTrackedSummaryInternal(long file)
           
abstract  void loadEndOfLogStat(EnvironmentStats stats)
           
(package private)  void loadEndOfLogStatInternal(EnvironmentStats stats)
           
 void loadStats(StatsConfig config, EnvironmentStats stats)
           
 long log(LogEntry item)
          Write a log entry.
 long log(LogEntry item, boolean isProvisional, boolean backgroundIO, long oldNodeLsn, int oldNodeSize)
          Write a log entry.
 long logForceFlip(LogEntry item)
          Log this single object and force a flip of the log files.
 long logForceFlush(LogEntry item, boolean fsyncRequired)
          Log this single object and force a write of the log files.
protected  LogManager.LogResult logInternal(LogEntryHeader header, LogEntry item, boolean isProvisional, boolean flushRequired, boolean forceNewLogFile, long oldNodeLsn, int oldNodeSize, boolean marshallOutsideLatch, java.nio.ByteBuffer marshalledBuffer, UtilizationTracker tracker, boolean shouldReplicate)
          Called within the log write critical section.
protected abstract  LogManager.LogResult logItem(LogEntryHeader header, LogEntry item, boolean isProvisional, boolean flushRequired, boolean forceNewLogFile, long oldNodeLsn, int oldNodeSize, boolean marshallOutsideLatch, java.nio.ByteBuffer marshalledBuffer, UtilizationTracker tracker, boolean shouldReplicate)
           
(package private)  java.nio.ByteBuffer putIntoBuffer(LogEntry item, long prevLogEntryOffset)
          Serialize a log entry into this buffer with proper entry header.
abstract  void removeTrackedFile(TrackedFileSummary tfs)
          Removes the tracked summary for the given file.
protected  void removeTrackedFileInternal(TrackedFileSummary tfs)
           
 void resetPool(DbConfigManager configManager)
          Reset the pool when the cache is resized.
 void setLastLsnAtRecovery(long lastLsnAtRecovery)
           
 void setReadHook(TestHook hook)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logBufferPool

protected LogBufferPool logBufferPool

logWriteLatch

protected Latch logWriteLatch

envImpl

protected EnvironmentImpl envImpl
Constructor Detail

LogManager

public LogManager(EnvironmentImpl envImpl,
                  boolean readOnly)
           throws DatabaseException
There is a single log manager per database environment.

Throws:
DatabaseException
Method Detail

getChecksumOnRead

public boolean getChecksumOnRead()

getLastLsnAtRecovery

public long getLastLsnAtRecovery()

setLastLsnAtRecovery

public void setLastLsnAtRecovery(long lastLsnAtRecovery)

resetPool

public void resetPool(DbConfigManager configManager)
               throws DatabaseException
Reset the pool when the cache is resized. This method is called after the memory budget has been calculated.

Throws:
DatabaseException

logForceFlush

public long logForceFlush(LogEntry item,
                          boolean fsyncRequired)
                   throws DatabaseException
Log this single object and force a write of the log files.

Parameters:
item - object to be logged
fsyncRequired - if true, log files should also be fsynced.
Returns:
LSN of the new log entry
Throws:
DatabaseException

logForceFlip

public long logForceFlip(LogEntry item)
                  throws DatabaseException
Log this single object and force a flip of the log files.

Parameters:
item - object to be logged
fsyncRequired - if true, log files should also be fsynced.
Returns:
LSN of the new log entry
Throws:
DatabaseException

log

public long log(LogEntry item)
         throws DatabaseException
Write a log entry.

Returns:
LSN of the new log entry
Throws:
DatabaseException

log

public long log(LogEntry item,
                boolean isProvisional,
                boolean backgroundIO,
                long oldNodeLsn,
                int oldNodeSize)
         throws DatabaseException
Write a log entry.

Returns:
LSN of the new log entry
Throws:
DatabaseException

logItem

protected abstract LogManager.LogResult logItem(LogEntryHeader header,
                                                LogEntry item,
                                                boolean isProvisional,
                                                boolean flushRequired,
                                                boolean forceNewLogFile,
                                                long oldNodeLsn,
                                                int oldNodeSize,
                                                boolean marshallOutsideLatch,
                                                java.nio.ByteBuffer marshalledBuffer,
                                                UtilizationTracker tracker,
                                                boolean shouldReplicate)
                                         throws java.io.IOException,
                                                DatabaseException
Throws:
java.io.IOException
DatabaseException

logInternal

protected LogManager.LogResult logInternal(LogEntryHeader header,
                                           LogEntry item,
                                           boolean isProvisional,
                                           boolean flushRequired,
                                           boolean forceNewLogFile,
                                           long oldNodeLsn,
                                           int oldNodeSize,
                                           boolean marshallOutsideLatch,
                                           java.nio.ByteBuffer marshalledBuffer,
                                           UtilizationTracker tracker,
                                           boolean shouldReplicate)
                                    throws java.io.IOException,
                                           DatabaseException
Called within the log write critical section.

Throws:
java.io.IOException
DatabaseException

putIntoBuffer

java.nio.ByteBuffer putIntoBuffer(LogEntry item,
                                  long prevLogEntryOffset)
                            throws DatabaseException
Serialize a log entry into this buffer with proper entry header. Return it ready for a copy.

Throws:
DatabaseException

getLogEntry

public LogEntry getLogEntry(long lsn)
                     throws DatabaseException
Instantiate all the objects in the log entry at this LSN.

Parameters:
lsn - location of entry in log.
Returns:
log entry that embodies all the objects in the log entry.
Throws:
DatabaseException

getLogEntry

LogEntry getLogEntry(long lsn,
                     java.io.RandomAccessFile file)
               throws DatabaseException
Throws:
DatabaseException

get

public java.lang.Object get(long lsn)
                     throws DatabaseException
Fault in the first object in the log entry log entry at this LSN.

Parameters:
lsn - location of object in log
Returns:
the object in the log
Throws:
DatabaseException

getLogSource

public LogSource getLogSource(long lsn)
                       throws DatabaseException
Find the LSN, whether in a file or still in the log buffers. Is public for unit testing.

Throws:
DatabaseException

flush

public void flush()
           throws DatabaseException
Flush all log entries, fsync the log file.

Throws:
DatabaseException

flushNoSync

public void flushNoSync()
                 throws DatabaseException
May be used to avoid sync to speed unit tests.

Throws:
DatabaseException

flushInternal

protected abstract void flushInternal()
                               throws LogException,
                                      DatabaseException
Throws:
LogException
DatabaseException

loadStats

public void loadStats(StatsConfig config,
                      EnvironmentStats stats)
               throws DatabaseException
Throws:
DatabaseException

getUnflushableTrackedSummary

public abstract TrackedFileSummary getUnflushableTrackedSummary(long file)
                                                         throws DatabaseException
Returns a tracked summary for the given file which will not be flushed. Used for watching changes that occur while a file is being cleaned.

Throws:
DatabaseException

getUnflushableTrackedSummaryInternal

protected TrackedFileSummary getUnflushableTrackedSummaryInternal(long file)
                                                           throws DatabaseException
Throws:
DatabaseException

removeTrackedFile

public abstract void removeTrackedFile(TrackedFileSummary tfs)
                                throws DatabaseException
Removes the tracked summary for the given file.

Throws:
DatabaseException

removeTrackedFileInternal

protected void removeTrackedFileInternal(TrackedFileSummary tfs)

countObsoleteNode

public abstract void countObsoleteNode(long lsn,
                                       LogEntryType type,
                                       int size)
                                throws DatabaseException
Count node as obsolete under the log write latch. This is done here because the log write latch is managed here, and all utilization counting must be performed under the log write latch.

Throws:
DatabaseException

countObsoleteNodeInternal

protected void countObsoleteNodeInternal(UtilizationTracker tracker,
                                         long lsn,
                                         LogEntryType type,
                                         int size)
                                  throws DatabaseException
Throws:
DatabaseException

countObsoleteNodes

public abstract void countObsoleteNodes(java.util.Collection summaries)
                                 throws DatabaseException
Counts file summary info under the log write latch.

Throws:
DatabaseException

countObsoleteNodesInternal

protected void countObsoleteNodesInternal(UtilizationTracker tracker,
                                          java.util.Collection summaries)
                                   throws DatabaseException
Throws:
DatabaseException

countObsoleteINs

public abstract void countObsoleteINs(java.util.List lsnList)
                               throws DatabaseException
Counts the given obsolete IN LSNs under the log write latch.

Throws:
DatabaseException

countObsoleteINsInternal

protected void countObsoleteINsInternal(java.util.List lsnList)
                                 throws DatabaseException
Throws:
DatabaseException

loadEndOfLogStat

public abstract void loadEndOfLogStat(EnvironmentStats stats)
                               throws DatabaseException
Throws:
DatabaseException

loadEndOfLogStatInternal

void loadEndOfLogStatInternal(EnvironmentStats stats)

setReadHook

public void setReadHook(TestHook hook)


Copyright 2004,2008 Oracle. All rights reserved.