com.sleepycat.je.log
Class LogBuffer

java.lang.Object
  extended by com.sleepycat.je.log.LogBuffer
All Implemented Interfaces:
LogSource

public class LogBuffer
extends Object
implements LogSource

LogBuffers hold outgoing, newly written log entries.


Constructor Summary
LogBuffer(ByteBuffer buffer, long firstLsn)
           
LogBuffer(int capacity, EnvironmentImpl env)
           
 
Method Summary
(package private)  boolean containsLsn(long lsn)
          Support for reading out of a still-in-memory log.
 ByteBuffer getBytes(long fileOffset)
          Fill the destination byte array with bytes.
 ByteBuffer getBytes(long fileOffset, int numBytes)
          Fill the destination byte array with the requested number of bytes.
(package private)  int getCapacity()
           
 ByteBuffer getDataBuffer()
           
 long getFirstLsn()
          Return first LSN held in this buffer.
 int getLogVersion()
          Entries in write buffers are always the current version.
(package private)  boolean getRewriteAllowed()
           
(package private)  boolean hasRoom(int numBytes)
          Check capacity of buffer.
 void latchForWrite()
          When modifying the buffer, acquire the readLatch.
(package private)  void registerLsn(long lsn)
          This LSN has been written to the log.
(package private)  void reinit()
           
 void release()
          We're done with this log source.
(package private)  void setRewriteAllowed()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LogBuffer

LogBuffer(int capacity,
          EnvironmentImpl env)
    throws DatabaseException
Throws:
DatabaseException

LogBuffer

LogBuffer(ByteBuffer buffer,
          long firstLsn)
Method Detail

reinit

void reinit()
      throws DatabaseException
Throws:
DatabaseException

getFirstLsn

public long getFirstLsn()
Return first LSN held in this buffer. Assumes the log write latch is held.


registerLsn

void registerLsn(long lsn)
           throws DatabaseException
This LSN has been written to the log.

Throws:
DatabaseException

hasRoom

boolean hasRoom(int numBytes)
Check capacity of buffer. Assumes that the log write latch is held.

Returns:
true if this buffer can hold this many more bytes.

getDataBuffer

public ByteBuffer getDataBuffer()
Returns:
the actual data buffer.

getCapacity

int getCapacity()
Returns:
capacity in bytes

containsLsn

boolean containsLsn(long lsn)
Support for reading out of a still-in-memory log. Can be used to determine if a log entry with a given LSN is contained in this buffer, or whether an arbitrary LSN location is present in the buffer.

Returns:
true if this buffer holds the data at this LSN location. If true is returned, the buffer will be latched for read. Returns false if LSN is not here, and releases the read latch.

latchForWrite

public void latchForWrite()
                   throws DatabaseException
When modifying the buffer, acquire the readLatch. Call release() to release the latch. Note that containsLsn() acquires the latch for reading.

Throws:
DatabaseException

release

public void release()
Description copied from interface: LogSource
We're done with this log source.

Specified by:
release in interface LogSource
See Also:
LogSource.release()

getRewriteAllowed

boolean getRewriteAllowed()

setRewriteAllowed

void setRewriteAllowed()

getBytes

public ByteBuffer getBytes(long fileOffset)
Description copied from interface: LogSource
Fill the destination byte array with bytes. The offset indicates the absolute log file position.

Specified by:
getBytes in interface LogSource
See Also:
LogSource.getBytes(long)

getBytes

public ByteBuffer getBytes(long fileOffset,
                           int numBytes)
                    throws ChecksumException
Description copied from interface: LogSource
Fill the destination byte array with the requested number of bytes. The offset indicates the absolute position in the log file.

Specified by:
getBytes in interface LogSource
Throws:
ChecksumException
See Also:
LogSource.getBytes(long)

getLogVersion

public int getLogVersion()
Entries in write buffers are always the current version.

Specified by:
getLogVersion in interface LogSource


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