Package com.berryworks.jquantify
Interface Interval
-
- All Superinterfaces:
Serializable
- All Known Implementing Classes:
EventCounterInterval,SessionCounterInterval
public interface Interval extends Serializable
An object that counts events occurring during a single time slice within the life of aMetricinstance.The life of a
Metricis conceptually a sequence of non-overlapping intervals. EachIntervalhas a duration that is a whole number of seconds, and all intervals for a givenMetrichave a uniform duration. EachIntervalhas a start time, which can be determined from the start time of the previousIntervalof theMetricand its duration.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidadd(int count)Registers the occurrence of n new events.longgetCumulativeEvents()Gets the total number of events, including those that occurred in previous intervals.longgetDuration()Gets the duration, in milliseconds, of thisIntervalfloatgetEventRatePerSecond()Returns the computed event rate per second during thisInterval.longgetEvents()Gets the number of events counted during this interval.longgetStartTime()Gets a timestamp corresponding to the start of thisIntervalinSystem.currentTimeMillis()format.longintervalsBefore(long time)Returns the number of intervals that have elapsed between thisIntervaland the time specified by the argument.booleanisPast()Returns true if the current time is after the end of this interval.voidsetClosed(boolean closed)Marks the interval as open or closed.
-
-
-
Method Detail
-
getStartTime
long getStartTime()
Gets a timestamp corresponding to the start of thisIntervalinSystem.currentTimeMillis()format.- Returns:
- start time of this
Interval
-
getDuration
long getDuration()
Gets the duration, in milliseconds, of thisInterval- Returns:
- long - number of seconds
-
getEvents
long getEvents()
Gets the number of events counted during this interval.- Returns:
- number of events
-
getEventRatePerSecond
float getEventRatePerSecond()
Returns the computed event rate per second during thisInterval.If the current time falls within this interval, consider only the time that has passed. Otherwise, consider the entire duration of the interval.
- Returns:
- events per second
-
getCumulativeEvents
long getCumulativeEvents()
Gets the total number of events, including those that occurred in previous intervals.- Returns:
- number of events
-
isPast
boolean isPast()
Returns true if the current time is after the end of this interval.- Returns:
- true if the current time is beyond the end of this interval
-
add
void add(int count)
Registers the occurrence of n new events.Intended for internal use only.
- Parameters:
count- number of events to be counted
-
setClosed
void setClosed(boolean closed)
Marks the interval as open or closed.Intended for internal use only. A closed interval is one known to be fully in the past. By flagging an interval as closed, we can calculate such things as the event rate without sampling the clock.
- Parameters:
closed-
-
intervalsBefore
long intervalsBefore(long time)
Returns the number of intervals that have elapsed between thisIntervaland the time specified by the argument.- Parameters:
time- typically the current time- Returns:
- number of intervals
-
-