java.lang.Object
net.i2p.router.web.HelperBase
net.i2p.router.web.helpers.TuningHelper
Helper for the transport tuning page (tuning.jsp). Renders tunable param tables with inline SVG sparklines.
Field Summary
FieldsModifier and TypeFieldDescriptionprivate StringNonce proving the tuner form came from this router.Param name to human label.Maps each Tuner subsystem metric identifier (as reported byTuner.SubsystemScore.details) to the stat that backs it and a value format, so ring tooltips can show live values.Param name to console description, at most 70 characters since it renders beside its control in the tuning page.Single-word section heading for each subsystem.private static final intHeight of a sparkline graph, in pixels.private static final intWidth of a sparkline graph, in pixels.private static final String[]Subsystems in the order the tuner page displays them, alphabetical.Fields inherited from class HelperBase
_context, _log, _out, CHECKED, PROP_ADVANCED, SELECTEDModifier and TypeFieldDescriptionprotected RouterContextThe router context.protected LogThe log instance.protected WriterThe writer for output.static final StringChecked attribute for HTML checkboxes.static final StringProperty key for advanced mode.static final StringSelected attribute for HTML select options.Constructor Summary
ConstructorsConstructorDescriptionNo CSRF nonce set yet, so the rendered form would carry an empty hidden field untilsetNonce(String)is called.Method Summary
Modifier and TypeMethodDescriptionprivate static StringEscapes a value for display in HTML.(package private) static StringformatMetricValue(String format, double avg, long count1m) Format one metric value for a ring tooltip.private StringgetDisplayName(String name) Return a human-readable display name for a raw param name, falling back to the raw name if unmapped.private TunergetTuner()Get the SSU transport tuner instance.Main content: editable tables of tunable params with sparklines.private String[]metricDetails(String[] metrics) Resolve a subsystem's metric identifiers to tooltip lines carrying each stat's live value, e.g.private static StringrenderSparkline(int[] values, int defaultValue) Render an inline SVG sparkline.private StringrenderSubsystemRings(Tuner tuner, boolean defer) Render the subsystem ring chart dashboard.voidRecords the CSRF nonce embedded in the rendered tuning form.Methods inherited from class HelperBase
_t, _t, _t, _x, getChecked, isAdvanced, ngettext, setContextId, storeWriterModifier and TypeMethodDescriptionTranslate a string.Translate a string with a parameter.Translate a string with two parameters.static StringMark a string for extraction by xgettext and translation.protected StringgetChecked(String prop) Get the checked attribute for a boolean property.booleanCheck if advanced mode is enabled.Translate a string with plural forms (ngettext).voidsetContextId(String contextId) Configure this bean to query a particular router context.voidstoreWriter(Writer out) Store the writer for output.
Field Details
SPARK_W
private static final int SPARK_WWidth of a sparkline graph, in pixels.- See Also:
SPARK_H
private static final int SPARK_HHeight of a sparkline graph, in pixels.- See Also:
_nonce
Nonce proving the tuner form came from this router.DISPLAY_NAMES
PARAM_DESCRIPTIONS
Param name to console description, at most 70 characters since it renders beside its control in the tuning page. Package-visible for the same reason asDISPLAY_NAMES.SUBSYSTEM_ORDER
Subsystems in the order the tuner page displays them, alphabetical.SECTION_LABELS
METRIC_STATS
Maps each Tuner subsystem metric identifier (as reported byTuner.SubsystemScore.details) to the stat that backs it and a value format, so ring tooltips can show live values. Metrics with no backing stat are absent and omitted from the tooltip - a bare identifier without a value tells the reader nothing.Format is one of: "ms" (duration average), "pct" (0-100 average), "pct1000" (per-mille average), "count" (events in the last minute), "num" (plain average).
Constructor Details
TuningHelper
public TuningHelper()No CSRF nonce set yet, so the rendered form would carry an empty hidden field untilsetNonce(String)is called.
Method Details
setNonce
Records the CSRF nonce embedded in the rendered tuning form.- Parameters:
nonce- the console CSRF nonce to embed in the hidden field of the rendered tuning form
getTuning
Main content: editable tables of tunable params with sparklines.- Returns:
- the tuning tables as HTML, or a notice if auto-tuning is unavailable
getDisplayName
renderSparkline
Render an inline SVG sparkline. Diverging bar chart: center line = default value, bars in the single tuner graph colour, above the line when tuned up and below when tuned down. Newest sample on the left.- Parameters:
values- the sampled tuner values, newest sample drawn on the leftdefaultValue- the untuned value, drawn as the chart's center line- Returns:
- the inline SVG markup, or a "Collecting..." span if fewer than two samples
esc
formatMetricValue
Format one metric value for a ring tooltip.- Parameters:
format- one of "ms", "pct", "pct1000", "count", "num"avg- the 1-minute average event valuecount1m- events in the last minute (current partial window preferred)- Returns:
- the formatted value, or null when the metric has no data to show
metricDetails
Resolve a subsystem's metric identifiers to tooltip lines carrying each stat's live value, e.g. "jobQueue.jobLag: 12ms". Metrics with no mapping or no stat are skipped. Returns null when nothing resolves, so the ring simply gets no tooltip instead of an identifier list.- Parameters:
metrics- the metric identifiers from the subsystem score, may be null- Returns:
- tooltip lines, or null if none resolve
renderSubsystemRings
Render the subsystem ring chart dashboard. Returns an HTML div with a grid of SVG ring charts, one per subsystem. NaN-scored subsystems show a gray "collecting..." ring.- Parameters:
tuner- the Tuner whose subsystem scores are rendereddefer- true to force every score to NaN, showing gray collecting rings- Returns:
- the HTML div with the ring grid, empty if there are no subsystem scores
getTuner
Get the SSU transport tuner instance.- Returns:
- the UDPTransport's Tuner, or null