Package com.wavefront.agent.queueing
Class SynchronizedTaskQueueWithMetrics<T extends DataSubmissionTask<T>>
- java.lang.Object
-
- com.wavefront.agent.queueing.SynchronizedTaskQueueWithMetrics<T>
-
- Type Parameters:
T- type of objects stored.
public class SynchronizedTaskQueueWithMetrics<T extends DataSubmissionTask<T>> extends Object implements TaskQueue<T>
A thread-safe wrapper forTaskQueuethat reports queue metrics.- Author:
- [email protected]
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(T t)Add a task to the end of the queuevoidclear()Empty and re-initialize the queue.voidclose()Close the queue.LonggetAvailableBytes()Returns the total number of pre-allocated but unused bytes in the backing file.StringgetName()Returns the unique queue name/identifier, can be anything, like file path name for file-based queues.Iterator<T>iterator()Tpeek()Retrieve a task that is currently at the head of the queue.voidremove()Remove a task from the head of the queue.intsize()Returns a number of tasks currently in the queue.Longweight()Returns the total weight of the queue (sum of weights of all tasks).-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
SynchronizedTaskQueueWithMetrics
public SynchronizedTaskQueueWithMetrics(TaskQueue<T> delegate, @Nullable String metricPrefix, @Nullable Map<String,String> metricTags, @Nullable com.wavefront.data.ReportableEntityType entityType)
- Parameters:
delegate- delegateTaskQueue.metricPrefix- prefix for metric names (default: "buffer")metricTags- point tags for metrics (default: none)entityType- entity type (default: points)
-
-
Method Detail
-
peek
public T peek()
Description copied from interface:TaskQueueRetrieve a task that is currently at the head of the queue.- Specified by:
peekin interfaceTaskQueue<T extends DataSubmissionTask<T>>- Returns:
- task object
-
add
public void add(@Nonnull T t) throws IOException
Description copied from interface:TaskQueueAdd a task to the end of the queue- Specified by:
addin interfaceTaskQueue<T extends DataSubmissionTask<T>>- Parameters:
t- task- Throws:
IOException- IO exceptions caught by the storage engine
-
clear
public void clear()
Description copied from interface:TaskQueueEmpty and re-initialize the queue.- Specified by:
clearin interfaceTaskQueue<T extends DataSubmissionTask<T>>
-
remove
public void remove()
Description copied from interface:TaskQueueRemove a task from the head of the queue. Requires peek() to be called first, otherwise anIllegalStateExceptionis thrown.- Specified by:
removein interfaceTaskQueue<T extends DataSubmissionTask<T>>
-
size
public int size()
Description copied from interface:TaskQueueReturns a number of tasks currently in the queue.- Specified by:
sizein interfaceTaskQueue<T extends DataSubmissionTask<T>>- Returns:
- number of tasks
-
close
public void close() throws IOExceptionDescription copied from interface:TaskQueueClose the queue. Should be invoked before a graceful shutdown.- Specified by:
closein interfaceTaskQueue<T extends DataSubmissionTask<T>>- Throws:
IOException
-
weight
@Nullable public Long weight()
Description copied from interface:TaskQueueReturns the total weight of the queue (sum of weights of all tasks).- Specified by:
weightin interfaceTaskQueue<T extends DataSubmissionTask<T>>- Returns:
- weight of the queue (null if unknown)
-
getAvailableBytes
@Nullable public Long getAvailableBytes()
Description copied from interface:TaskQueueReturns the total number of pre-allocated but unused bytes in the backing file. May return null if not applicable.- Specified by:
getAvailableBytesin interfaceTaskQueue<T extends DataSubmissionTask<T>>- Returns:
- total number of available bytes in the file or null
-
getName
public String getName()
Description copied from interface:TaskQueueReturns the unique queue name/identifier, can be anything, like file path name for file-based queues.- Specified by:
getNamein interfaceTaskQueue<T extends DataSubmissionTask<T>>- Returns:
- queue name.
-
-