Package org.altlinux.jabbix
Class JabbixActiveMetric<T>
- java.lang.Object
-
- org.altlinux.jabbix.JabbixMetric<T>
-
- org.altlinux.jabbix.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 intcompareTo(java.util.concurrent.Delayed o)Indicates if the current metric is less than, equal to or greater than the givenDelayedobject.intcompareTo(JabbixActiveMetric<?> m)Indicates if the current metric is less than, equal to or greater than the given one.longgetDelay(java.util.concurrent.TimeUnit unit)Returns the remaining time for the next refresh of the metric.java.util.DategetNextCheck()Returns the date and time this metric value should be refreshed (on the target server).longgetPeriod()Returns the value refresh period (in milliseconds).java.util.DategetUpdated()Indicates when (and whether) the metric value was updated.booleanisActive()Indicates either the metric is "active".voidsetActive(boolean active)Sets the metric "activity" status.-
Methods inherited from class org.altlinux.jabbix.JabbixMetric
equals, getKey, getValue, getValueType, toString, updateValue
-
-
-
-
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 metricperiod- the refresh period in millisecondsactive- the count-down status
-
-
Method Detail
-
isActive
public boolean isActive()
Indicates either the metric is "active". For an active metric thegetNextCheck()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 itsnextCheckproperty 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 thenextCheckis set to null. Otherwise thenextCheckis 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 theirnextCheckproperties 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 itsnextCheckvalue is not set) then the maximal long valueLong.MAX_VALUEis returned. Otherwise the difference between current time andnextCheckvalue is returned represented in the specified units.- Specified by:
getDelayin interfacejava.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 givenDelayedobject. Active metric objects are compared using thecompareTo(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:
compareToin interfacejava.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)
-
-