Class JournalImpl
java.lang.Object
org.apache.activeio.journal.active.JournalImpl
- All Implemented Interfaces:
Journal
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:
- Concurrent 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 inactivate (due to a new mark) are resized to their 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
FieldsModifier and TypeFieldDescriptionstatic final int
static final int
-
Constructor Summary
ConstructorsConstructorDescriptionJournalImpl
(File logDirectory) JournalImpl
(File logDirectory, int logFileCount, int logFileSize) JournalImpl
(File logDirectory, int logFileCount, int logFileSize, File archiveDirectory) JournalImpl
(LogFileManager logFile) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Deprecated.void
dispose()
int
getMark()
Obtains the mark that was set in the Journal.getNextRecordLocation
(RecordLocation lastLocation) Allows you to get the next RecordLocation after thelocation
that is in the journal.protected IOException
Reads a previously written record from the journal.void
setJournalEventListener
(JournalEventListener eventListener) Registers aJournalEventListener
that will receive notifications from the Journal.void
setMark
(RecordLocation l, boolean force) Informs the journal that all the journal space up to thelocation
is no longer needed and can be reclaimed for reuse.toString()
Writes a of data to the journal.
-
Field Details
-
DEFAULT_POOL_SIZE
public static final int DEFAULT_POOL_SIZE -
DEFAULT_PACKET_SIZE
public static final int DEFAULT_PACKET_SIZE
-
-
Constructor Details
-
JournalImpl
- Throws:
IOException
-
JournalImpl
- Throws:
IOException
-
JournalImpl
public JournalImpl(File logDirectory, int logFileCount, int logFileSize, File archiveDirectory) throws IOException - Throws:
IOException
-
JournalImpl
-
-
Method Details
-
write
Description copied from interface:Journal
Writes a of data to the journal. Ifsync
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 interfaceJournal
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 thelocation
is no longer needed and can be reclaimed for reuse.- Specified by:
setMark
in interfaceJournal
- Parameters:
recordLocator
-force
-- Throws:
InvalidRecordLocationException
IOException
InterruptedException
-
getMark
Description copied from interface:Journal
Obtains the mark that was set in the Journal. -
getNextRecordLocation
public RecordLocation getNextRecordLocation(RecordLocation lastLocation) throws IOException, InvalidRecordLocationException Description copied from interface:Journal
Allows you to get the next RecordLocation after thelocation
that is in the journal.- Specified by:
getNextRecordLocation
in interfaceJournal
- Parameters:
lastLocation
-- Returns:
- Throws:
IOException
InvalidRecordLocationException
-
handleExecutionException
- Throws:
IOException
-
read
Description copied from interface:Journal
Reads a previously written record from the journal.- Specified by:
read
in interfaceJournal
- Parameters:
location
-- Returns:
- Throws:
InvalidRecordLocationException
IOException
-
setJournalEventListener
Description copied from interface:Journal
Registers aJournalEventListener
that will receive notifications from the Journal.- Specified by:
setJournalEventListener
in interfaceJournal
- Parameters:
eventListener
- object that will receive journal events.
-
close
Deprecated.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 interfaceJournal
- Throws:
IOException
- if an error occurs while the journal is being closed.- See Also:
-
dispose
public void dispose() -
getLogDirectory
- Returns:
-
getInitialLogFileSize
public int getInitialLogFileSize() -
toString
-