Package org.altlinux.jabbix
Class MetricRequest<M extends JabbixMetric<?>>
- java.lang.Object
-
- org.altlinux.jabbix.MetricRequest<M>
-
- Type Parameters:
M
-
- All Implemented Interfaces:
java.lang.Runnable
public class MetricRequest<M extends JabbixMetric<?>> extends java.lang.Object implements java.lang.Runnable
A task object encapsulating the process of the metric value retrieval using a metric agent both synchronously and asynchronously.- Author:
- Paul Wolneykien
-
-
Constructor Summary
Constructors Constructor Description MetricRequest(AgentServer agentServer, M metric, MetricTable<M> table)
Constructs a metric request task object with the specified parameters.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JabbixMetric<?>
getFreshMetric()
Returns a new metric instance with the fresh value for the metric specified on the request construction.void
run()
Used to retrieve and update the metric value asynchronously.void
setAgentServer(AgentServer agentServer)
Sets the metric agent server to query for new values.void
updateMetric(M metric)
Updates the value of the given metric making a request to the suitable metric agent.
-
-
-
Constructor Detail
-
MetricRequest
public MetricRequest(AgentServer agentServer, M metric, MetricTable<M> table)
Constructs a metric request task object with the specified parameters.- Parameters:
agentServer
- a metric agent server using to get the suitable metric agent for a metric being requestedmetric
- a metric to retrieve a fresh value fortable
- an optional metric table object to pass the updated metric object to
-
-
Method Detail
-
run
public void run()
Used to retrieve and update the metric value asynchronously. By the end the updated metric may by passed to an update table.- Specified by:
run
in interfacejava.lang.Runnable
-
getFreshMetric
public JabbixMetric<?> getFreshMetric() throws JabbixException, NoSuchMetricException
Returns a new metric instance with the fresh value for the metric specified on the request construction.- Returns:
- a new metric instance with the fresh value
- Throws:
JabbixException
- on the exception case during the value retrievalNoSuchMetricException
- if a metric agent for the specified metric is not found
-
updateMetric
public void updateMetric(M metric) throws JabbixException, NoSuchMetricException
Updates the value of the given metric making a request to the suitable metric agent.- Parameters:
metric
- a metric to update- Throws:
JabbixException
- on the exception case during the value retrievalNoSuchMetricException
- if a metric agent for the specified metric is not found
-
setAgentServer
public void setAgentServer(AgentServer agentServer)
Sets the metric agent server to query for new values.- Parameters:
agentServer
- a metric agent server
-
-