|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.archive.queue.DiskQueue
public class DiskQueue
Queue which stores all its objects to disk using object serialization, on top of a DiskBackedByteQueue. The serialization state is reset after each enqueue(). Care should be taken not to enqueue() items which will pull out excessive referenced objects, or objects which will be redundantly reinstantiated upon dequeue() from disk. This class is not synchronized internally.
| Field Summary | |
|---|---|
(package private) DiskByteQueue |
bytes
The object which shuffles raw bytes to/from disk. |
(package private) java.lang.Object |
headObject
top item in queue, pulled into memory for peek() |
(package private) java.io.ObjectInputStream |
headStream
|
(package private) long |
length
the number of elements currently in the queue |
(package private) java.lang.String |
prefix
the prefix for the files created in the scratchDir |
(package private) java.io.ObjectOutputStream |
tailStream
|
| Constructor Summary | |
|---|---|
DiskQueue(java.io.File file,
java.lang.String file_prefix)
Create a new DiskQueue which creates its temporary files in a
given directory, with a given prefix. |
|
DiskQueue(java.io.File dir,
java.lang.String prefix,
boolean reuse)
Create a new DiskQueue which creates its temporary files in a
given directory, with a given prefix, and reuse any prexisting backing
files as directed. |
|
| Method Summary | |
|---|---|
void |
connect()
Reconnect to disk-based backing |
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 |
disconnect()
Disconnect from any backing files, without deleting those files, allowing reattachment later. |
void |
enqueue(java.lang.Object o)
Add an entry to the end of queue |
java.util.Iterator |
getIterator(boolean inCacheOnly)
Returns an iterator for the queue. |
boolean |
isEmpty()
is the queue empty? |
protected boolean |
isInitialized()
|
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 |
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 |
|---|
long length
java.lang.Object headObject
java.lang.String prefix
DiskByteQueue bytes
transient java.io.ObjectOutputStream tailStream
transient java.io.ObjectInputStream headStream
| Constructor Detail |
|---|
public DiskQueue(java.io.File dir,
java.lang.String prefix,
boolean reuse)
throws java.io.IOException
DiskQueue which creates its temporary files in a
given directory, with a given prefix, and reuse any prexisting backing
files as directed.
dir - the directory in which to create the data filesprefix - reuse - whether to reuse any existing backing files
java.io.IOException - if we cannot create an appropriate file
public DiskQueue(java.io.File file,
java.lang.String file_prefix)
throws java.io.IOException
DiskQueue which creates its temporary files in a
given directory, with a given prefix.
file - file_prefix -
java.io.IOException| Method Detail |
|---|
protected boolean isInitialized()
public void enqueue(java.lang.Object o)
Queue
enqueue in interface Queueo - the entry to queueQueue.enqueue(java.lang.Object)public boolean isEmpty()
Queue
isEmpty in interface Queuetrue if the queue has no elementsQueue.isEmpty()public java.lang.Object dequeue()
Queue
dequeue in interface QueueQueue.dequeue()public java.lang.Object peek()
Queue
peek in interface QueueQueue.peek()public void unpeek()
Queue
unpeek in interface Queuepublic long length()
Queue
length in interface QueueQueue.length()public void release()
Queue
release in interface QueueQueue.release()public void disconnect()
public void connect()
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 QueueQueue.getIterator(boolean)public 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
Queue.deleteMatchedItems(org.apache.commons.collections.Predicate)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||