Package org.altlinux.jabbix
Class ResponseQueue
- java.lang.Object
-
- org.altlinux.jabbix.ZabbixClient
-
- org.altlinux.jabbix.ResponseQueue
-
- All Implemented Interfaces:
java.lang.Runnable
,MetricTable<JabbixActiveMetric<?>>
public class ResponseQueue extends ZabbixClient implements MetricTable<JabbixActiveMetric<?>>, java.lang.Runnable
A Zabbix server client that send metric values to the server when some value expires its refresh period. Holding an updatable queue ofJabbixActiveMetric
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.
- Author:
- Paul Wolneykien
-
-
Constructor Summary
Constructors Constructor Description ResponseQueue(java.net.InetSocketAddress addr, MetricTable<JabbixActiveMetric<?>> returnTable)
Create a response queue object with the specified parameters.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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.-
Methods inherited from class org.altlinux.jabbix.ZabbixClient
getAddress, getHostName, setAddress, setAddress, setAddress, setAddress, setHostName
-
-
-
-
Constructor Detail
-
ResponseQueue
public ResponseQueue(java.net.InetSocketAddress addr, MetricTable<JabbixActiveMetric<?>> returnTable)
Create a response queue object with the specified parameters. A separate return table is used to hold sent values. The two-table (internal queue table and a return table) mechanism is used to prevent metrics the server no longer interested in to resist in the queue for the whole process lifetime.- Parameters:
addr
- remote server socket addressreturnTable
- a table to return sent active metrics to
-
-
Method Detail
-
run
public void run()
Starts the queue wait-and-send loop. While the loop is not terminated by theterminate()
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.- Specified by:
run
in interfacejava.lang.Runnable
- See Also:
JabbixJSONProtocol.sendMetricList(JabbixWriter, String, Collection)
,getReturnTable()
-
updateMetric
public void updateMetric(JabbixActiveMetric<?> freshMetric)
Adds the given metric to the queue. The active status of a metric (seeJabbixActiveMetric.setActive(boolean)
) is toggled. That action should reset the expiration counter of a metric.- Specified by:
updateMetric
in interfaceMetricTable<JabbixActiveMetric<?>>
- Parameters:
freshMetric
- a metric to add- See Also:
JabbixMetric.equals(Object)
-
getReturnTable
public MetricTable<JabbixActiveMetric<?>> getReturnTable()
Returns the queue object used to return sent metric objects to.- Returns:
- the queue to add sent metric objects to
-
isTerminated
public boolean isTerminated()
Indicates whether the wait-and-send loop is terminated.- Returns:
- true if this queue process is terminated
- See Also:
run()
-
terminate
public void terminate()
Terminates this queue wait-and-send loop.- See Also:
run()
-
-