Package org.apache.activeio.journal
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 Summary
Modifier and TypeMethodDescriptionvoidclose()Close the Journal.getMark()Obtains the mark that was set in the Journal.getNextRecordLocation(RecordLocation location) Allows you to get the next RecordLocation after thelocationthat is in the journal.read(RecordLocation location) Reads a previously written record from the journal.voidsetJournalEventListener(JournalEventListener listener) Registers aJournalEventListenerthat will receive notifications from the Journal.voidsetMark(RecordLocation location, boolean sync) Informs the journal that all the journal space up to thelocationis no longer needed and can be reclaimed for reuse.Writes a of data to the journal.
-
Method Details
-
write
Writes a of data to the journal. Ifsyncis 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.record- - the data to be written to 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
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- iflocationparameter 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
void setMark(RecordLocation location, boolean sync) throws InvalidRecordLocationException, IOException, IllegalStateException Informs the journal that all the journal space up to thelocationis 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- iflocationparameter 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
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.
-
close
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
RecordLocation getNextRecordLocation(RecordLocation location) throws InvalidRecordLocationException, IOException, IllegalStateException Allows you to get the next RecordLocation after thelocationthat 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,locationshould be set to null.- Returns:
- the next record location
- Throws:
InvalidRecordLocationException- iflocationparameter is out of range. It cannot be a location that is before the current mark.IllegalStateException- if the journal is closed.IOException
-
setJournalEventListener
Registers aJournalEventListenerthat will receive notifications from the Journal.- Parameters:
listener- object that will receive journal events.- Throws:
IllegalStateException- if the journal is closed.
-