Class MemoryJournal
- java.lang.Object
-
- org.apache.jackrabbit.core.journal.AbstractJournal
-
- org.apache.jackrabbit.core.journal.MemoryJournal
-
- All Implemented Interfaces:
Journal
public class MemoryJournal extends AbstractJournal
Memory-based journal, useful for testing purposes only.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMemoryJournal.MemoryRecordMemory record.classMemoryJournal.MemoryRecordIteratorRecord iterator implementation.
-
Constructor Summary
Constructors Constructor Description MemoryJournal()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidappend(AppendRecord record, InputStream in, int length)Append a record backed by a file.protected voidappending(AppendRecord record)Notification method called by an appended record at creation time.voidclose()Close this journal.protected voiddoLock()Lock the journal revision.protected voiddoUnlock(boolean successful)Unlock the journal revision.InstanceRevisiongetInstanceRevision()Gets the instance that manages the cluster node's local revision.longgetReadDelay()Return the read delay in milliseconds.RecordIteratorgetRecords()Return an iterator over all available records in the journal.RecordIteratorgetRecords(long startRevision)Return an iterator over all records after the specified revision.longgetWriteDelay()Return the write delay in milliseconds.voidinit(String id, NamespaceResolver resolver)Initialize journal.voidsetReadDelay(long readDelay)Set the read delay in milliseconds.voidsetRecords(List<MemoryJournal.MemoryRecord> records)Set records.voidsetWriteDelay(long writeDelay)Set the write delay in milliseconds.-
Methods inherited from class org.apache.jackrabbit.core.journal.AbstractJournal
createProducer, doSync, doSync, getConsumer, getId, getNamePathResolver, getProducer, getRepositoryHome, getResolver, getRevision, lockAndSync, register, setInternalVersionManager, setRepositoryHome, setRevision, sync, syncAgainOnNewRecords, unlock, unregister
-
-
-
-
Method Detail
-
getInstanceRevision
public InstanceRevision getInstanceRevision() throws JournalException
Gets the instance that manages the cluster node's local revision.- Returns:
- the InstanceRevision manager
- Throws:
JournalException- on error
-
init
public void init(String id, NamespaceResolver resolver) throws JournalException
Initialize journal.- Specified by:
initin interfaceJournal- Overrides:
initin classAbstractJournal- Parameters:
id- id this journal should use to write its own recordsresolver- resolver used when reading/writing records- Throws:
JournalException- if an error occurs
-
doLock
protected void doLock() throws JournalExceptionLock the journal revision. Subclass responsibility.- Specified by:
doLockin classAbstractJournal- Throws:
JournalException- if an error occurs
-
appending
protected void appending(AppendRecord record)
Description copied from class:AbstractJournalNotification method called by an appended record at creation time. May be overridden by subclasses to save some context information inside the appended record.- Overrides:
appendingin classAbstractJournal- Parameters:
record- record that was appended
-
append
protected void append(AppendRecord record, InputStream in, int length) throws JournalException
Append a record backed by a file. On exit, the new revision must have been set inside the appended record. Subclass responsibility.- Specified by:
appendin classAbstractJournal- Parameters:
record- record to appendin- input streamlength- number of bytes in input stream- Throws:
JournalException- if an error occurs
-
doUnlock
protected void doUnlock(boolean successful)
Unlock the journal revision. Subclass responsibility.- Specified by:
doUnlockin classAbstractJournal- Parameters:
successful- flag indicating whether the update process was successful
-
getRecords
public RecordIterator getRecords(long startRevision) throws JournalException
Return an iterator over all records after the specified revision.- Parameters:
startRevision- start point (exlusive)- Returns:
- an iterator over all records after the specified revision.
- Throws:
JournalException- if an error occurs
-
getRecords
public RecordIterator getRecords() throws JournalException
Return an iterator over all available records in the journal.- Returns:
- an iterator over all records.
- Throws:
JournalException- if an error occurs
-
setRecords
public void setRecords(List<MemoryJournal.MemoryRecord> records)
Set records. Used to share records between two journal implementations.- Parameters:
records- array list that should back up this memory journal
-
getReadDelay
public long getReadDelay()
Return the read delay in milliseconds.- Returns:
- read delay
-
setReadDelay
public void setReadDelay(long readDelay)
Set the read delay in milliseconds.- Parameters:
readDelay- read delay
-
getWriteDelay
public long getWriteDelay()
Return the write delay in milliseconds.- Returns:
- write delay
-
setWriteDelay
public void setWriteDelay(long writeDelay)
Set the write delay in milliseconds.- Parameters:
writeDelay- write delay
-
close
public void close()
Close this journal. This should release any resources still held by this journal.
-
-