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.active
Class JournalImpl

    java.lang.Object
      org.activeio.journal.active.JournalImpl

All Implemented Interfaces:
  Disposable, Journal

public final class JournalImpl
extends java.lang.Object
implements Journal, Disposable

A high speed Journal implementation. Inspired by the ideas of the Howl project but tailored to the needs of ActiveMQ.

This Journal provides the following features:

- Conncurrent writes are batched into a single write/force done by a background thread.
- Uses preallocated logs to avoid disk fragmentation and performance degregation.
- The number and size of the preallocated logs are configurable.
- Uses direct ByteBuffers to write data to log files.
- Allows logs to grow in case of an overflow condition so that overflow exceptions are not not thrown. Grown logs that are inactivated (due to a new mark) are resized to thier original size.
- No limit on the size of the record written to the journal
- Should be possible to extend so that multiple physical disk are used concurrently to increase throughput and decrease latency.

Version:
  $Revision: 1.1 $

Field Summary
`static int` | `DEFAULT_PACKET_SIZE`
`static int` | `DEFAULT_POOL_SIZE`

Constructor Summary
`JournalImpl(java.io.File logDirectory)`
`JournalImpl(java.io.File logDirectory, int logFileCount, int logFileSize)`
`JournalImpl(LogFileManager logFile)`

Method Summary
`void` | `close()` Close the Journal.
`void` | `dispose()` This method should not throw any exceptions.
`int` | `getInitialLogFileSize()`
`java.io.File` | `getLogDirectory()`
`RecordLocation` | `getMark()` Obtains the mark that was set in the Journal.
`RecordLocation` | `getNextRecordLocation(RecordLocation lastLocation)` Allows you to get the next RecordLocation after the `location` that is in the journal.
`Packet` | `read(RecordLocation l)` Reads a previously written record from the journal.
`void` | `setJournalEventListener(JournalEventListener eventListener)` Registers a `JournalEventListener` that will receive notifications from the Journal.
`void` | `setMark(RecordLocation l, boolean force)` Informs the journal that all the journal space up to the `location` is no longer needed and can be reclaimed for reuse.
`java.lang.String` | `toString()`
`RecordLocation` | `write(Packet data, boolean sync)` Writes a `Packet` of data to the journal.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### DEFAULT_POOL_SIZE

    public static final int DEFAULT_POOL_SIZE

### DEFAULT_PACKET_SIZE

    public static final int DEFAULT_PACKET_SIZE

Constructor Detail

### JournalImpl

    public JournalImpl(java.io.File logDirectory)
                throws java.io.IOException

### JournalImpl

    public JournalImpl(java.io.File logDirectory,
                       int logFileCount,
                       int logFileSize)
                throws java.io.IOException

### JournalImpl

    public JournalImpl(LogFileManager logFile)

Method Detail

### write

    public RecordLocation write(Packet data,
                                boolean sync)
                         throws java.io.IOException

  Description copied from interface: `Journal`
  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.

  Specified by:
    `write` in interface `Journal`
  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.

### setMark

    public void setMark(RecordLocation l,
                        boolean force)
                 throws InvalidRecordLocationException,
                        java.io.IOException

  Description copied from interface: `Journal`
  Informs the journal that all the journal space up to the `location` is no longer needed and can be reclaimed for reuse.

  Specified by:
    `setMark` in interface `Journal`
  Parameters:
    `force` -
    `l` - the location of the record to mark. All record locations before the marked location will no longger be vaild.
  Returns:
  Throws:
    `InvalidRecordLocationException`
    `java.io.IOException`
    `java.lang.InterruptedException`

### getMark

    public RecordLocation getMark()

  Description copied from interface: `Journal`
  Obtains the mark that was set in the Journal.

  Specified by:
    `getMark` in interface `Journal`
  Returns:
  See Also:
    `read(RecordLocation location);`

### getNextRecordLocation

    public RecordLocation getNextRecordLocation(RecordLocation lastLocation)
                                         throws java.io.IOException,
                                                InvalidRecordLocationException

  Description copied from interface: `Journal`
  Allows you to get the next RecordLocation after the `location` that is in the journal.

  Specified by:
    `getNextRecordLocation` in interface `Journal`
  Parameters:
    `lastLocation` -
  Returns:
  Throws:
    `java.io.IOException`
    `InvalidRecordLocationException`

### read

    public Packet read(RecordLocation l)
                throws java.io.IOException,
                       InvalidRecordLocationException

  Description copied from interface: `Journal`
  Reads a previously written record from the journal.

  Specified by:
    `read` in interface `Journal`
  Parameters:
    `l` - is where to read the record from.
  Returns:
  Throws:
    `InvalidRecordLocationException`
    `java.io.IOException`

### setJournalEventListener

    public void setJournalEventListener(JournalEventListener eventListener)

  Description copied from interface: `Journal`
  Registers a `JournalEventListener` that will receive notifications from the Journal.

  Specified by:
    `setJournalEventListener` in interface `Journal`
  Parameters:
    `eventListener` - object that will receive journal events.

### close

    public void close()
               throws java.io.IOException

  Deprecated. @see #dispose()

  Description copied from interface: `Journal`
  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.

  Specified by:
    `close` in interface `Journal`
  Throws:
    `java.io.IOException` - if an error occurs while the journal is being closed.

### dispose

    public void dispose()

  Description copied from interface: `Disposable`
  This method should not throw any exceptions. Cleaning up a Disposable object should be easy of an end user therefore do not make him have to handle an Exception.

  Specified by:
    `dispose` in interface `Disposable`

### getLogDirectory

    public java.io.File getLogDirectory()

  Returns:

### getInitialLogFileSize

    public int getInitialLogFileSize()

### toString

    public java.lang.String toString()

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.