java.lang.Object
net.i2p.router.web.helpers.StatsGenerator
Dump the stats to the web admin interface.
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classTranslated sort Inner class, can't be Serializable.Field Summary
FieldsModifier and TypeFieldDescriptionprivate final RouterContextThe router whose stats are written.private static final ThreadLocal<DecimalFormat> Formatter for plain numbers.private static final ThreadLocal<DecimalFormat> Formatter for percentages.Constructor Summary
ConstructorsConstructorDescriptionStatsGenerator(RouterContext context) Hold the router context whose StatManager supplies the stats.Method Summary
Modifier and TypeMethodDescriptionprivate StringTranslate a string.private StringTranslate a string carrying one parameter.(package private) static StringdownloadName(String name) The download filename offered for a stat's XML export.voidgenerateCSV(Writer out, String filter) Generate CSV export of all stats (optionally filtered by name).voidgenerateStatsPage(Writer out, boolean showAll, String filter) Render the stats page as HTML.private StringTranslate a string whose form depends on a count (ngettext).private static final Stringnum(double num) Formats a plain number.private static final Stringpct(double num) Formats a percentage.private voidrenderFrequency(String name, StringBuilder buf) Writes one frequency statistic.private static voidrenderPeriod(StringBuilder buf, long period, String name) Writes one period column of a rate table.private voidrenderRate(String name, StringBuilder buf, boolean showAll) Writes one rate statistic.
Field Details
_context
The router whose stats are written._fmt
Formatter for plain numbers._pct
Formatter for percentages.
Constructor Details
StatsGenerator
Hold the router context whose StatManager supplies the stats.- Parameters:
context- the router context whose StatManager supplies the stats
Method Details
generateCSV
Generate CSV export of all stats (optionally filtered by name).- Parameters:
out- where the CSV text is written and flushedfilter- optional case-insensitive stat name substring, null or empty for every stat- Throws:
IOException- if the writer fails partway through the export
generateStatsPage
Render the stats page as HTML.- Parameters:
out- where the HTML is writtenshowAll- true to include the saturation and per-period extremes that are hidden in the default viewfilter- optional stat name substring filter (case-insensitive), null for all- Throws:
IOException- if the writer fails partway through the page
renderFrequency
Writes one frequency statistic.- Parameters:
name- the stat's namebuf- where the text is written
renderRate
Writes one rate statistic.- Parameters:
name- the stat's namebuf- where the text is writtenshowAll- true to write every time period
renderPeriod
Writes one period column of a rate table.- Parameters:
buf- where the text is writtenperiod- the period length, in msname- the stat's name
downloadName
The download filename offered for a stat's XML export.Stat names carry dots, spaces and, for a per-tunnel stat, brackets around a user-supplied nickname, all of which landed in the download attribute verbatim, so a nickname holding a double quote closed the attribute early. Dots and spaces become underscores and anything HTML-significant is escaped; a plain name such as
bw.sendRatestill readsgraphdata_bw_sendRate.xml.- Parameters:
name- the stat name as registered- Returns:
- a filename safe inside a quoted HTML attribute
num
Formats a plain number.- Parameters:
num- the value to format- Returns:
- the text to show
pct
Formats a percentage.- Parameters:
num- the value to format- Returns:
- the text to show
_t
_t
ngettext