Class MemoryJournal

  • All Implemented Interfaces:
    Journal

    public class MemoryJournal
    extends AbstractJournal
    Memory-based journal, useful for testing purposes only.
    • Constructor Detail

      • MemoryJournal

        public MemoryJournal()
    • Method Detail

      • appending

        protected void appending​(AppendRecord record)
        Description copied from class: AbstractJournal
        Notification method called by an appended record at creation time. May be overridden by subclasses to save some context information inside the appended record.
        Overrides:
        appending in class AbstractJournal
        Parameters:
        record - record that was appended
      • 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
      • 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
      • setRecords

        public void setRecords​(List<MemoryJournal.MemoryRecord> records)
        Set records. Used to share records between two journal implementations.
        Parameters:
        records - array list that should back up this memory journal
      • getReadDelay

        public long getReadDelay()
        Return the read delay in milliseconds.
        Returns:
        read delay
      • setReadDelay

        public void setReadDelay​(long readDelay)
        Set the read delay in milliseconds.
        Parameters:
        readDelay - read delay
      • getWriteDelay

        public long getWriteDelay()
        Return the write delay in milliseconds.
        Returns:
        write delay
      • setWriteDelay

        public void setWriteDelay​(long writeDelay)
        Set the write delay in milliseconds.
        Parameters:
        writeDelay - write delay
      • close

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