Class FileJournal

  • All Implemented Interfaces:
    Journal

    public class FileJournal
    extends AbstractJournal
    File-based journal implementation that appends journal records to a single file.

    It is configured through the following properties:

    • revision: the filename where the parent cluster node's revision file should be written to; this is a required property with no default value
    • directory: the directory where to keep the journal file as well as the rotated files; this is a required property with no default value
    • basename: the basename of journal files; the default value is DEFAULT_BASENAME
    • maximumSize: the maximum size of an active journal file before rotating it: the default value is DEFAULT_MAXSIZE
    • Field Detail

      • DEFAULT_INSTANCE_FILE_NAME

        public static final String DEFAULT_INSTANCE_FILE_NAME
        Default instance revision file name.
        See Also:
        Constant Field Values
    • Constructor Detail

      • FileJournal

        public FileJournal()
    • Method Detail

      • getRecords

        public RecordIterator getRecords​(long startRevision)
                                  throws JournalException
        Return an iterator over all records after the specified revision.
        Parameters:
        startRevision - start point (exlusive)
        Returns:
        an iterator over all records after the specified revision.
        Throws:
        JournalException - if an error occurs
      • append

        protected void append​(AppendRecord record,
                              InputStream in,
                              int length)
                       throws JournalException
        Append a record backed by a file. On exit, the new revision must have been set inside the appended record. Subclass responsibility.
        Specified by:
        append in class AbstractJournal
        Parameters:
        record - record to append
        in - input stream
        length - number of bytes in input stream
        Throws:
        JournalException - if an error occurs
      • doUnlock

        protected void doUnlock​(boolean successful)
        Unlock the journal revision. Subclass responsibility.
        Specified by:
        doUnlock in class AbstractJournal
        Parameters:
        successful - flag indicating whether the update process was successful
      • close

        public void close()
        Close this journal. This should release any resources still held by this journal.
      • getDirectory

        public String getDirectory()
        Bean getters
      • getBasename

        public String getBasename()
      • getMaximumSize

        public int getMaximumSize()
      • setDirectory

        public void setDirectory​(String directory)
        Bean setters
      • setBasename

        public void setBasename​(String basename)
      • setMaximumSize

        public void setMaximumSize​(int maximumSize)