Class FileJournal
- java.lang.Object
-
- org.apache.jackrabbit.core.journal.AbstractJournal
-
- org.apache.jackrabbit.core.journal.FileJournal
-
- All Implemented Interfaces:
Journal
public class FileJournal extends AbstractJournal
File-based journal implementation that appends journal records to a single file.It is configured through the following properties:
revision
: the filename where the parent cluster node's revision file should be written to; this is a required property with no default valuedirectory
: the directory where to keep the journal file as well as the rotated files; this is a required property with no default valuebasename
: the basename of journal files; the default value isDEFAULT_BASENAME
maximumSize
: the maximum size of an active journal file before rotating it: the default value isDEFAULT_MAXSIZE
-
-
Field Summary
Fields Modifier and Type Field Description static String
DEFAULT_INSTANCE_FILE_NAME
Default instance revision file name.
-
Constructor Summary
Constructors Constructor Description FileJournal()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
append(AppendRecord record, InputStream in, int length)
Append a record backed by a file.void
close()
Close this journal.protected void
doLock()
Lock the journal revision.protected void
doUnlock(boolean successful)
Unlock the journal revision.String
getBasename()
String
getDirectory()
Bean gettersprotected long
getGlobalRevision()
InstanceRevision
getInstanceRevision()
Gets the instance that manages the cluster node's local revision.int
getMaximumSize()
RecordIterator
getRecords()
Return an iterator over all available records in the journal.RecordIterator
getRecords(long startRevision)
Return an iterator over all records after the specified revision.void
init(String id, NamespaceResolver resolver)
Initialize journal.void
setBasename(String basename)
void
setDirectory(String directory)
Bean settersvoid
setMaximumSize(int maximumSize)
-
Methods inherited from class org.apache.jackrabbit.core.journal.AbstractJournal
appending, createProducer, doSync, doSync, getConsumer, getId, getNamePathResolver, getProducer, getRepositoryHome, getResolver, getRevision, lockAndSync, register, setInternalVersionManager, setRepositoryHome, setRevision, sync, syncAgainOnNewRecords, unlock, unregister
-
-
-
-
Field Detail
-
DEFAULT_INSTANCE_FILE_NAME
public static final String DEFAULT_INSTANCE_FILE_NAME
Default instance revision file name.- See Also:
- Constant Field Values
-
-
Method Detail
-
init
public void init(String id, NamespaceResolver resolver) throws JournalException
Initialize journal.- Specified by:
init
in interfaceJournal
- Overrides:
init
in 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
-
getGlobalRevision
protected long getGlobalRevision() throws JournalException
- Throws:
JournalException
-
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
-
doLock
protected void doLock() throws JournalException
Lock the journal revision. Subclass responsibility.- Specified by:
doLock
in classAbstractJournal
- Throws:
JournalException
- if an error occurs
-
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:
append
in 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:
doUnlock
in classAbstractJournal
- Parameters:
successful
- flag indicating whether the update process was successful
-
close
public void close()
Close this journal. This should release any resources still held by this journal.
-
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
-
getDirectory
public String getDirectory()
Bean getters
-
getBasename
public String getBasename()
-
getMaximumSize
public int getMaximumSize()
-
setDirectory
public void setDirectory(String directory)
Bean setters
-
setBasename
public void setBasename(String basename)
-
setMaximumSize
public void setMaximumSize(int maximumSize)
-
-