Package com.berryworks.jquantify
Class EventCounterInterval
- java.lang.Object
-
- com.berryworks.jquantify.EventCounterInterval
-
- All Implemented Interfaces:
Interval,Serializable
- Direct Known Subclasses:
SessionCounterInterval
public class EventCounterInterval extends Object implements Interval
This class implementsIntervalfor use byEventCounter.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected longeventsNumber of events that have been counted in this interval
-
Constructor Summary
Constructors Constructor Description EventCounterInterval()EventCounterInterval(long inDuration, long inStartTime)Constructs a newEventCounterInterval.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(int inCount)Registers the occurrence of n new events.EventCounterIntervalcopy(EventCounterInterval inFrom)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 inTime)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.StringtoString()Summarizes thisIntervalas a String for display purposes.
-
-
-
Constructor Detail
-
EventCounterInterval
public EventCounterInterval()
-
EventCounterInterval
public EventCounterInterval(long inDuration, long inStartTime)Constructs a newEventCounterInterval.This constructor is not public because
Intervals are constructed only viaMetricaccording to the Abstract Factory design pattern.- Parameters:
inDuration- - length of this intervalinStartTime- - time stamp of the first millisecond of the interval
-
-
Method Detail
-
copy
public EventCounterInterval copy(EventCounterInterval inFrom)
-
getDuration
public long getDuration()
Description copied from interface:IntervalGets the duration, in milliseconds, of thisInterval- Specified by:
getDurationin interfaceInterval- Returns:
- long - number of seconds
-
getStartTime
public long getStartTime()
Description copied from interface:IntervalGets a timestamp corresponding to the start of thisIntervalinSystem.currentTimeMillis()format.- Specified by:
getStartTimein interfaceInterval- Returns:
- start time of this
Interval
-
getEventRatePerSecond
public float getEventRatePerSecond()
Description copied from interface:IntervalReturns 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.
- Specified by:
getEventRatePerSecondin interfaceInterval- Returns:
- events per second
-
getEvents
public long getEvents()
Description copied from interface:IntervalGets the number of events counted during this interval.
-
getCumulativeEvents
public long getCumulativeEvents()
Description copied from interface:IntervalGets the total number of events, including those that occurred in previous intervals.- Specified by:
getCumulativeEventsin interfaceInterval- Returns:
- number of events
-
add
public void add(int inCount)
Description copied from interface:IntervalRegisters the occurrence of n new events.Intended for internal use only.
-
setClosed
public void setClosed(boolean closed)
Description copied from interface:IntervalMarks 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.
-
isPast
public boolean isPast()
Description copied from interface:IntervalReturns true if the current time is after the end of this interval.
-
intervalsBefore
public long intervalsBefore(long inTime)
Returns the number of intervals that have elapsed between thisIntervaland the time specified by the argument.The argument is typically a recently-noted timestamp.
- Specified by:
intervalsBeforein interfaceInterval- Parameters:
inTime- - reference point in time- Returns:
- long - number of intervals
-
-