Journal (ActiveIO 1.0 API)
Keywords: org.activeio.journal.Journal interface

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## 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 java.io.IOException,
                                java.lang.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:
    `java.io.IOException` - if the write failed.
    `java.lang.IllegalStateException` - if the journal is closed.

### read

    public 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

    public 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

    public 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.
  See Also:
    `read(RecordLocation location);`

### close

    public 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

    public 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

    public 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.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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