|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.archive.queue.DiskBackedQueue
public class DiskBackedQueue
Queue which uses a DiskQueue ('tailQ') for spillover entries once a in-memory LinkedList ('headQ') reaches a maximum size.
Field Summary | |
---|---|
protected static float |
DISCARD_BACKING_THRESHOLD
if all contents would leave head less than this percent full, discard the backing file(s) |
protected int |
headMax
|
protected java.util.LinkedList |
headQ
|
protected java.lang.String |
name
|
protected DiskQueue |
tailQ
|
Constructor Summary | |
---|---|
DiskBackedQueue(java.io.File dir,
java.lang.String name,
boolean reuse,
int headMax)
|
Method Summary | |
---|---|
protected java.lang.Object |
backingDequeue()
|
protected void |
backingUpdate()
|
protected boolean |
canDiscardBacking()
|
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 |
protected void |
discardBacking()
|
void |
disconnect()
Release any file-handles in arecoverable way. |
void |
enqueue(java.lang.Object o)
Add an entry to the end of queue |
protected void |
fillHeadQ()
|
java.util.Iterator |
getIterator(boolean inCacheOnly)
Returns an iterator for the queue. |
protected int |
headTargetSize()
|
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 |
setHeadMax(int hm)
Set the maximum number of items to keep in memory at the structure's top. |
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 |
---|
protected static final float DISCARD_BACKING_THRESHOLD
protected int headMax
protected java.util.LinkedList headQ
protected DiskQueue tailQ
protected java.lang.String name
Constructor Detail |
---|
public DiskBackedQueue(java.io.File dir, java.lang.String name, boolean reuse, int headMax) throws java.io.IOException
dir
- name
- reuse
- whether to reuse any existing backing filesheadMax
-
java.io.IOException
Method Detail |
---|
public void enqueue(java.lang.Object o)
Queue
enqueue
in interface Queue
o
- the entry to queueQueue.enqueue(java.lang.Object)
public boolean isEmpty()
Queue
isEmpty
in interface Queue
true
if the queue has no elementsQueue.isEmpty()
public java.lang.Object dequeue()
Queue
dequeue
in interface Queue
Queue.dequeue()
protected void backingUpdate()
protected void discardBacking()
public void disconnect()
protected boolean canDiscardBacking()
protected void fillHeadQ()
protected java.lang.Object backingDequeue()
protected int headTargetSize()
public long length()
Queue
length
in interface Queue
Queue.length()
public void release()
Queue
release
in interface Queue
Queue.release()
public java.lang.Object peek()
Queue
peek
in interface Queue
Queue.peek()
public void unpeek()
Queue
unpeek
in interface Queue
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 Queue
Queue.getIterator(boolean)
public long deleteMatchedItems(org.apache.commons.collections.Predicate matcher)
Queue
matcher.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 Queue
matcher
- a predicate
Queue.deleteMatchedItems(org.apache.commons.collections.Predicate)
public void setHeadMax(int hm)
hm
- Maximum number of items to keep in memory.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |