public class EventCounterInterval extends Object implements Interval
Interval for use by EventCounter.| Modifier and Type | Field and Description |
|---|---|
protected long |
events
Number of events that have been counted in this interval
|
| Constructor and Description |
|---|
EventCounterInterval() |
EventCounterInterval(long inDuration,
long inStartTime)
Constructs a new
EventCounterInterval. |
| Modifier and Type | Method and Description |
|---|---|
void |
add(int inCount)
Registers the occurrence of n new events.
|
EventCounterInterval |
copy(EventCounterInterval inFrom) |
long |
getCumulativeEvents()
Gets the total number of events, including those that occurred
in previous intervals.
|
long |
getDuration()
Gets the duration, in milliseconds, of this
Interval |
float |
getEventRatePerSecond()
Returns the computed event rate per second during this
Interval. |
long |
getEvents()
Gets the number of events counted during this interval.
|
long |
getStartTime()
Gets a timestamp corresponding to the start of this
Interval
in System.currentTimeMillis() format. |
long |
intervalsBefore(long inTime)
Returns the number of intervals that have elapsed between this
Interval and the time specified by the argument. |
boolean |
isPast()
Returns true if the current time is after the end of this interval.
|
void |
setClosed(boolean closed)
Marks the interval as open or closed.
|
String |
toString()
Summarizes this
Interval as a String for display purposes. |
protected volatile long events
public EventCounterInterval()
public EventCounterInterval(long inDuration,
long inStartTime)
EventCounterInterval.
This constructor is not public because Intervals are
constructed only via Metric according to the Abstract Factory
design pattern.inDuration - - length of this intervalinStartTime - - time stamp of the first millisecond of the intervalpublic EventCounterInterval copy(EventCounterInterval inFrom)
public long getDuration()
IntervalIntervalgetDuration in interface Intervalpublic long getStartTime()
IntervalInterval
in System.currentTimeMillis() format.getStartTime in interface IntervalIntervalpublic float getEventRatePerSecond()
IntervalInterval.
If the current time falls within this interval, consider only the time that has passed.
Otherwise, consider the entire duration of the interval.getEventRatePerSecond in interface Intervalpublic long getEvents()
Intervalpublic long getCumulativeEvents()
IntervalgetCumulativeEvents in interface Intervalpublic void add(int inCount)
Intervalpublic void setClosed(boolean closed)
Intervalpublic boolean isPast()
Intervalpublic long intervalsBefore(long inTime)
Interval and the time specified by the argument.
The argument is typically a recently-noted timestamp.intervalsBefore in interface IntervalinTime - - reference point in timeCopyright © 2015. All rights reserved.