java.lang.Object
net.i2p.router.StatisticsManager
Collects and publishes router performance statistics to the network database. Provides bandwidth, tunnel, and peer metrics for router capability advertising.
Field Summary
Modifier and TypeFieldDescriptionprivate final RouterContextThe router context.private final DecimalFormatThe number format of the stats.private final LogThe log for the statistics.private final StringThe network id to report.private final DecimalFormatThe percent format of the stats.static final StringConfig property controlling whether to publish peer rankings.private static final intEnhance anonymity by only including build stats one out of this many times.private static final booleanWhether the simple stats format is used.private static final String[]The names of the tunnel build stats.Constructor Summary
ConstructorsConstructorDescriptionStatisticsManager(RouterContext context) Captures the router context and prepares the number and percentage formatters.Method Summary
Modifier and TypeMethodDescriptionprivate static StringThe period label of a rate.private voidincludeRate(String rateName, Properties stats, long[] selectedPeriods, boolean fudgeQuantity) Include a named rate's data in the published stats.private voidincludeTunnelRates(String tunnelType, Properties stats, long selectedPeriod) Add tunnel build rates with some mods to hide absolute quantities In particular, report counts normalized to 100 (i.e.private final Stringnum(double num) Formats a number for the stats.private final Stringpct(double num) Formats a percentage for the stats.Retrieve a snapshot of the statistics that should be published.Retrieve a snapshot of the statistics that should be published.private StringrenderRate(Rate rate, boolean fudgeQuantity) Simple format, only what stats.i2p needs:private StringrenderRate(Rate rate, double fudgeQuantity) Simple format, only what stats.i2p needs:voidrenderStatusHTML(Writer out) Render the status in HTML.
Field Details
_log
The log for the statistics._context
The router context._networkID
The network id to report.PROP_PUBLISH_RANKINGS
Config property controlling whether to publish peer rankings.- See Also:
RANDOM_INCLUDE_STATS
private static final int RANDOM_INCLUDE_STATSEnhance anonymity by only including build stats one out of this many times.- See Also:
SIMPLE_STATS
private static final boolean SIMPLE_STATSWhether the simple stats format is used.- See Also:
_fmt
The number format of the stats._pct
The percent format of the stats.tunnelStats
The names of the tunnel build stats.
Constructor Details
StatisticsManager
Captures the router context and prepares the number and percentage formatters.- Parameters:
context- the router context supplying the identity, rates and config
Method Details
publishStatistics
Retrieve a snapshot of the statistics that should be published.This includes all standard options (as of 0.9.24, network ID and caps).
- Returns:
- the statistics as an unsigned Properties set
publishStatistics
Retrieve a snapshot of the statistics that should be published.This includes all standard options (as of 0.9.24, network ID and caps).
- Parameters:
h- current router hash, non-null- Returns:
- the statistics as an unsigned Properties set
includeRate
private void includeRate(String rateName, Properties stats, long[] selectedPeriods, boolean fudgeQuantity) Include a named rate's data in the published stats.- Parameters:
rateName- the rate to includestats- the properties to add toselectedPeriods- the periods to include, or null for allfudgeQuantity- the data being published in this stat is too sensitive to, uh publish, so we're kludge the quantity (allowing the fairly safe publication of the average values
renderRate
Simple format, only what stats.i2p needs:average
Previous format:
avg;extreme avg;pct of lifetime avg; if lifetime total event time greater than zero: lastEventSaturation;lastSaturationLimit;extremeEventSaturation;extremeSaturationLimit; event count; if number of periods greater than zero: avg freq;exteremeEventCount;lifetimeEventCount;- Parameters:
rate- the rate to renderfudgeQuantity- true to replace the event counts with the placeholder 555, hiding absolute quantities- Returns:
- the semicolon-separated statistics fields
includeTunnelRates
Add tunnel build rates with some mods to hide absolute quantities In particular, report counts normalized to 100 (i.e. a percentage).- Parameters:
tunnelType- the tunnel type in the rate name, e.g. Exploratorystats- the properties the rendered rates are stored inselectedPeriod- the rate period in milliseconds to report
renderRate
Simple format, only what stats.i2p needs:0;0;0;percent or event count
Previous format: see above
- Parameters:
rate- the rate to renderfudgeQuantity- the value rendered in place of the event count, normally the count normalized to 100- Returns:
- the semicolon-separated statistics fields
getPeriod
num
Formats a number for the stats.- Parameters:
num- the number to format- Returns:
- the formatted text
pct
Formats a percentage for the stats.- Parameters:
num- the percentage to format- Returns:
- the formatted text
renderStatusHTML
Render the status in HTML. Intentionally a no-op.- Parameters:
out- accepted and left untouched, since this implementation renders nothing