Class DefaultJournalManager
- java.lang.Object
-
- com.atlassian.confluence.impl.journal.DefaultJournalManager
-
- All Implemented Interfaces:
JournalManager,JournalManagerBackdoor
public class DefaultJournalManager extends Object implements JournalManager, JournalManagerBackdoor
This is the default implementation ofJournalManager.- Since:
- 5.6
-
-
Constructor Summary
Constructors Constructor Description DefaultJournalManager(JournalDao journalDao, JournalStateStore journalStateStore, long ignoreWithinMillis)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated 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.voidenqueue(@NonNull Collection<JournalEntry> entries)Adds a collection of entries to a journal.longgetIgnoreWithinMillis()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>,@NonNull EntryProcessorResult<V>> entryProcessor)Deprecated.since 7.0.1.<V> VprocessNewEntries(@NonNull JournalIdentifier journalId, int maxEntries, @NonNull Function<Iterable<JournalEntry>,@NonNull 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.voidsetIgnoreWithinMillis(long ignoreWithinMillis)voidwaitForRecentEntriesToBecomeVisible()Waits long enough to ensure that entries added before calling this method will be available to subsequent call toJournalManager.processNewEntries(JournalIdentifier, int, Function).
-
-
-
Constructor Detail
-
DefaultJournalManager
public DefaultJournalManager(JournalDao journalDao, JournalStateStore journalStateStore, long ignoreWithinMillis)
-
-
Method Detail
-
enqueue
public long enqueue(@NonNull JournalEntry entry)
Description copied from interface:JournalManagerAdds the given entry to a journal.New journal is automatically created if a journal with the given name does not exists.
- Specified by:
enqueuein interfaceJournalManager- Parameters:
entry- entry to persist- Returns:
- id generated for the entry
-
enqueue
public void enqueue(@NonNull Collection<JournalEntry> entries) throws ServiceException
Description copied from interface:JournalManagerAdds a collection of entries to a journal.
- Specified by:
enqueuein interfaceJournalManager- Parameters:
entries- entries to persist- Throws:
ServiceException- if one of entries could not be persisted. In this case, the transaction is rolled back and no entries are persisted
-
peek
public Iterable<JournalEntry> peek(@NonNull JournalIdentifier journalId, int maxEntries)
Description copied from interface:JournalManagerReturn a copy of journal entries that are waiting to be processed.- Specified by:
peekin interfaceJournalManager- Parameters:
journalId- only entries with this journal id will be returnedmaxEntries- maximum number of entries to return- Returns:
- a copy of journal entries that are waiting to be processed
-
reset
public void reset(@NonNull JournalIdentifier journalId)
Description copied from interface:JournalManagerResets the state of the journal so that all entries currently in the journal will be skipped.- Specified by:
resetin interfaceJournalManager- Parameters:
journalId- identifier of the journal to reset
-
countEntries
public int countEntries(@NonNull JournalIdentifier journalId)
Description copied from interface:JournalManagerCounts the number of entries in a journal.- Specified by:
countEntriesin interfaceJournalManager- Parameters:
journalId- identifier of the journal
-
processNewEntries
public <V> V processNewEntries(@NonNull JournalIdentifier journalId, int maxEntries, @NonNull Function<Iterable<JournalEntry>,@NonNull EntryProcessorResult<V>> entryProcessor) throws org.springframework.dao.DataAccessException
Description copied from interface:JournalManagerProcesses 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
JournalManager.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:
processNewEntriesin interfaceJournalManager- Parameters:
journalId- only entries with this journal id will be returnedmaxEntries- maximum number of entries to processentryProcessor- function that will process entries that were added since the last time- Returns:
- result of entryProcessor
- Throws:
org.springframework.dao.DataAccessException- if entries could not be fetched or the journal state could not be saved
-
processEntries
@Deprecated public <V> V processEntries(@NonNull JournalIdentifier journalId, int maxEntries, @NonNull com.google.common.base.Function<Iterable<JournalEntry>,@NonNull EntryProcessorResult<V>> entryProcessor) throws org.springframework.dao.DataAccessException
Deprecated.since 7.0.1. UseprocessNewEntries(JournalIdentifier, int, Function)Description copied from interface:JournalManagerProcesses 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
JournalManager.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 interfaceJournalManager- Parameters:
journalId- only entries with this journal id will be returnedmaxEntries- maximum number of entries to processentryProcessor- function that will process entries that were added since the last time- Returns:
- result of entryProcessor
- Throws:
org.springframework.dao.DataAccessException- if entries could not be fetched or the journal state could not be saved
-
waitForRecentEntriesToBecomeVisible
public void waitForRecentEntriesToBecomeVisible() throws InterruptedExceptionDescription copied from interface:JournalManagerWaits long enough to ensure that entries added before calling this method will be available to subsequent call toJournalManager.processNewEntries(JournalIdentifier, int, Function).- Specified by:
waitForRecentEntriesToBecomeVisiblein interfaceJournalManager- Throws:
InterruptedException- if the thread got interrupted
-
getIgnoreWithinMillis
public long getIgnoreWithinMillis()
- Specified by:
getIgnoreWithinMillisin interfaceJournalManager- Specified by:
getIgnoreWithinMillisin interfaceJournalManagerBackdoor- Returns:
- the time that new entries are ignored
-
setIgnoreWithinMillis
public void setIgnoreWithinMillis(long ignoreWithinMillis)
- Specified by:
setIgnoreWithinMillisin interfaceJournalManagerBackdoor
-
-