org.activeio.journal
Interface Journal

All Known Implementing Classes:
HowlJournal, 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 Summary
 void close()
          Close the Journal.
 RecordLocation getMark()
          Obtains the mark that was set in the Journal.
 RecordLocation getNextRecordLocation(RecordLocation location)
          Allows you to get the next RecordLocation after the location that is in the journal.
 Packet read(RecordLocation location)
          Reads a previously written record from the journal.
 void setJournalEventListener(JournalEventListener listener)
          Registers a JournalEventListener that will receive notifications from the Journal.
 void setMark(RecordLocation location, boolean sync)
          Informs the journal that all the journal space up to the location is no longer needed and can be reclaimed for reuse.
 RecordLocation write(Packet packet, boolean sync)
          Writes a Packet of data to the journal.
 

Method Detail

write

public RecordLocation write(Packet packet,
                            boolean sync)
                     throws IOException,
                            IllegalStateException
Writes a 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:
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:
IOException - if the write failed.
IllegalStateException - if the journal is closed.

read

public Packet read(RecordLocation location)
            throws InvalidRecordLocationException,
                   IOException,
                   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.
IOException - if the record could not be read.
IllegalStateException - if the journal is closed.

setMark

public void setMark(RecordLocation location,
                    boolean sync)
             throws InvalidRecordLocationException,
                    IOException,
                    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.
IOException - if the record could not be read.
IllegalStateException - if the journal is closed.

getMark

public RecordLocation getMark()
                       throws IllegalStateException
Obtains the mark that was set in the Journal.

Returns:
the mark that was set in the Journal.
Throws:
IllegalStateException - if the journal is closed.
See Also:
read(RecordLocation location);

close

public void close()
           throws 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:
IOException - if an error occurs while the journal is being closed.

getNextRecordLocation

public RecordLocation getNextRecordLocation(RecordLocation location)
                                     throws InvalidRecordLocationException,
                                            IOException,
                                            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.
IllegalStateException - if the journal is closed.
IOException

setJournalEventListener

public void setJournalEventListener(JournalEventListener listener)
                             throws IllegalStateException
Registers a JournalEventListener that will receive notifications from the Journal.

Parameters:
listener - object that will receive journal events.
Throws:
IllegalStateException - if the journal is closed.


Copyright © -2007 The ActiveIO Project. All Rights Reserved.