Package com.wavefront.agent.queueing
Interface QueueFile
-
- All Superinterfaces:
AutoCloseable,Closeable,Iterable<byte[]>
- All Known Implementing Classes:
ConcurrentQueueFile,ConcurrentShardedQueueFile,TapeQueueFile
public interface QueueFile extends Closeable, Iterable<byte[]>
Proxy-specific FIFO queue interface for storingbyte[]. This allows us to potentially support multiple backing storages in the future.- Author:
- [email protected]
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default voidadd(byte[] data)Adds an element to the end of the queue.voidadd(byte[] data, int offset, int count)Adds an element to the end of the queue.longavailableBytes()Returns the number of bytes available for adding new tasks without growing the file.voidclear()Clears this queue.default booleanisEmpty()Checks whether this queue is empty.byte[]peek()Reads the eldest element.voidremove()Removes the eldest element.intsize()Returns the number of elements in this queue.longstorageBytes()Returns the storage size (on-disk file size) in bytes.longusedBytes()Returns the number of bytes used for data.-
Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
-
-
-
Method Detail
-
add
default void add(byte[] data) throws IOExceptionAdds an element to the end of the queue.- Parameters:
data- to copy bytes from- Throws:
IOException
-
add
void add(byte[] data, int offset, int count) throws IOExceptionAdds an element to the end of the queue.- Parameters:
data- to copy bytes fromoffset- to start from in buffercount- number of bytes to copy- Throws:
IndexOutOfBoundsException- ifoffset < 0orcount < 0, or ifoffset + countis bigger than the length ofbuffer.IOException
-
clear
void clear() throws IOExceptionClears this queue. Truncates the file to the initial size.- Throws:
IOException
-
isEmpty
default boolean isEmpty()
Checks whether this queue is empty.- Returns:
- true if this queue contains no entries
-
peek
@Nullable byte[] peek() throws IOException
Reads the eldest element. Returns null if the queue is empty.- Returns:
- the eldest element.
- Throws:
IOException
-
remove
void remove() throws IOExceptionRemoves the eldest element.- Throws:
NoSuchElementException- if the queue is emptyIOException
-
size
int size()
Returns the number of elements in this queue.
-
storageBytes
long storageBytes()
Returns the storage size (on-disk file size) in bytes.- Returns:
- file size in bytes.
-
usedBytes
long usedBytes()
Returns the number of bytes used for data.- Returns:
- bytes used.
-
availableBytes
long availableBytes()
Returns the number of bytes available for adding new tasks without growing the file.- Returns:
- bytes available.
-
-