Class RandomNumberMetric

  • All Implemented Interfaces:
    MetricAgent

    public class RandomNumberMetric
    extends java.lang.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

      Constructors 
      Constructor Description
      RandomNumberMetric​(long seed)
      Creates a new random metric with a given seed.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      JabbixMetric<java.lang.Double> getMetric​(java.lang.String key)
      Returns a value of a normally distributed random number.
      java.util.Random getRandom()
      Returns the random number generator.
      void setRandom​(java.util.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<java.lang.Double> getMetric​(java.lang.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​(java.util.Random random)
        Sets a random generator.
        Parameters:
        random - a random generator to use
      • getRandom

        public java.util.Random getRandom()
        Returns the random number generator.
        Returns:
        the random number generator that is used for value retrieval