Class LogRecord

java.lang.Object
org.objectweb.howl.log.LogRecord
Direct Known Subclasses:
XALogRecord

public class LogRecord extends Object
LogRecord class used by Logger.replay().

This class may be extended by applications to provide Java Bean mappings for application data fields within the record.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) LogBuffer
    used by Logger.get() and Logger.getNext() to retrieve records from the journal.
    byte[]
    byte[] containing unparsed record data.
    ByteBuffer wrapper for the data byte[].
    protected byte[][]
    array of individual record fields as passed to Logger.put(byte[][])
    private boolean
    Set to true to prevent get() from returning control records.
    long
    log key associated with this LogRecord.
    short
    length of the data record.
    long
    currentTimeMillis the log buffer containing this record was initialized.
    short
    type of data record.
  • Constructor Summary

    Constructors
    Constructor
    Description
    LogRecord(int size)
    constructs an instance of LogRecord with a byte[] of size data.
  • Method Summary

    Modifier and Type
    Method
    Description
    final int
     
    protected LogRecord
    protected method to copy next logical record from the LogBuffer specified by the callers lb parameter.
    byte[][]
    Parse record data into a byte[][] that is equivalent to the one passed to Logger.put(byte[][]).
    private LogRecord
    helper for get().
    boolean
    Return true if the current record is a control record.
    boolean
    Return true if current record is an EOB type control record.
    void
    setFilterCtrlRecords(boolean filterCtrlRecords)
    Set the filterCtrlRecords member

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • buffer

      LogBuffer buffer
      used by Logger.get() and Logger.getNext() to retrieve records from the journal. FEATURE: 300792
    • type

      public short type
      type of data record.

      USER data records have a type == 0.

      Logger control record types are defined by LogRecordType.

      See Also:
    • length

      public short length
      length of the data record.
    • key

      public long key
      log key associated with this LogRecord.
    • fields

      protected byte[][] fields
      array of individual record fields as passed to Logger.put(byte[][])
      See Also:
    • data

      public byte[] data
      byte[] containing unparsed record data.
    • tod

      public long tod
      currentTimeMillis the log buffer containing this record was initialized.

      LogBuffers normally flush to disk in something less than 50 ms, so this tod should be a pretty close approximation of the time the record was generated.

    • dataBuffer

      public ByteBuffer dataBuffer
      ByteBuffer wrapper for the data byte[].
    • filterCtrlRecords

      private boolean filterCtrlRecords
      Set to true to prevent get() from returning control records.

      Default is false causing all records including control records to be returned by get()

  • Constructor Details

    • LogRecord

      public LogRecord(int size)
      constructs an instance of LogRecord with a byte[] of size data.
      Parameters:
      size - initial size of data buffer.

      the get() method will reallocate the data buffer to accomdate larger records.

  • Method Details

    • isEOB

      public boolean isEOB()
      Return true if current record is an EOB type control record.
      Returns:
      true if this record type is an EOB type.
    • isCTRL

      public boolean isCTRL()
      Return true if the current record is a control record.
      Returns:
      true if this record type has LogRecordType.CTRL set.
    • setFilterCtrlRecords

      public void setFilterCtrlRecords(boolean filterCtrlRecords)
      Set the filterCtrlRecords member
      Parameters:
      filterCtrlRecords -
    • capacity

      public final int capacity()
      Returns:
      length of the byte[] that backs the ByteBuffer.
    • get

      protected LogRecord get(LogBuffer lb) throws InvalidLogBufferException
      protected method to copy next logical record from the LogBuffer specified by the callers lb parameter.

      Following the call to get() the number of data bytes transferred into this LogRecord's data buffer is available in LogRecord.length. The LogRecord.dataBuffer.limit is also set to the number of bytes transferred.

      Sets LogRecord.type to LogRecordType.EOB if the position of this LogBuffer is at or beyond bytes used.

      Sets the limit of this LogRecord to the number of bytes in the logical record being retreived.

      LogBuffer.position() is unchanged if any exception is thrown.

      Parameters:
      lb - LogBuffer to get the next logical record from.
      Returns:
      this LogRecord.
      Throws:
      InvalidLogBufferException - if the size of the data record exceeds the bytes used for the buffer.
      See Also:
    • getNext

      private LogRecord getNext(LogBuffer lb) throws InvalidLogBufferException
      helper for get().

      returns the next record in the LogBuffer.

      Parameters:
      lb -
      Returns:
      the next LogRecord in the LogBuffer
      Throws:
      InvalidLogBufferException
    • getFields

      public byte[][] getFields()
      Parse record data into a byte[][] that is equivalent to the one passed to Logger.put(byte[][]).
      Returns:
      byte[][] containing data that was originally put into the log.