Class ActiveMetricTable

  • All Implemented Interfaces:
    java.lang.Comparable<java.util.concurrent.Delayed>, java.util.concurrent.Delayed, MetricTable<JabbixActiveMetric<?>>

    public class ActiveMetricTable
    extends java.lang.Object
    implements MetricTable<JabbixActiveMetric<?>>, java.util.concurrent.Delayed
    An updatable queue of JabbixActiveMetric entries with an expiration period for the whole queue. The refreshPeriod property and the getDelay(TimeUnit) method of the Delayed interface can be used to set and track the expiration date of the queue. As the information for the active checks is server-originated it is provident to make periodical updates for the set of active metric objects not to run out of date.
    Author:
    Paul Wolneykien
    • Constructor Summary

      Constructors 
      Constructor Description
      ActiveMetricTable​(long refreshPeriod)
      Creates the table with the specified expiration period.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int compareTo​(java.util.concurrent.Delayed o)
      Indicates if the current table is less than, equal to or greater than the given Delayed object.
      int compareTo​(ActiveMetricTable a)
      Indicates if the current table is less than, equal to or greater than the given one.
      long getDelay​(java.util.concurrent.TimeUnit unit)
      Returns the remaining time for the queue data assumed to be fresh.
      java.util.Date getNextRefresh()
      Returns the queue expiration date and time.
      java.util.concurrent.DelayQueue<JabbixActiveMetric<?>> getQueue()
      Returns the queue with the active metric objects placed in accordance with their expiration dates.
      long getRefreshPeriod()
      Returns the refresh period of the queue.
      boolean isExpired()
      Indicates whether the queue data is expired.
      void setRefreshPeriod​(long refreshPeriod)
      Sets the refresh period for the whole queue to the specified value.
      void updateMetric​(JabbixActiveMetric<?> freshMetric)
      Adds the given metric to the queue.
      • Methods inherited from class java.lang.Object

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

      • ActiveMetricTable

        public ActiveMetricTable​(long refreshPeriod)
        Creates the table with the specified expiration period.
        Parameters:
        refreshPeriod - the queue expiration period
    • Method Detail

      • setRefreshPeriod

        public void setRefreshPeriod​(long refreshPeriod)
        Sets the refresh period for the whole queue to the specified value. Each time the refresh period value is updated the nextRefresh value is set in accordance with the old value or the current system time.

        If the given value is 0 then the nextRefresh value is set to null and no periodical refreshes of the table are provided.

        Parameters:
        refreshPeriod - the refresh period in milliseconds
      • getRefreshPeriod

        public long getRefreshPeriod()
        Returns the refresh period of the queue.
        Returns:
        the refresh period of the queue in milliseconds
      • getNextRefresh

        public java.util.Date getNextRefresh()
        Returns the queue expiration date and time.
        Returns:
        the queue expiration date and time
      • isExpired

        public boolean isExpired()
        Indicates whether the queue data is expired.
        Returns:
        true if the queue is expired, false otherwise
      • getDelay

        public long getDelay​(java.util.concurrent.TimeUnit unit)
        Returns the remaining time for the queue data assumed to be fresh.
        Specified by:
        getDelay in interface java.util.concurrent.Delayed
        Returns:
        the remaining time for the queue to expire in the given time units
      • compareTo

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

        public int compareTo​(ActiveMetricTable a)
        Indicates if the current table is less than, equal to or greater than the given one. One table is less that the other if its refresh is expected sooner. Return value is obtained by the comparison of the nextCheck properties of the tables.
        Parameters:
        a - another table to compare with
        Returns:
        below zero number if this table is expired sooner than the given one, zero if both tables are expired in the same time and above zero number if this table is expired later than the given one
      • getQueue

        public java.util.concurrent.DelayQueue<JabbixActiveMetric<?>> getQueue()
        Returns the queue with the active metric objects placed in accordance with their expiration dates.
        Returns:
        the queue with the active metric objects