public class ResponseQueue extends ZabbixClient implements MetricTable<JabbixActiveMetric<?>>, java.lang.Runnable
JabbixActiveMetric
entries to be sent to the server and a link to an
other queue to return sent values to.
When an active metric value is added to the queue its expiration counter is reset. Because of that a value is sent to the server when its whole expiration period is passed or when that is the case for some other value.
Constructor and Description |
---|
ResponseQueue(java.net.InetSocketAddress addr,
MetricTable<JabbixActiveMetric<?>> returnTable)
Create a response queue object with the specified parameters.
|
Modifier and Type | Method and Description |
---|---|
MetricTable<JabbixActiveMetric<?>> |
getReturnTable()
Returns the queue object used to return sent metric objects to.
|
boolean |
isTerminated()
Indicates whether the wait-and-send loop is terminated.
|
void |
run()
Starts the queue wait-and-send loop.
|
void |
terminate()
Terminates this queue wait-and-send loop.
|
void |
updateMetric(JabbixActiveMetric<?> freshMetric)
Adds the given metric to the queue.
|
getAddress, getHostName, setAddress, setAddress, setAddress, setAddress, setHostName
public ResponseQueue(java.net.InetSocketAddress addr, MetricTable<JabbixActiveMetric<?>> returnTable)
addr
- remote server socket addressreturnTable
- a table to return sent active metrics topublic void run()
terminate()
method the process waits for any
active metric value in the queue to expire and then send the whole queue
contents in the "agent data" request. Then the collection of sent metric
objects is offered back to a return table.run
in interface java.lang.Runnable
JabbixJSONProtocol.sendMetricList(JabbixWriter, String, Collection)
,
getReturnTable()
public void updateMetric(JabbixActiveMetric<?> freshMetric)
JabbixActiveMetric.setActive(boolean)
) is
toggled. That action should reset the expiration counter of a metric.updateMetric
in interface MetricTable<JabbixActiveMetric<?>>
freshMetric
- a metric to addJabbixMetric.equals(Object)
public MetricTable<JabbixActiveMetric<?>> getReturnTable()
public boolean isTerminated()
run()
public void terminate()
run()