Class AbstractJournal
- java.lang.Object
-
- org.apache.jackrabbit.core.journal.AbstractJournal
-
- All Implemented Interfaces:
Journal
- Direct Known Subclasses:
DatabaseJournal,FileJournal,MemoryJournal
public abstract class AbstractJournal extends Object implements Journal
Base journal implementation.
-
-
Constructor Summary
Constructors Constructor Description AbstractJournal()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract 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.protected RecordProducercreateProducer(String identifier)Create the record producer for a given identifier.protected abstract voiddoLock()Lock the journal revision.protected voiddoSync(long startRevision)Synchronize contents from journal.protected voiddoSync(long startRevision, boolean startup)protected abstract voiddoUnlock(boolean successful)Unlock the journal revision.RecordConsumergetConsumer(String identifier)Return the consumer given its identifier.StringgetId()Return this journal's identifier.NamePathResolvergetNamePathResolver()Return this journal's NamePathResolver.RecordProducergetProducer(String identifier)Return the record producer for a given identifier.FilegetRepositoryHome()Return the repository home.NamespaceResolvergetResolver()Return this journal's namespace resolver.StringgetRevision()voidinit(String id, NamespaceResolver resolver)Initialize journal.voidlockAndSync()Lock the journal revision, disallowing changes from other sources untilunlock(boolean)has been called, and synchronizes to the latest change.voidregister(RecordConsumer consumer)Register a record consumer.voidsetInternalVersionManager(InternalVersionManagerImpl internalVersionManager)Set the version manager.voidsetRepositoryHome(File repHome)Set the repository home.voidsetRevision(String revision)voidsync(boolean startup)Synchronize contents from journal.protected booleansyncAgainOnNewRecords()Return a flag indicating whether synchronization should continue in a loop until no more new records are found.voidunlock(boolean successful)Unlock the journal revision.booleanunregister(RecordConsumer consumer)Unregister a record processor.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.jackrabbit.core.journal.Journal
close, getInstanceRevision, getRecords, getRecords
-
-
-
-
Method Detail
-
init
public void init(String id, NamespaceResolver resolver) throws JournalException
Initialize journal.- Specified by:
initin interfaceJournal- Parameters:
id- id this journal should use to write its own recordsresolver- resolver used when reading/writing records- Throws:
JournalException- if an error occurs
-
register
public void register(RecordConsumer consumer) throws JournalException
Register a record consumer.- Specified by:
registerin interfaceJournal- Parameters:
consumer- record consumer- Throws:
JournalException- if an error occurs
-
unregister
public boolean unregister(RecordConsumer consumer)
Unregister a record processor.- Specified by:
unregisterin interfaceJournal- Parameters:
consumer- record processor to unregister- Returns:
trueif the consumer was previously registered;falseotherwise
-
getConsumer
public RecordConsumer getConsumer(String identifier)
Return the consumer given its identifier.- Parameters:
identifier- identifier- Returns:
- consumer associated with identifier;
nullif no consumer is associated with identifier
-
getProducer
public RecordProducer getProducer(String identifier)
Return the record producer for a given identifier.- Specified by:
getProducerin interfaceJournal- Parameters:
identifier- identifier- Returns:
- the record producer for a given identifier.
-
createProducer
protected RecordProducer createProducer(String identifier)
Create the record producer for a given identifier. May be overridden by subclasses.- Parameters:
identifier- producer identifier
-
sync
public void sync(boolean startup) throws JournalExceptionSynchronize contents from journal. This will compare the journal's revision with the revisions of all registered consumers and invoke theirRecordConsumer.consume(org.apache.jackrabbit.core.journal.Record)method when their identifier matches the one found in the records. The startup flag allow for a separate treatment of the initial sync when the cluster nodes starts up. This might be needed for example when there are a lot of old revisions in a database.- Specified by:
syncin interfaceJournal- Parameters:
startup- indicates if the cluster node is syncing on startup or does a normal sync.- Throws:
JournalException- if an error occurs
-
doSync
protected void doSync(long startRevision, boolean startup) throws JournalException- Throws:
JournalException
-
doSync
protected void doSync(long startRevision) throws JournalExceptionSynchronize contents from journal. May be overridden by subclasses.- Parameters:
startRevision- start point (exclusive)- Throws:
JournalException- if an error occurs
-
syncAgainOnNewRecords
protected boolean syncAgainOnNewRecords()
Return a flag indicating whether synchronization should continue in a loop until no more new records are found. Subclass overridable.- Returns:
trueif synchronization should continue;falseotherwise
-
lockAndSync
public void lockAndSync() throws JournalExceptionLock the journal revision, disallowing changes from other sources untilunlock(boolean)has been called, and synchronizes to the latest change.- Throws:
JournalException- if an error occurs
-
unlock
public void unlock(boolean successful)
Unlock the journal revision.- Parameters:
successful- flag indicating whether the update process was successful
-
doLock
protected abstract void doLock() throws JournalExceptionLock the journal revision. Subclass responsibility.- Throws:
JournalException- if an error occurs
-
appending
protected void appending(AppendRecord record)
Notification method called by an appended record at creation time. May be overridden by subclasses to save some context information inside the appended record.- Parameters:
record- record that was appended
-
append
protected abstract 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.- Parameters:
record- record to appendin- input streamlength- number of bytes in input stream- Throws:
JournalException- if an error occurs
-
doUnlock
protected abstract void doUnlock(boolean successful)
Unlock the journal revision. Subclass responsibility.- Parameters:
successful- flag indicating whether the update process was successful
-
getId
public String getId()
Return this journal's identifier.- Returns:
- journal identifier
-
getResolver
public NamespaceResolver getResolver()
Return this journal's namespace resolver.- Returns:
- namespace resolver
-
getNamePathResolver
public NamePathResolver getNamePathResolver()
Return this journal's NamePathResolver.- Returns:
- name and path resolver
-
setRepositoryHome
public void setRepositoryHome(File repHome)
Set the repository home.- Parameters:
repHome- repository home- Since:
- JR 1.5
-
setInternalVersionManager
public void setInternalVersionManager(InternalVersionManagerImpl internalVersionManager)
Set the version manager.
-
getRepositoryHome
public File getRepositoryHome()
Return the repository home.- Returns:
- the repository home
- Since:
- JR 1.5
-
getRevision
public String getRevision()
- Returns:
- the path of the cluster node's local revision file
-
setRevision
public void setRevision(String revision)
- Parameters:
revision- the path of the cluster node's local revision file to set
-
-