class FileSystemQueue<E>
extends java.util.AbstractQueue<E>
Eine Queue, die zur Speicherung von Daten ausschließlich das Dateisystem verwendet. Diese Klasse ist nicht Threadsafe.
Modifier and Type | Class and Description |
---|---|
private class |
FileSystemQueue.Itr |
Modifier and Type | Field and Description |
---|---|
private BufferedFile |
_bufferedFile |
private java.io.DataInputStream |
_dataInputStream |
private java.io.DataOutputStream |
_dataOutputStream |
private static Debug |
_debug |
private long |
_fileHeadPosition |
private long |
_fileSizeInUse |
private long |
_fileTailPosition |
private int |
_maxBufferSize |
private long |
_maximumFileSize |
private QueueSerializer<E> |
_queueSerializer |
private int |
_size |
Constructor and Description |
---|
FileSystemQueue(long maximumFileSize,
QueueSerializer<E> queueSerializer)
Eine Queue, die zur Speicherung von Daten ausschließlich das Dateisystem verwendet
|
FileSystemQueue(long maximumFileSize,
QueueSerializer<E> queueSerializer,
int maxBufferSize)
Eine Queue, die zur Speicherung von Daten ausschließlich das Dateisystem verwendet
|
Modifier and Type | Method and Description |
---|---|
void |
clear() |
long |
getCapacity() |
long |
getDiskUsed() |
java.util.Iterator<E> |
iterator()
Returns an iterator over the elements contained in this collection.
|
boolean |
offer(E e)
Inserts the specified element into this queue if it is possible to do so immediately without violating capacity restrictions.
|
E |
peek()
Retrieves, but does not remove, the head of this queue, or returns null if this queue is empty.
|
E |
poll()
Retrieves and removes the head of this queue, or returns null if this queue is empty.
|
private E |
read() |
int |
size() |
java.lang.String |
toString() |
private void |
write(E e) |
contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
private static final Debug _debug
private final int _maxBufferSize
private long _fileHeadPosition
private long _fileSizeInUse
private final long _maximumFileSize
private final QueueSerializer<E> _queueSerializer
private int _size
private long _fileTailPosition
private final BufferedFile _bufferedFile
private final java.io.DataOutputStream _dataOutputStream
private final java.io.DataInputStream _dataInputStream
public FileSystemQueue(long maximumFileSize, QueueSerializer<E> queueSerializer)
Eine Queue, die zur Speicherung von Daten ausschließlich das Dateisystem verwendet
maximumFileSize
- Maximalgröße der Datei in Bytes. Diese kann um maximal eine Elementgröße überschritten werden, sodass immer mindestens ein Eintrag in die Datei passt.public FileSystemQueue(long maximumFileSize, QueueSerializer<E> queueSerializer, int maxBufferSize)
Eine Queue, die zur Speicherung von Daten ausschließlich das Dateisystem verwendet
maximumFileSize
- Maximalgröße der Datei in Bytes. Diese kann um maximal eine Elementgröße überschritten werden, sodass immer mindestens ein Eintrag in die Datei passt.maxBufferSize
- Maximale Größe für den Schreib- und Lesebuffer für Datei-Ein- und Ausgaben. Kleine Werte verringern den Speicherverbrauch, senken aber auch die Performance.public java.util.Iterator<E> iterator()
Returns an iterator over the elements contained in this collection.
public int size()
public boolean offer(E e)
Inserts the specified element into this queue if it is possible to do so immediately without violating capacity restrictions. When using a capacity-restricted queue, this method is generally preferable to AbstractQueue.add(E)
, which can fail to insert an element only by throwing an exception.
e
- the element to addjava.lang.ClassCastException
- if the class of the specified element prevents it from being added to this queuejava.lang.NullPointerException
- if the specified element is null and this queue does not permit null elementsjava.lang.IllegalArgumentException
- if some property of this element prevents it from being added to this queueprivate E read() throws java.io.IOException
java.io.IOException
private void write(E e) throws java.io.IOException
java.io.IOException
public E poll()
Retrieves and removes the head of this queue, or returns null if this queue is empty.
public E peek()
Retrieves, but does not remove, the head of this queue, or returns null if this queue is empty.
public java.lang.String toString()
toString
in class java.util.AbstractCollection<E>
public long getDiskUsed()
public long getCapacity()