org.altlinux.jabbix
Class MetricRequest<M extends JabbixMetric<?>>

java.lang.Object
  extended by org.altlinux.jabbix.MetricRequest<M>
Type Parameters:
M -
All Implemented Interfaces:
Runnable

public class MetricRequest<M extends JabbixMetric<?>>
extends Object
implements 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
MetricRequest(AgentServer agentServer, M metric, MetricTable<M> table)
          Constructs a metric request task object with the specified parameters.
 
Method Summary
 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.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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 requested
metric - a metric to retrieve a fresh value for
table - 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 interface 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 retrieval
NoSuchMetricException - 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 retrieval
NoSuchMetricException - 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