public class Rate extends Object
| Constructor and Description |
|---|
Rate(long period)
A rate with period shorter than Router.COALESCE_TIME = 50*1000 has to
be manually coalesced before values are fetched from it.
|
Rate(Properties props,
String prefix,
boolean treatAsCurrent)
Create a new rate and load its state from the properties, taking data
from the data points underneath the given prefix.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addData(long value)
Accrue the data in current period as an instantaneous event.
|
void |
addData(long value,
long eventDuration)
Accrue the data in current period as if the event took the specified amount of time
If value is always a constant, you should be using Frequency instead.
|
void |
coalesce() |
RateAverages |
computeAverages()
Computes the averages for this rate.
|
RateAverages |
computeAverages(RateAverages out,
boolean useLifetime)
Computes the averages and stores them in the provided object.
|
boolean |
equals(Object obj)
This is used in GraphGenerator and GraphListener.
|
double |
getAverageValue()
What was the average value across the events in the last period?
|
double |
getAvgOrLifetimeAvg()
Gets the average value, or the lifetime average if no recent data.
|
long |
getCreationDate()
when was this rate created?
|
long |
getCurrentEventCount()
in current (partial) period, how many events have occurred?
|
long |
getCurrentTotalEventTime()
in current (partial) period, how much of the time has been spent doing the events?
|
double |
getCurrentTotalValue()
in current (partial) period, what is the total value acrued through all events?
|
double |
getExtremeAverageValue()
During the extreme period (i.e.
|
long |
getExtremeEventCount()
when the max(totalValue) was achieved, how many events occurred in that period?
Note that this is not necesarily the highest event count; that isn't tracked.
|
double |
getExtremeEventSaturation()
During the extreme period (i.e.
|
double |
getExtremeSaturationLimit()
During the extreme period (i.e.
|
long |
getExtremeTotalEventTime()
when the max(totalValue) was achieved, how much of the time was spent doing the events?
|
double |
getExtremeTotalValue()
what was the max total value acrued in any period?
|
long |
getLastCoalesceDate()
when was the rate last coalesced?
|
long |
getLastEventCount()
in the last full period, how many events occurred?
|
double |
getLastEventSaturation()
During the last period, how much of the time was spent actually processing events in proportion
to how many events could have occurred if there were no intervals?
|
double |
getLastSaturationLimit()
using the last period's rate, what is the total value that could have been sent
if events were constant?
|
long |
getLastTotalEventTime()
in the last full period, how much of the time was spent doing the events?
|
double |
getLastTotalValue()
in the last full period, what was the total value acrued through all events?
|
double |
getLifetimeAverageValue()
What was the average value across the events since the stat was created?
|
long |
getLifetimeEventCount()
since rate creation, how many events have occurred?
|
double |
getLifetimeEventSaturation()
During the lifetime of this stat, how much of the time was spent actually processing events in proportion
to how many events could have occurred if there were no intervals?
|
long |
getLifetimePeriods()
how many periods have we already completed?
|
long |
getLifetimeTotalEventTime()
since rate creation, how much of the time was spent doing the events?
|
double |
getLifetimeTotalValue()
since rate creation, what was the total value acrued through all events?
|
double |
getPercentageOfExtremeValue()
What was the total value, compared to the total value in
the extreme period (i.e.
|
double |
getPercentageOfLifetimeValue()
How large was the last period's value as compared to the lifetime average value?
Warning- returns ratio, not percentage (i.e.
|
long |
getPeriod()
how large should this rate's cycle be?
|
RateStat |
getRateStat() |
RateSummaryListener |
getSummaryListener() |
int |
hashCode()
It doesn't appear that Rates are ever stored in a Set or Map
(RateStat stores in an array) so let's make this easy.
|
void |
load(Properties props,
String prefix,
boolean treatAsCurrent)
Load this rate from the properties, taking data from the data points underneath the given prefix.
|
void |
setRateStat(RateStat rs) |
void |
setSummaryListener(RateSummaryListener listener) |
void |
store(String prefix,
StringBuilder buf)
Stores the rate data to a string builder.
|
void |
store(String prefix,
StringBuilder buf,
boolean addComments)
Stores the rate data to a string builder.
|
String |
toString() |
public Rate(long period)
throws IllegalArgumentException
period - number of milliseconds in the period this rate deals with, min 1, max Integer.MAX_VALUEIllegalArgumentException - if the period is invalidpublic Rate(Properties props, String prefix, boolean treatAsCurrent) throws IllegalArgumentException
(e.g. prefix = "profile.dbIntroduction.60m", this will load the associated data points such as "profile.dbIntroduction.60m.lifetimeEventCount"). The data can be exported through store(outputStream, "profile.dbIntroduction.60m").
prefix - prefix to the property entries (should NOT end with a period)treatAsCurrent - if true, we'll treat the loaded data as if no time has
elapsed since it was written out, but if it is false, we'll
treat the data with as much freshness (or staleness) as appropriate.IllegalArgumentException - if the data was formatted incorrectlypublic void addData(long value)
public void addData(long value,
long eventDuration)
There are at least 4 possible strategies for eventDuration:
1) eventDuration is always zero.
The various get*Saturation*() and get*EventTime() methods will return zero.
2) Each eventDuration is relatively small, and reflects processing time.
This is probably the original meaning of "saturation", as it allows you
to track how much time is spent gathering the stats.
get*EventTime() will be close to 0.
get*EventSaturation() will return values close to 0,
get*SaturationLimit() will return adjusted values for the totals.
3) The total of the eventDurations are approximately equal to total elapsed time.
get*EventTime() will be close to the period.
get*EventSaturation() will return values close to 1,
get*SaturationLimit() will return adjusted values for the totals.
4) Each eventDuration is not a duration at all, but someother independent data.
get*EventTime() may be used to retrieve the data.
get*EventSaturation() are probably useless.
get*SaturationLimit() are probably useless.
value - value to accrue in current periodeventDuration - how long it took to accrue this data (set to 0 if it was instantaneous)public void coalesce()
public RateAverages computeAverages()
public RateAverages computeAverages(RateAverages out, boolean useLifetime)
out - where to store the computed averages.useLifetime - whether the lifetime average should be used if
there are no events.public boolean equals(Object obj)
public double getAverageValue()
public double getAvgOrLifetimeAvg()
public long getCreationDate()
public long getCurrentEventCount()
public long getCurrentTotalEventTime()
public double getCurrentTotalValue()
public double getExtremeAverageValue()
public long getExtremeEventCount()
public double getExtremeEventSaturation()
public double getExtremeSaturationLimit()
public long getExtremeTotalEventTime()
public double getExtremeTotalValue()
public long getLastCoalesceDate()
public long getLastEventCount()
public double getLastEventSaturation()
public double getLastSaturationLimit()
public long getLastTotalEventTime()
public double getLastTotalValue()
public double getLifetimeAverageValue()
public long getLifetimeEventCount()
public double getLifetimeEventSaturation()
public long getLifetimePeriods()
public long getLifetimeTotalEventTime()
public double getLifetimeTotalValue()
public double getPercentageOfExtremeValue()
public double getPercentageOfLifetimeValue()
public long getPeriod()
public RateStat getRateStat()
public RateSummaryListener getSummaryListener()
public int hashCode()
public void load(Properties props, String prefix, boolean treatAsCurrent) throws IllegalArgumentException
prefix - prefix to the property entries (should NOT end with a period)treatAsCurrent - if true, we'll treat the loaded data as if no time has elapsed since it was
written out, but if it is false, we'll treat the data with as much freshness
(or staleness) as appropriate.IllegalArgumentException - if the data was formatted incorrectlypublic void setRateStat(RateStat rs)
public void setSummaryListener(RateSummaryListener listener)
public void store(String prefix, StringBuilder buf) throws IOException
IOExceptionpublic void store(String prefix, StringBuilder buf, boolean addComments) throws IOException
addComments - add comment lines to the outputIOException