|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.archive.queue.TieredQueue
public class TieredQueue
A queue with multiple internal queues, numbered 0 to n. Dequeues come from lower-numbered queues before higher-numbered queues. The standard enqueue() places an item at the back of the highest-numbered queue. Other variants of enqueue place items on specific queues. A peek() guarantees that the item returned by peek() will be returned by the next dequeue(), even if other items are enqueued to lower-numbered internal queues in the meantime. (The unpeek() may be used to release the TieredQueue from this guarantee; the next peek()/dequeue() will then return the item available from the lowest-numbered queue.)
| Field Summary | |
|---|---|
(package private) java.lang.Object |
headObject
|
(package private) int |
headSource
|
(package private) Queue[] |
innerQueues
|
(package private) int |
lastQueue
|
(package private) long |
length
|
| Constructor Summary | |
|---|---|
TieredQueue(int tiers)
Create a TieredQueue with the given number of internal queue slots. |
|
| Method Summary | |
|---|---|
long |
deleteMatchedItems(org.apache.commons.collections.Predicate matcher)
All objects in the queue where matcher.match(object)
returns true will be deleted from the queue. |
java.lang.Object |
dequeue()
remove an entry from the start of the queue |
void |
enqueue(java.lang.Object obj)
Add an entry to the end of queue |
void |
enqueue(java.lang.Object obj,
int tier)
Enqueue the object to the given tier. |
java.util.Iterator |
getIterator(boolean inCacheOnly)
Returns an iterator for the queue. |
void |
initializeDiskBackedQueues(java.io.File scratchDir,
java.lang.String tmpName,
int inMemCap)
Initialize all innerQueues to be DiskBackedQueues in the given scratch directory, using the tmpName prefix. |
boolean |
isEmpty()
is the queue empty? |
long |
length()
get the number of elements in the queue |
java.lang.Object |
peek()
Give the top object in the queue, leaving it in place to be returned by future peek() or dequeue() invocations. |
void |
release()
release any OS/IO resources associated with Queue |
void |
setMemoryResidentQueueCap(int inMemCap)
Set the total number of in-memory items, assuming the underlying subqueues are DiskBackedQueue instances. |
void |
setQueue(int tier,
Queue q)
Set the internal queue tier to be the supplied Queue instance. |
void |
unpeek()
Releases queue from the obligation to return in the next peek()/dequeue() the same object as returned by any previous peek(). |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
java.lang.Object headObject
int headSource
Queue[] innerQueues
int lastQueue
long length
| Constructor Detail |
|---|
public TieredQueue(int tiers)
| Method Detail |
|---|
public void enqueue(java.lang.Object obj)
Queue
enqueue in interface Queueobj - the entry to queue
public void enqueue(java.lang.Object obj,
int tier)
public boolean isEmpty()
Queue
isEmpty in interface Queuetrue if the queue has no elements
public java.lang.Object dequeue()
throws java.util.NoSuchElementException
Queue
dequeue in interface Queuejava.util.NoSuchElementExceptionpublic long length()
Queue
length in interface Queuepublic void release()
Queue
release in interface Queuepublic java.lang.Object peek()
Queue
peek in interface Queuepublic void unpeek()
Queue
unpeek in interface Queue
public void setQueue(int tier,
Queue q)
tier - Tier level to set.q - Queue to use.public java.util.Iterator getIterator(boolean inCacheOnly)
Queue
The returned iterator's remove method is considered
unsafe.
Editing the queue while using the iterator is not safe.
getIterator in interface Queuepublic long deleteMatchedItems(org.apache.commons.collections.Predicate matcher)
Queuematcher.match(object)
returns true will be deleted from the queue.
Making other changes to the queue while this method is being processed is not safe.
deleteMatchedItems in interface Queuematcher - a predicate
public void initializeDiskBackedQueues(java.io.File scratchDir,
java.lang.String tmpName,
int inMemCap)
throws java.io.IOException
scratchDir - Directory to put tmp files in.tmpName - Prefix to use in tmpnames.
java.io.IOExceptionpublic void setMemoryResidentQueueCap(int inMemCap)
inMemCap - Memory cap.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||