Package org.altlinux.jabbix
Class ActiveMetricTable
- java.lang.Object
-
- org.altlinux.jabbix.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 ofJabbixActiveMetricentries with an expiration period for the whole queue. TherefreshPeriodproperty and thegetDelay(TimeUnit)method of theDelayedinterface 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 intcompareTo(java.util.concurrent.Delayed o)Indicates if the current table is less than, equal to or greater than the givenDelayedobject.intcompareTo(ActiveMetricTable a)Indicates if the current table is less than, equal to or greater than the given one.longgetDelay(java.util.concurrent.TimeUnit unit)Returns the remaining time for the queue data assumed to be fresh.java.util.DategetNextRefresh()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.longgetRefreshPeriod()Returns the refresh period of the queue.booleanisExpired()Indicates whether the queue data is expired.voidsetRefreshPeriod(long refreshPeriod)Sets the refresh period for the whole queue to the specified value.voidupdateMetric(JabbixActiveMetric<?> freshMetric)Adds the given metric to the queue.
-
-
-
Method Detail
-
updateMetric
public void updateMetric(JabbixActiveMetric<?> freshMetric)
Adds the given metric to the queue.- Specified by:
updateMetricin interfaceMetricTable<JabbixActiveMetric<?>>- Parameters:
freshMetric- a metric to add- See Also:
JabbixMetric.equals(Object)
-
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 thenextRefreshvalue is set in accordance with the old value or the current system time.If the given value is 0 then the
nextRefreshvalue 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:
getDelayin interfacejava.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 givenDelayedobject. Tables are compared using thecompareTo(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:
compareToin interfacejava.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 thenextCheckproperties 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
-
-