Class DefaultJournalService
- java.lang.Object
- 
- com.atlassian.confluence.impl.journal.DefaultJournalService
 
- 
- All Implemented Interfaces:
- JournalService
 
 public class DefaultJournalService extends Object implements JournalService This is the default implementation ofJournalService.- Since:
- 5.6
 
- 
- 
Constructor SummaryConstructors Constructor Description DefaultJournalService(JournalManager journalManager)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description intcountEntries(@NonNull JournalIdentifier journalId)Counts the number of entries in a journal.longenqueue(@NonNull JournalEntry entry)Adds the given entry to a journal.Iterable<JournalEntry>peek(@NonNull JournalIdentifier journalId, int maxEntries)Return a copy of journal entries that are waiting to be processed.<V> VprocessEntries(@NonNull JournalIdentifier journalId, int maxEntries, @NonNull com.google.common.base.Function<Iterable<JournalEntry>,EntryProcessorResult<V>> entryProcessor)Processes journal entries that were added since the last time this method was called for this journal on this cluster node.voidreset(@NonNull JournalIdentifier journalId)Resets the state of the journal so that all entries currently in the journal will be skipped.voidwaitForRecentEntriesToBecomeVisible()Waits long enough to ensure that entries added before calling this method will be available to subsequent call toJournalService.processNewEntries(JournalIdentifier, int, Function).- 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface com.atlassian.confluence.api.service.journal.JournalServiceprocessNewEntries
 
- 
 
- 
- 
- 
Constructor Detail- 
DefaultJournalServicepublic DefaultJournalService(JournalManager journalManager) 
 
- 
 - 
Method Detail- 
enqueuepublic long enqueue(@NonNull JournalEntry entry) throws ServiceException Description copied from interface:JournalServiceAdds the given entry to a journal.New journal is automatically created if a journal with the given name does not exists. - Specified by:
- enqueuein interface- JournalService
- Parameters:
- entry- entry to persist
- Returns:
- id generated for the entry
- Throws:
- ServiceException- if the entry could not be persisted
 
 - 
processEntriespublic <V> V processEntries(@NonNull JournalIdentifier journalId, int maxEntries, @NonNull com.google.common.base.Function<Iterable<JournalEntry>,EntryProcessorResult<V>> entryProcessor) throws ServiceException Description copied from interface:JournalServiceProcesses journal entries that were added since the last time this method was called for this journal on this cluster node.This method does not return entries that were added immediately before calling this method. Use JournalService.waitForRecentEntriesToBecomeVisible()for ensuring these entries will be included.This method can miss some entries due to identifier assignment and entry insertion not being an atomic operation. The risk of missed entries can be reduced by creating new entries as close to transaction commit as possible. If entryProcessor throws an exception, the same entries will be returned again when this method is next called for this journal on this cluster node. New journal is automatically created if a journal with the given name does not exists. - Specified by:
- processEntriesin interface- JournalService
- Parameters:
- journalId- only entries with this journal id will be returned
- maxEntries- maximum number of entries to process
- entryProcessor- function that will process entries that were added since the last time
- Returns:
- result of entryProcessor
- Throws:
- ServiceException- if entries could not be fetched or the journal state could not be saved
 
 - 
waitForRecentEntriesToBecomeVisiblepublic void waitForRecentEntriesToBecomeVisible() throws InterruptedExceptionDescription copied from interface:JournalServiceWaits long enough to ensure that entries added before calling this method will be available to subsequent call toJournalService.processNewEntries(JournalIdentifier, int, Function).- Specified by:
- waitForRecentEntriesToBecomeVisiblein interface- JournalService
- Throws:
- InterruptedException- if the thread got interrupted
 
 - 
peekpublic Iterable<JournalEntry> peek(@NonNull JournalIdentifier journalId, int maxEntries) throws ServiceException Description copied from interface:JournalServiceReturn a copy of journal entries that are waiting to be processed.- Specified by:
- peekin interface- JournalService
- Parameters:
- journalId- only entries with this journal id will be returned
- maxEntries- maximum number of entries to return
- Returns:
- a copy of journal entries that are waiting to be processed
- Throws:
- ServiceException- if entries could not be fetched
 
 - 
resetpublic void reset(@NonNull JournalIdentifier journalId) throws ServiceException Description copied from interface:JournalServiceResets the state of the journal so that all entries currently in the journal will be skipped.- Specified by:
- resetin interface- JournalService
- Parameters:
- journalId- identifier of the journal to reset
- Throws:
- ServiceException- if the reset fails
 
 - 
countEntriespublic int countEntries(@NonNull JournalIdentifier journalId) throws ServiceException Description copied from interface:JournalServiceCounts the number of entries in a journal.- Specified by:
- countEntriesin interface- JournalService
- Parameters:
- journalId- identifier of the journal
- Throws:
- ServiceException- if entries could not be counted
 
 
- 
 
-