Class FileRecordLog


  • public class FileRecordLog
    extends Object
    A file record log is a file containing Records. Every file record log contains a header with the following physical layout:
    Physical Record Layout
    Byte 1 Byte 2 Byte 3 Byte 4
    'J' 'L' 'O' 'G'
    MAJOR MINOR
    START REVISION
    After this header, zero or more ReadRecords follow.
    • Constructor Summary

      Constructors 
      Constructor Description
      FileRecordLog​(File logFile)
      Create a new instance of this class.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      long append​(String journalId, String producerId, InputStream in, int length)
      Append a record to this log.
      void close()
      Close this log.
      boolean contains​(long revision)
      Return a flag indicating whether this record log contains a certain revision.
      boolean exceeds​(long size)
      Return a flag indicating whether this record log exceeds a given size.
      long getLastRevision()
      Return the last revision.
      long getPreviousRevision()
      Return the previous revision.
      void init​(long previousRevision)
      Initialize this record log by writing a header containing the previous revision.
      boolean isNew()
      Return a flag indicating whether this record log is new.
      ReadRecord read​(org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver resolver, org.apache.jackrabbit.spi.commons.conversion.NamePathResolver npResolver)
      Read the file record at the current seek position.
      void seek​(long revision)
      Seek an entry.
    • Constructor Detail

      • FileRecordLog

        public FileRecordLog​(File logFile)
                      throws IOException
        Create a new instance of this class. Opens a record log in read-only mode.
        Parameters:
        logFile - file containing record log
        Throws:
        IOException - if an I/O error occurs
    • Method Detail

      • init

        public void init​(long previousRevision)
                  throws IOException
        Initialize this record log by writing a header containing the previous revision.
        Throws:
        IOException
      • contains

        public boolean contains​(long revision)
        Return a flag indicating whether this record log contains a certain revision.
        Parameters:
        revision - revision to look for
        Returns:
        true if this record log contain a certain revision; false otherwise
      • isNew

        public boolean isNew()
        Return a flag indicating whether this record log is new.
        Returns:
        true if this record log is new; false otherwise
      • exceeds

        public boolean exceeds​(long size)
        Return a flag indicating whether this record log exceeds a given size.
      • seek

        public void seek​(long revision)
                  throws IOException
        Seek an entry. This is an operation that allows the underlying input stream to be sequentially scanned and must therefore not be called twice.
        Parameters:
        revision - revision to seek
        Throws:
        IOException - if an I/O error occurs
      • read

        public ReadRecord read​(org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver resolver,
                               org.apache.jackrabbit.spi.commons.conversion.NamePathResolver npResolver)
                        throws IOException
        Read the file record at the current seek position.
        Parameters:
        resolver - namespace resolver
        Returns:
        file record
        Throws:
        IOException - if an I/O error occurs
      • append

        public long append​(String journalId,
                           String producerId,
                           InputStream in,
                           int length)
                    throws IOException
        Append a record to this log. Returns the revision following this record.
        Parameters:
        journalId - journal identifier
        producerId - producer identifier
        in - record to add
        length - record length
        Throws:
        IOException - if an I/O error occurs
      • getPreviousRevision

        public long getPreviousRevision()
        Return the previous revision. This is the last revision preceding the first revision in this log.
        Returns:
        previous revision
      • getLastRevision

        public long getLastRevision()
        Return the last revision. This is the last revision in this log.
        Returns:
        last revision
      • close

        public void close()
        Close this log.