java.lang.Object
net.i2p.router.web.HelperBase
net.i2p.router.web.helpers.DebugOverviewHelper

public class DebugOverviewHelperextends HelperBase
Overview tiles and mini-graphs for the debug page entry point, one tile per debug tab summarizing what that tab shows, linking to it.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) static final int
    Number of mini-graphs shown, backfilled from other enabled stats.
    (package private) static final Map<String,String>
    Human-readable labels for the priority stats, for the graph caption; backfilled stats fall back to their raw name.
    (package private) static final String[]
    Priority-ordered single-stat graph wishes, after bw.combined.

    Fields inherited from class HelperBase

    _context, _log, _out, CHECKED, PROP_ADVANCED, SELECTED
    Modifier and Type
    Field
    Description
    protected RouterContext
    The router context.
    protected Log
    The log instance.
    protected Writer
    The writer for output.
    static final String
    Checked attribute for HTML checkboxes.
    static final String
    Property key for advanced mode.
    static final String
    Selected attribute for HTML select options.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Helper bean that gathers the debug overview's tiles and mini-graphs.
  • Method Summary

    Modifier and Type
    Method
    Description
    private int[]
    Counts the running apps for the page.
    private long[]
    Sum the ratchet stats across distinct client session key managers.
    private long[]
    Reads the torrent DHT statistics for the page.
    private long[]
    Reads the router's session key counts for the page.
    private int
    Counts the running services for the page.
    private int[]
    Counts the open streaming connections for the page.
    private int[]
    Counts the available updates for the page.
    (package private) static String
    buildGraphs(List<String> stats, long now, Map<String,String> labels)
    Build the mini-graph row for the given stats, at the standard graph size with grid but no legend or title - the tiny sidebar template is not used here.
    (package private) static List<String>
    buildTiles(int services, int[] apps, int[] updates, long[] skmRouter, long[] skmClients, int[] streams, long[] dht)
    Build the ring cells in tab order: one per data-bearing debug tab (the DHT tab gets two, fill and fullest) plus one for active streams before it.
    Build the overview: tile grid then up to four recorded mini-graphs.
    (package private) static List<String>
    Pick up to GRAPH_COUNT stats to graph: bw.combined first when both bw rates are enabled, then the priority wish list, then a deterministic backfill from any other enabled stats so the row fills out.
    private static String
    skmCell(String label, long[] stats)
    One ratchet-SKM cell: outbound sessions ring with tags and lifetime counters in the tooltip.
    private static String
    tile(String href, String cell)
    Wrap a ring cell in a link to its debug tab.

    Methods inherited from class HelperBase

    _t, _t, _t, _x, getChecked, isAdvanced, ngettext, setContextId, storeWriter
    Modifier and Type
    Method
    Description
    Translate a string.
    _t(String s, Object o)
    Translate a string with a parameter.
    _t(String s, Object o, Object o2)
    Translate a string with two parameters.
    static String
    Mark a string for extraction by xgettext and translation.
    protected String
    Get the checked attribute for a boolean property.
    boolean
    Check if advanced mode is enabled.
    ngettext(String s, String p, int n)
    Translate a string with plural forms (ngettext).
    void
    setContextId(String contextId)
    Configure this bean to query a particular router context.
    void
    Store the writer for output.

    Methods inherited from class Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • GRAPH_STATS

      static final String[] GRAPH_STATS
      Priority-ordered single-stat graph wishes, after bw.combined.
    • GRAPH_COUNT

      static final int GRAPH_COUNT
      Number of mini-graphs shown, backfilled from other enabled stats.
      See Also:
    • GRAPH_LABELS

      static final Map<String,String> GRAPH_LABELS
      Human-readable labels for the priority stats, for the graph caption; backfilled stats fall back to their raw name. Values are translated at render time.
  • Constructor Details

    • DebugOverviewHelper

      public DebugOverviewHelper()
      Helper bean that gathers the debug overview's tiles and mini-graphs.
  • Method Details

    • buildTiles

      static List<String> buildTiles(int services, int[] apps, int[] updates, long[] skmRouter, long[] skmClients, int[] streams, long[] dht)
      Build the ring cells in tab order: one per data-bearing debug tab (the DHT tab gets two, fill and fullest) plus one for active streams before it. Null stat arrays mean the subsystem reported nothing and the cell degrades to a plain link tile. The SAM and translation tabs get no tile - translation is a pre-generated static report with no live data.
      Parameters:
      services - count of listening services
      apps - {tracked, running, registered} app counts, or null
      updates - {installed, downloaded, available} counts, or null
      skmRouter - ratchet stats, see SessionKeyManager.getDebugStats, or null
      skmClients - summed ratchet stats across client managers, or null
      streams - {inbound, outbound} open stream sockets, or null
      dht - {keys, buckets, capacity, fullest} bucket stats, or null
      Returns:
      one cell html string per tile, never null
    • skmCell

      private static String skmCell(String label, long[] stats)
      One ratchet-SKM cell: outbound sessions ring with tags and lifetime counters in the tooltip.
      Parameters:
      label - the cell label
      stats - the ratchet stats, or null
      Returns:
      the cell html, never null
    • tile

      private static String tile(String href, String cell)
      Wrap a ring cell in a link to its debug tab.
      Parameters:
      href - the tab url
      cell - the ring cell html
      Returns:
      the linked cell html, never null
    • getOverviewHTML

      public String getOverviewHTML()
      Build the overview: tile grid then up to four recorded mini-graphs.
      Returns:
      the page html, never null
    • pickGraphStats

      static List<String> pickGraphStats(Set<String> enabled)
      Pick up to GRAPH_COUNT stats to graph: bw.combined first when both bw rates are enabled, then the priority wish list, then a deterministic backfill from any other enabled stats so the row fills out. A single stat not in the router's stat.summaries list would make viewstat.jsp 400, so only enabled stats are ever shown.
      Parameters:
      enabled - names of stats with a graph listener
      Returns:
      the stat names to graph, at most GRAPH_COUNT, never null
    • buildGraphs

      static String buildGraphs(List<String> stats, long now, Map<String,String> labels)
      Build the mini-graph row for the given stats, at the standard graph size with grid but no legend or title - the tiny sidebar template is not used here. bw.combined needs no period parameter (viewstat.jsp resolves it specially) and links to the plain graphs page. A single stat only draws when a period is given, so 60 one-minute buckets = 60 min.
      Parameters:
      stats - the stats to graph, non-empty
      now - current time, used as a cache-buster
      labels - translated display labels, stat name to caption
      Returns:
      the graph div html, never null
    • _services

      private int _services()
      Counts the running services for the page.
      Returns:
      the service count
    • _appCounts

      private int[] _appCounts()
      Counts the running apps for the page.
      Returns:
      the counts shown on the page
    • _updateCounts

      private int[] _updateCounts()
      Counts the available updates for the page.
      Returns:
      the counts shown on the page
    • _routerSKM

      private long[] _routerSKM()
      Reads the router's session key counts for the page.
      Returns:
      the counts shown on the page
    • _clientSKMSum

      private long[] _clientSKMSum()
      Sum the ratchet stats across distinct client session key managers.
      Returns:
      the summed stats, or null if no client reported any
    • _streamCounts

      private int[] _streamCounts()
      Counts the open streaming connections for the page.
      Returns:
      the counts shown on the page
    • _dhtStats

      private long[] _dhtStats()
      Reads the torrent DHT statistics for the page.
      Returns:
      the counts shown on the page