org.activeio.journal.active
Class JournalImpl

java.lang.Object
  extended byorg.activeio.journal.active.JournalImpl
All Implemented Interfaces:
Disposable, Journal

public final class JournalImpl
extends 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:

Version:
$Revision: 1.1 $

Field Summary
static int DEFAULT_PACKET_SIZE
           
static int DEFAULT_POOL_SIZE
           
 
Constructor Summary
JournalImpl(File logDirectory)
           
JournalImpl(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()
           
 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.
 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(File logDirectory)
            throws IOException

JournalImpl

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

JournalImpl

public JournalImpl(LogFileManager logFile)
Method Detail

write

public RecordLocation write(Packet data,
                            boolean sync)
                     throws 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:
IOException - if the write failed.

setMark

public void setMark(RecordLocation l,
                    boolean force)
             throws InvalidRecordLocationException,
                    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
IOException
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 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:
IOException
InvalidRecordLocationException

read

public Packet read(RecordLocation l)
            throws 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
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 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:
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 File getLogDirectory()
Returns:

getInitialLogFileSize

public int getInitialLogFileSize()

toString

public String toString()


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