public class ActiveMetricTable extends java.lang.Object implements MetricTable<JabbixActiveMetric<?>>, java.util.concurrent.Delayed
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.Constructor and Description |
---|
ActiveMetricTable(long refreshPeriod)
Creates the table with the specified expiration period.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(ActiveMetricTable a)
Indicates if the current table is less than, equal to or greater than
the given one.
|
int |
compareTo(java.util.concurrent.Delayed o)
Indicates if the current table is less than, equal to or greater than
the given
Delayed object. |
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.
|
public ActiveMetricTable(long refreshPeriod)
refreshPeriod
- the queue expiration periodpublic void updateMetric(JabbixActiveMetric<?> freshMetric)
updateMetric
in interface MetricTable<JabbixActiveMetric<?>>
freshMetric
- a metric to addJabbixMetric.equals(Object)
public void setRefreshPeriod(long refreshPeriod)
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.
refreshPeriod
- the refresh period in millisecondspublic long getRefreshPeriod()
public java.util.Date getNextRefresh()
public boolean isExpired()
public long getDelay(java.util.concurrent.TimeUnit unit)
getDelay
in interface java.util.concurrent.Delayed
public int compareTo(java.util.concurrent.Delayed o)
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.compareTo
in interface java.lang.Comparable<java.util.concurrent.Delayed>
o
- the object to compare topublic int compareTo(ActiveMetricTable a)
nextCheck
properties of the
tables.a
- another table to compare withpublic java.util.concurrent.DelayQueue<JabbixActiveMetric<?>> getQueue()