Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## net.i2p.stat
Class Rate

    java.lang.Object
      net.i2p.stat.Rate

    public class Rate

extends Object

Simple rate calculator for periodically sampled data points - determining an average value over a period, the number of events in that period, the maximum number of events (using the interval between events), and lifetime data.

Constructor Summary
`Rate(long period)`
`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.

Method Summary
`void` | `addData(long value)` accrue the data in the current period as an instantaneous event
`void` | `addData(long value, long eventDuration)` Accrue the data in the current period as if the event took the specified amount of time
`void` | `coalesce()`
`boolean` | `equals(Object obj)`
`double` | `getAverageValue()` what was the average value across the events in the last period?
`long` | `getCreationDate()` when was this rate created?
`long` | `getCurrentEventCount()` in the current (partial) period, how many events have occurred?
`long` | `getCurrentTotalEventTime()` in the current (partial) period, how much of the time has been spent doing the events?
`double` | `getCurrentTotalValue()` in the current (partial) period, what is the total value acrued through all events?
`double` | `getExtremeAverageValue()` what was the average value across the events in the most active period?
`long` | `getExtremeEventCount()` when the max(totalValue) was achieved, how many events occurred in that period?
`double` | `getExtremeEventSaturation()` During the extreme 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` | `getExtremeSaturationLimit()` using the extreme period's rate, what is the total value that could have been sent if events were constant?
`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()` How large was the last period's value as compared to the largest period ever?
`double` | `getPercentageOfLifetimeValue()` How large was the last period's value as compared to the lifetime average value?
`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.
`static void` | `main(String[] args)`
`void` | `setRateStat(RateStat rs)`
`void` | `setSummaryListener(RateSummaryListener listener)`
`void` | `store(String prefix, StringBuilder buf)`
`String` | `toString()`

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

Constructor Detail

### Rate

    public Rate(long period)
         throws IllegalArgumentException

Parameters:
  `period` - number of milliseconds in the period this rate deals with
Throws:
  `IllegalArgumentException` - if the period is not greater than 0

### Rate

    public Rate(Properties props,
                String prefix,
                boolean treatAsCurrent)
         throws IllegalArgumentException

  Create a new rate and load its state from the properties, taking data from the data points underneath the given prefix.

  (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").

  Parameters:
    `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.
  Throws:
    `IllegalArgumentException` - if the data was formatted incorrectly

Method Detail

### getCurrentTotalValue

    public double getCurrentTotalValue()

  in the current (partial) period, what is the total value acrued through all events?

### getCurrentEventCount

    public long getCurrentEventCount()

  in the current (partial) period, how many events have occurred?

### getCurrentTotalEventTime

    public long getCurrentTotalEventTime()

  in the current (partial) period, how much of the time has been spent doing the events?

### getLastTotalValue

    public double getLastTotalValue()

  in the last full period, what was the total value acrued through all events?

### getLastEventCount

    public long getLastEventCount()

  in the last full period, how many events occurred?

### getLastTotalEventTime

    public long getLastTotalEventTime()

  in the last full period, how much of the time was spent doing the events?

### getExtremeTotalValue

    public double getExtremeTotalValue()

  what was the max total value acrued in any period?

### getExtremeEventCount

    public long getExtremeEventCount()

  when the max(totalValue) was achieved, how many events occurred in that period?

### getExtremeTotalEventTime

    public long getExtremeTotalEventTime()

  when the max(totalValue) was achieved, how much of the time was spent doing the events?

### getLifetimeTotalValue

    public double getLifetimeTotalValue()

  since rate creation, what was the total value acrued through all events?

### getLifetimeEventCount

    public long getLifetimeEventCount()

  since rate creation, how many events have occurred?

### getLifetimeTotalEventTime

    public long getLifetimeTotalEventTime()

  since rate creation, how much of the time was spent doing the events?

### getLastCoalesceDate

    public long getLastCoalesceDate()

  when was the rate last coalesced?

### getCreationDate

    public long getCreationDate()

  when was this rate created?

### getPeriod

    public long getPeriod()

  how large should this rate's cycle be?

### getRateStat

    public RateStat getRateStat()

### setRateStat

    public void setRateStat(RateStat rs)

### addData

    public void addData(long value)

  accrue the data in the current period as an instantaneous event

### addData

    public void addData(long value,
                        long eventDuration)

  Accrue the data in the current period as if the event took the specified amount of time

  Parameters:
    `value` - value to accrue in the current period
    `eventDuration` - how long it took to accrue this data (set to 0 if it was instantaneous)

### coalesce

    public void coalesce()

### setSummaryListener

    public void setSummaryListener(RateSummaryListener listener)

### getSummaryListener

    public RateSummaryListener getSummaryListener()

### getAverageValue

    public double getAverageValue()

  what was the average value across the events in the last period?

### getExtremeAverageValue

    public double getExtremeAverageValue()

  what was the average value across the events in the most active period?

### getLifetimeAverageValue

    public double getLifetimeAverageValue()

  what was the average value across the events since the stat was created?

### getLastEventSaturation

    public 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?

  Returns:
    percentage, or 0 if event times aren't used

### getExtremeEventSaturation

    public double getExtremeEventSaturation()

  During the extreme 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?

  Returns:
    percentage, or 0 if the statistic doesn't use event times

### getLifetimeEventSaturation

    public 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?

  Returns:
    percentage, or 0 if event times aren't used

### getLifetimePeriods

    public long getLifetimePeriods()

  how many periods have we already completed?

### getLastSaturationLimit

    public double getLastSaturationLimit()

  using the last period's rate, what is the total value that could have been sent if events were constant?

  Returns:
    max total value, or 0 if event times aren't used

### getExtremeSaturationLimit

    public double getExtremeSaturationLimit()

  using the extreme period's rate, what is the total value that could have been sent if events were constant?

  Returns:
    event total at saturation, or 0 if no event times are measured

### getPercentageOfExtremeValue

    public double getPercentageOfExtremeValue()

  How large was the last period's value as compared to the largest period ever?

### getPercentageOfLifetimeValue

    public double getPercentageOfLifetimeValue()

  How large was the last period's value as compared to the lifetime average value?

### store

    public void store(String prefix,
                      StringBuilder buf)
               throws IOException

  Throws:
    `IOException`

### load

    public void load(Properties props,
                     String prefix,
                     boolean treatAsCurrent)
              throws IllegalArgumentException

  Load this rate from the properties, taking data from the data points underneath the given prefix.

  Parameters:
    `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.
  Throws:
    `IllegalArgumentException` - if the data was formatted incorrectly

### equals

    public boolean equals(Object obj)

  Overrides:
    `equals` in class `Object`

### hashCode

    public 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. We can always make something faster if it's actually used.

  Overrides:
    `hashCode` in class `Object`

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`

### main

    public static void main(String[] args)

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD