T
- type of the index task@Internal public abstract class AbstractJournalIndexTaskQueue<T extends IndexTask> extends Object implements IndexTaskQueue<T>
IndexTaskQueue
implementations that are backed by the journal.
Subclass implementations supply the type of IndexTask
that is queued.
Subclass implementations also supply logic to convert from their supplied IndexTask
type to a
JournalEntry
(and logic for the reverse).
Modifier and Type | Field and Description |
---|---|
protected AnyTypeDao |
anyTypeDao |
protected IndexFlushRequester |
indexFlushRequester |
static JournalIdentifier |
JOURNAL_ID |
protected JournalService |
journalService |
Constructor and Description |
---|
AbstractJournalIndexTaskQueue(JournalService journalService,
AnyTypeDao anyTypeDao,
IndexFlushRequester indexFlushRequester) |
Modifier and Type | Method and Description |
---|---|
void |
enqueue(T task)
Add a new task to this queue.
|
void |
enqueueAll(Collection<T> tasks)
Add a collection of tasks to this queue.
|
List<T> |
flushQueue()
Deprecated.
|
int |
flushQueue(com.atlassian.fugue.Effect<T> action)
Deprecated.
since 7.0.1. Use
IndexTaskQueue.flushAndExecute(Consumer) |
int |
flushQueue(com.atlassian.fugue.Effect<T> action,
int numberOfEntries)
Deprecated.
since 7.0.1. Use
IndexTaskQueue.flushAndExecute(Consumer, int) |
List<T> |
flushQueue(int numberOfEntries)
Deprecated.
|
int |
flushQueueWithActionOnIterableOfTasks(Consumer<Iterable<T>> actionOnIterableOfTasks,
int numberOfTasks)
Flush the contents of the queue, applying the given action to an iterable of tasks.
|
List<T> |
getQueuedEntries()
Retrieve a list of all of the queued entries.
|
int |
getSize()
Retrieve the number of elements in the queue.
|
void |
reset()
Remove all queued index tasks from this queue.
|
protected abstract Optional<JournalEntry> |
toEntry(T task)
Convert a task into a journal entry.
|
protected abstract T |
toTask(JournalEntry entry)
Convert an entry to a task.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
flushAndExecute, flushAndExecute
@Internal public static final JournalIdentifier JOURNAL_ID
protected final JournalService journalService
protected final AnyTypeDao anyTypeDao
protected final IndexFlushRequester indexFlushRequester
public AbstractJournalIndexTaskQueue(JournalService journalService, AnyTypeDao anyTypeDao, IndexFlushRequester indexFlushRequester)
protected abstract T toTask(JournalEntry entry)
entry
- a journal entry.protected abstract Optional<JournalEntry> toEntry(T task)
task
- a taskpublic int getSize()
IndexTaskQueue
getSize
in interface IndexTaskQueue<T extends IndexTask>
public List<T> getQueuedEntries()
IndexTaskQueue
getQueuedEntries
in interface IndexTaskQueue<T extends IndexTask>
public void enqueue(T task)
IndexTaskQueue
enqueue
in interface IndexTaskQueue<T extends IndexTask>
public void enqueueAll(Collection<T> tasks)
IndexTaskQueue
enqueueAll
in interface IndexTaskQueue<T extends IndexTask>
@Deprecated public List<T> flushQueue(int numberOfEntries)
IndexTaskQueue
Tasks that were added immediately before calling this method are not
returned. See IndexTaskQueue.flushQueue()
for an alternative.
flushQueue
in interface IndexTaskQueue<T extends IndexTask>
numberOfEntries
- the maximum number of entries to return. This should return the n first entries in the queue.@Deprecated public List<T> flushQueue()
IndexTaskQueue
This method waits until tasks that we added immediately before calling
this method are available. See IndexTaskQueue.flushQueue(int)
for an
alternative.
flushQueue
in interface IndexTaskQueue<T extends IndexTask>
@Deprecated public int flushQueue(com.atlassian.fugue.Effect<T> action)
IndexTaskQueue.flushAndExecute(Consumer)
IndexTaskQueue
This method waits until tasks that we added immediately before calling
this method are available. See
IndexTaskQueue.flushAndExecute(Consumer, int)
for an alternative.
flushQueue
in interface IndexTaskQueue<T extends IndexTask>
action
- action to perform for each entry@Deprecated public int flushQueue(com.atlassian.fugue.Effect<T> action, int numberOfEntries)
IndexTaskQueue.flushAndExecute(Consumer, int)
IndexTaskQueue
Tasks that were added immediately before calling this method are not
returned. See IndexTaskQueue.flushAndExecute(Consumer)
for an
alternative.
flushQueue
in interface IndexTaskQueue<T extends IndexTask>
action
- action to perform for each entrynumberOfEntries
- the maximum number of entries to flush. This
should flush the n first entries in the queue.public int flushQueueWithActionOnIterableOfTasks(Consumer<Iterable<T>> actionOnIterableOfTasks, int numberOfTasks)
IndexTaskQueue
IndexTaskQueue.flushQueue(Effect, int)
applys an action to an individual task. In contrast, this method applies
an action to an iterable of tasks.
If the specified action throws a RuntimeException, tasks are returned to the queue so that they can be processed again. The exception will be propagated so clients must handle it accordingly.
flushQueueWithActionOnIterableOfTasks
in interface IndexTaskQueue<T extends IndexTask>
actionOnIterableOfTasks
- action on iterable of tasksnumberOfTasks
- the maximum number of tasks to retrieve from the queuepublic void reset()
IndexTaskQueue
reset
in interface IndexTaskQueue<T extends IndexTask>
Copyright © 2003–2019 Atlassian. All rights reserved.