Class FileRecordLog
- java.lang.Object
-
- org.apache.jackrabbit.core.journal.FileRecordLog
-
public class FileRecordLog extends Object
A file record log is a file containingRecords. Every file record log contains a header with the following physical layout:
After this header, zero or morePhysical Record Layout Byte 1Byte 2Byte 3Byte 4'J''L''O''G'MAJORMINORSTART REVISIONReadRecords follow.
-
-
Constructor Summary
Constructors Constructor Description FileRecordLog(File logFile)Create a new instance of this class.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longappend(String journalId, String producerId, InputStream in, int length)Append a record to this log.voidclose()Close this log.booleancontains(long revision)Return a flag indicating whether this record log contains a certain revision.booleanexceeds(long size)Return a flag indicating whether this record log exceeds a given size.longgetLastRevision()Return the last revision.longgetPreviousRevision()Return the previous revision.voidinit(long previousRevision)Initialize this record log by writing a header containing the previous revision.booleanisNew()Return a flag indicating whether this record log is new.ReadRecordread(NamespaceResolver resolver, NamePathResolver npResolver)Read the file record at the current seek position.voidseek(long revision)Seek an entry.
-
-
-
Constructor Detail
-
FileRecordLog
public FileRecordLog(File logFile) throws IOException
Create a new instance of this class. Opens a record log in read-only mode.- Parameters:
logFile- file containing record log- Throws:
IOException- if an I/O error occurs
-
-
Method Detail
-
init
public void init(long previousRevision) throws IOExceptionInitialize this record log by writing a header containing the previous revision.- Throws:
IOException
-
contains
public boolean contains(long revision)
Return a flag indicating whether this record log contains a certain revision.- Parameters:
revision- revision to look for- Returns:
trueif this record log contain a certain revision;falseotherwise
-
isNew
public boolean isNew()
Return a flag indicating whether this record log is new.- Returns:
trueif this record log is new;falseotherwise
-
exceeds
public boolean exceeds(long size)
Return a flag indicating whether this record log exceeds a given size.
-
seek
public void seek(long revision) throws IOExceptionSeek an entry. This is an operation that allows the underlying input stream to be sequentially scanned and must therefore not be called twice.- Parameters:
revision- revision to seek- Throws:
IOException- if an I/O error occurs
-
read
public ReadRecord read(NamespaceResolver resolver, NamePathResolver npResolver) throws IOException
Read the file record at the current seek position.- Parameters:
resolver- namespace resolver- Returns:
- file record
- Throws:
IOException- if an I/O error occurs
-
append
public long append(String journalId, String producerId, InputStream in, int length) throws IOException
Append a record to this log. Returns the revision following this record.- Parameters:
journalId- journal identifierproducerId- producer identifierin- record to addlength- record length- Throws:
IOException- if an I/O error occurs
-
getPreviousRevision
public long getPreviousRevision()
Return the previous revision. This is the last revision preceding the first revision in this log.- Returns:
- previous revision
-
getLastRevision
public long getLastRevision()
Return the last revision. This is the last revision in this log.- Returns:
- last revision
-
close
public void close()
Close this log.
-
-