Class SimpleDistributionQueue
- java.lang.Object
-
- org.apache.sling.distribution.queue.impl.simple.SimpleDistributionQueue
-
- All Implemented Interfaces:
DistributionQueue
public class SimpleDistributionQueue extends Object implements DistributionQueue
A simple implementation of aDistributionQueue. Note that, at the moment, this is a transient in memory queue not persisted on the repository and therefore not usable for production. Note: potentially the Queue could contain the ordered package ids, with a sidecar map id,item; that way removal could be faster.
-
-
Constructor Summary
Constructors Constructor Description SimpleDistributionQueue(String agentName, String name)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DistributionQueueEntryadd(@NotNull DistributionQueueItem item)add a distribution item to this queue@NotNull Iterable<DistributionQueueEntry>clear(int limit)Clear a range of entries from the queue.@NotNull Iterable<DistributionQueueEntry>getEntries(int skip, int limit)get all the entries in the queue@Nullable DistributionQueueEntrygetEntry(@NotNull String id)gets an entry from the queue by specifying its id@Nullable DistributionQueueEntrygetHead()get the first entry (in a FIFO strategy, the next to be processed) from the queue@NotNull StringgetName()get this queue name@NotNull DistributionQueueStatusgetStatus()get the status of the queue@NotNull DistributionQueueTypegetType()get the type of this queuebooleanhasCapability(@NotNull String capability)voidrecordProcessingAttempt(@NotNull DistributionQueueEntry entry)@Nullable DistributionQueueEntryremove(@NotNull String id)remove an entry from the queue by specifying its id@NotNull Iterable<DistributionQueueEntry>remove(@NotNull Set<String> entryIds)Remove a set entries from the queue by specifying their identifiers.StringtoString()
-
-
-
Method Detail
-
getName
@NotNull public @NotNull String getName()
Description copied from interface:DistributionQueueget this queue name- Specified by:
getNamein interfaceDistributionQueue- Returns:
- the queue name
-
add
public DistributionQueueEntry add(@NotNull @NotNull DistributionQueueItem item)
Description copied from interface:DistributionQueueadd a distribution item to this queue- Specified by:
addin interfaceDistributionQueue- Parameters:
item- a distribution item, typically representing aDistributionPackageto distribute- Returns:
- the queue entry created for this item or
nollif none is created
-
getHead
@Nullable public @Nullable DistributionQueueEntry getHead()
Description copied from interface:DistributionQueueget the first entry (in a FIFO strategy, the next to be processed) from the queue- Specified by:
getHeadin interfaceDistributionQueue- Returns:
- the first entry into the queue or
nullif the queue is empty
-
getStatus
@NotNull public @NotNull DistributionQueueStatus getStatus()
Description copied from interface:DistributionQueueget the status of the queue- Specified by:
getStatusin interfaceDistributionQueue- Returns:
- the queue status
-
getType
@NotNull public @NotNull DistributionQueueType getType()
Description copied from interface:DistributionQueueget the type of this queue- Specified by:
getTypein interfaceDistributionQueue- Returns:
- the type
-
hasCapability
public boolean hasCapability(@NotNull @NotNull String capability)- Specified by:
hasCapabilityin interfaceDistributionQueue- Returns:
trueif the queue supports the capability ;falseotherwise
-
getEntries
@NotNull public @NotNull Iterable<DistributionQueueEntry> getEntries(int skip, int limit)
Description copied from interface:DistributionQueueget all the entries in the queue- Specified by:
getEntriesin interfaceDistributionQueue- Parameters:
skip- the number of entries to skiplimit- the maximum number of entries to return. use -1 to return all entries.- Returns:
- a
IterableofDistributionQueueEntryentries
-
getEntry
@Nullable public @Nullable DistributionQueueEntry getEntry(@NotNull @NotNull String id)
Description copied from interface:DistributionQueuegets an entry from the queue by specifying its id- Specified by:
getEntryin interfaceDistributionQueue- Parameters:
id- the entry identifier- Returns:
- the entry, or
nullif the entry with the given id doesn't exist
-
remove
@NotNull public @NotNull Iterable<DistributionQueueEntry> remove(@NotNull @NotNull Set<String> entryIds)
Description copied from interface:DistributionQueueRemove a set entries from the queue by specifying their identifiers.- Specified by:
removein interfaceDistributionQueue- Parameters:
entryIds- The identifiers of the entries to be removed- Returns:
- an iterable over the removed entries
-
remove
@Nullable public @Nullable DistributionQueueEntry remove(@NotNull @NotNull String id)
Description copied from interface:DistributionQueueremove an entry from the queue by specifying its id- Specified by:
removein interfaceDistributionQueue- Parameters:
id- the entry identifier- Returns:
- the removed entry, or
nullif the entry with the given id doesn't exist
-
clear
@NotNull public @NotNull Iterable<DistributionQueueEntry> clear(int limit)
Description copied from interface:DistributionQueueClear a range of entries from the queue. The range starts from the head entry, includes the specified #limit number of entries.- Specified by:
clearin interfaceDistributionQueue- Parameters:
limit- The maximum number of entries to remove. All entries are removed when the limit is-1.- Returns:
- an iterable over the removed entries
-
recordProcessingAttempt
public void recordProcessingAttempt(@NotNull @NotNull DistributionQueueEntry entry)
-
-