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 intstatic 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 TypeMethodDescriptionvoidclose()Deprecated.@see #dispose()voiddispose()intgetMark()Obtains the mark that was set in the Journal.getNextRecordLocation(RecordLocation lastLocation) Allows you to get the next RecordLocation after thelocationthat is in the journal.protected IOExceptionReads a previously written record from the journal.voidsetJournalEventListener(JournalEventListener eventListener) Registers aJournalEventListenerthat will receive notifications from the Journal.voidsetMark(RecordLocation l, boolean force) Informs the journal that all the journal space up to thelocationis 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:JournalWrites 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.- Specified by:
writein interfaceJournal- 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:JournalInforms the journal that all the journal space up to thelocationis no longer needed and can be reclaimed for reuse.- Specified by:
setMarkin interfaceJournal- Parameters:
l- the location of the record to mark. All record locations before the marked location will no longger be vaild.force-recordLocator-- Throws:
InvalidRecordLocationExceptionIOExceptionInterruptedException
-
getMark
Description copied from interface:JournalObtains the mark that was set in the Journal. -
getNextRecordLocation
public RecordLocation getNextRecordLocation(RecordLocation lastLocation) throws IOException, InvalidRecordLocationException Description copied from interface:JournalAllows you to get the next RecordLocation after thelocationthat is in the journal.- Specified by:
getNextRecordLocationin interfaceJournal- Parameters:
lastLocation-- Returns:
- Throws:
IOExceptionInvalidRecordLocationException
-
handleExecutionException
- Throws:
IOException
-
read
Description copied from interface:JournalReads a previously written record from the journal.- Specified by:
readin interfaceJournal- Parameters:
l- is where to read the record from.location-- Returns:
- Throws:
InvalidRecordLocationExceptionIOException
-
setJournalEventListener
Description copied from interface:JournalRegisters aJournalEventListenerthat will receive notifications from the Journal.- Specified by:
setJournalEventListenerin interfaceJournal- Parameters:
eventListener- object that will receive journal events.
-
close
Deprecated.@see #dispose()Description copied from interface:JournalClose 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:
closein interfaceJournal- Throws:
IOException- if an error occurs while the journal is being closed.
-
dispose
public void dispose() -
getLogDirectory
- Returns:
-
getInitialLogFileSize
public int getInitialLogFileSize() -
toString
-