Class JabbixActiveMetric<T>

  • Type Parameters:
    T - the type of a metric value
    All Implemented Interfaces:
    java.lang.Comparable<java.util.concurrent.Delayed>, java.util.concurrent.Delayed

    public class JabbixActiveMetric<T>
    extends JabbixMetric<T>
    implements java.util.concurrent.Delayed
    A metric with additional information to be used for active metric reporting.
    Author:
    Paul Wolneykien
    • Constructor Summary

      Constructors 
      Constructor Description
      JabbixActiveMetric​(java.lang.String key, java.lang.Class<T> type, T value, long period, boolean active)
      Creates a new active metric entry with the specified parameters.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int compareTo​(java.util.concurrent.Delayed o)
      Indicates if the current metric is less than, equal to or greater than the given Delayed object.
      int compareTo​(JabbixActiveMetric<?> m)
      Indicates if the current metric is less than, equal to or greater than the given one.
      long getDelay​(java.util.concurrent.TimeUnit unit)
      Returns the remaining time for the next refresh of the metric.
      java.util.Date getNextCheck()
      Returns the date and time this metric value should be refreshed (on the target server).
      long getPeriod()
      Returns the value refresh period (in milliseconds).
      java.util.Date getUpdated()
      Indicates when (and whether) the metric value was updated.
      boolean isActive()
      Indicates either the metric is "active".
      void setActive​(boolean active)
      Sets the metric "activity" status.
      • Methods inherited from class java.lang.Object

        getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • JabbixActiveMetric

        public JabbixActiveMetric​(java.lang.String key,
                                  java.lang.Class<T> type,
                                  T value,
                                  long period,
                                  boolean active)
        Creates a new active metric entry with the specified parameters.
        Parameters:
        key - the name of the metric
        period - the refresh period in milliseconds
        active - the count-down status
    • Method Detail

      • isActive

        public boolean isActive()
        Indicates either the metric is "active". For an active metric the getNextCheck() property is non-null.
        Returns:
        the metric active status
      • setActive

        public void setActive​(boolean active)
        Sets the metric "activity" status. If the status of a metric changes from inactive to active then its nextCheck property is set to the sum of current time value and the period value specified for the metric ( getPeriod()). If the status of a metric changes form active to inactive then the nextCheck is set to null. Otherwise the nextCheck is leaved unchanged.
        Parameters:
        active - the status value to be set
      • getNextCheck

        public java.util.Date getNextCheck()
        Returns the date and time this metric value should be refreshed (on the target server).
        Returns:
        the next refresh time
      • getPeriod

        public long getPeriod()
        Returns the value refresh period (in milliseconds).
        Returns:
        the value refresh period
      • compareTo

        public int compareTo​(JabbixActiveMetric<?> m)
        Indicates if the current metric is less than, equal to or greater than the given one. One metric is less than the other if its refresh is expected sooner. If both metrics are active then their nextCheck properties are compared. Otherwise the active metric is always less that the inactive one (so the inactive entries are always sit at the end of the queue).
        Parameters:
        m - active metric to compare to
        Returns:
        below zero number if this metric is to be sent sooner than the given one, zero if both metrics are to be sent in the same time and above zero number if this metric is to be sent later than the given one
        See Also:
        ActiveMetricTable
      • getDelay

        public long getDelay​(java.util.concurrent.TimeUnit unit)
        Returns the remaining time for the next refresh of the metric. If the metric is not active (and its nextCheck value is not set) then the maximal long value Long.MAX_VALUE is returned. Otherwise the difference between current time and nextCheck value is returned represented in the specified units.
        Specified by:
        getDelay in interface java.util.concurrent.Delayed
        Returns:
        remaining time for the next refresh of the metric represented in the specified time units
      • compareTo

        public int compareTo​(java.util.concurrent.Delayed o)
        Indicates if the current metric is less than, equal to or greater than the given Delayed object. Active metric objects are compared using the compareTo(JabbixActiveMetric) method. If the given object is not an active metric then the metric is supposed to be less (sooner) than the given object.
        Specified by:
        compareTo in interface java.lang.Comparable<T>
        Parameters:
        o - the object to compare to
        Returns:
        below zero number if this metric is expired sooner than the given object, zero if both objects are expired in the same time and above zero number if this metric is expired later than the given object
      • getUpdated

        public java.util.Date getUpdated()
        Indicates when (and whether) the metric value was updated.
        Returns:
        the date and time the metric value was updated or null if this metric value never was updated
        See Also:
        JabbixMetric.updateValue(java.lang.Object)