Class AbstractJournal

    • Constructor Detail

      • AbstractJournal

        public AbstractJournal()
    • Method Detail

      • unregister

        public boolean unregister​(RecordConsumer consumer)
        Unregister a record processor.
        Specified by:
        unregister in interface Journal
        Parameters:
        consumer - record processor to unregister
        Returns:
        true if the consumer was previously registered; false otherwise
      • getConsumer

        public RecordConsumer getConsumer​(String identifier)
        Return the consumer given its identifier.
        Parameters:
        identifier - identifier
        Returns:
        consumer associated with identifier; null if no consumer is associated with identifier
      • getProducer

        public RecordProducer getProducer​(String identifier)
        Return the record producer for a given identifier.
        Specified by:
        getProducer in interface Journal
        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 JournalException
        Synchronize contents from journal. This will compare the journal's revision with the revisions of all registered consumers and invoke their RecordConsumer.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:
        sync in interface Journal
        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)
                       throws JournalException
        Synchronize 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:
        true if synchronization should continue; false otherwise
      • lockAndSync

        public void lockAndSync()
                         throws JournalException
        Lock the journal revision, disallowing changes from other sources until unlock(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 JournalException
        Lock 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 append
        in - input stream
        length - 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