Interface Journal

  • All Known Implementing Classes:
    JournalImpl

    public interface Journal
    A Journal is a record logging Interface that can be used to implement a transaction log. This interface was largely extracted out of the HOWL project to allow ActiveMQ to switch between different Journal implementations verry easily.
    Version:
    $Revision: 1.1 $
    • Method Detail

      • write

        RecordLocation write​(Packet packet,
                             boolean sync)
                      throws java.io.IOException,
                             java.lang.IllegalStateException
        Writes a {@see Packet} of data to the journal. If sync is true, then this call blocks until the data has landed on the physical disk. Otherwise, this enqueues the write request and returns.
        Parameters:
        record - - the data to be written to disk.
        sync - - If this call should block until the data lands on disk.
        Returns:
        RecordLocation the location where the data will be written to on disk.
        Throws:
        java.io.IOException - if the write failed.
        java.lang.IllegalStateException - if the journal is closed.
      • read

        Packet read​(RecordLocation location)
             throws InvalidRecordLocationException,
                    java.io.IOException,
                    java.lang.IllegalStateException
        Reads a previously written record from the journal.
        Parameters:
        location - is where to read the record from.
        Returns:
        the data previously written at the location.
        Throws:
        InvalidRecordLocationException - if location parameter is out of range. It cannot be a location that is before the current mark.
        java.io.IOException - if the record could not be read.
        java.lang.IllegalStateException - if the journal is closed.
      • setMark

        void setMark​(RecordLocation location,
                     boolean sync)
              throws InvalidRecordLocationException,
                     java.io.IOException,
                     java.lang.IllegalStateException
        Informs the journal that all the journal space up to the location is no longer needed and can be reclaimed for reuse.
        Parameters:
        location - the location of the record to mark. All record locations before the marked location will no longger be vaild.
        sync - if this call should block until the mark is set on the journal.
        Throws:
        InvalidRecordLocationException - if location parameter is out of range. It cannot be a location that is before the current mark.
        java.io.IOException - if the record could not be read.
        java.lang.IllegalStateException - if the journal is closed.
      • getMark

        RecordLocation getMark()
                        throws java.lang.IllegalStateException
        Obtains the mark that was set in the Journal.
        Returns:
        the mark that was set in the Journal.
        Throws:
        java.lang.IllegalStateException - if the journal is closed.
      • close

        void close()
            throws java.io.IOException
        Close the Journal. This is blocking operation that waits for any pending put opperations to be forced to disk. Once the Journal is closed, all other methods of the journal should throw IllegalStateException.
        Throws:
        java.io.IOException - if an error occurs while the journal is being closed.
      • getNextRecordLocation

        RecordLocation getNextRecordLocation​(RecordLocation location)
                                      throws InvalidRecordLocationException,
                                             java.io.IOException,
                                             java.lang.IllegalStateException
        Allows you to get the next RecordLocation after the location that is in the journal.
        Parameters:
        location - the reference location the is used to find the next location. To get the oldest location available in the journal, location should be set to null.
        Returns:
        the next record location
        Throws:
        InvalidRecordLocationException - if location parameter is out of range. It cannot be a location that is before the current mark.
        java.lang.IllegalStateException - if the journal is closed.
        java.io.IOException
      • setJournalEventListener

        void setJournalEventListener​(JournalEventListener listener)
                              throws java.lang.IllegalStateException
        Registers a JournalEventListener that will receive notifications from the Journal.
        Parameters:
        listener - object that will receive journal events.
        Throws:
        java.lang.IllegalStateException - if the journal is closed.