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 void
add(byte[] data)
Adds an element to the end of the queue.void
add(byte[] data, int offset, int count)
Adds an element to the end of the queue.long
availableBytes()
Returns the number of bytes available for adding new tasks without growing the file.void
clear()
Clears this queue.default boolean
isEmpty()
Checks whether this queue is empty.byte[]
peek()
Reads the eldest element.void
remove()
Removes the eldest element.int
size()
Returns the number of elements in this queue.long
storageBytes()
Returns the storage size (on-disk file size) in bytes.long
usedBytes()
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 IOException
Adds 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 IOException
Adds 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 < 0
orcount < 0
, or ifoffset + count
is bigger than the length ofbuffer
.IOException
-
clear
void clear() throws IOException
Clears 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 IOException
Removes 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.
-
-