org.altlinux.jabbix.metric
Class RandomNumberMetric

java.lang.Object
  extended by org.altlinux.jabbix.metric.RandomNumberMetric
All Implemented Interfaces:
MetricAgent

public class RandomNumberMetric
extends Object
implements MetricAgent

A sample metric agent for the Jabbix library querying the random number generator for a value of a normally distributed random number. Because of only one metric to return it is returned for any given key.

Author:
Paul Wolneykien

Constructor Summary
RandomNumberMetric(long seed)
          Creates a new random metric with a given seed.
 
Method Summary
 JabbixMetric<Double> getMetric(String key)
          Returns a value of a normally distributed random number.
 Random getRandom()
          Returns the random number generator.
 void setRandom(Random random)
          Sets a random generator.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RandomNumberMetric

public RandomNumberMetric(long seed)
Creates a new random metric with a given seed.

Parameters:
seed - a random number generator seed
Method Detail

getMetric

public JabbixMetric<Double> getMetric(String key)
                               throws JabbixException,
                                      NoSuchMetricException
Returns a value of a normally distributed random number. Because of only one metric to return it is returned for any given key.

Specified by:
getMetric in interface MetricAgent
Parameters:
key - metric key, the name of a metric
Returns:
JabbixMetric object containing a randomly generated value
Throws:
NoSuchMetricException - if no metric with the specified key is found
JabbixException - in any other error case

setRandom

public void setRandom(Random random)
Sets a random generator.

Parameters:
random - a random generator to use

getRandom

public Random getRandom()
Returns the random number generator.

Returns:
the random number generator that is used for value retrieval