java.lang.Object
net.i2p.router.web.GraphGenerator.ReportThrottle
Enclosing class:
GraphGenerator

static final class GraphGenerator.ReportThrottleextends Object
Decide whether a repeated report is due, and remember the decision.

Pure enough to unit test and free of router context, so the "first report is never throttled, a changed one is never delayed, an unchanged one repeats on a timer" rule is pinned by tests rather than by reading the caller.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private long
    Render time of the last graph, in ms.
    private long
    Signature of the last rendered data.
  • Constructor Summary

    Constructors
    Constructor
    Description
    One per reported condition, so each carries its own last report and signature.
  • Method Summary

    All Methods
    Modifier and Type
    Method
    Description
    (package private) boolean
    allow(long now, long signature, long minIntervalMs)
    Decide whether this report is due, and remember the decision.

    Methods inherited from class Object

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

    • _lastMs

      private long _lastMs
      Render time of the last graph, in ms.
    • _lastSignature

      private long _lastSignature
      Signature of the last rendered data.
  • Constructor Details

    • ReportThrottle

      ReportThrottle()
      One per reported condition, so each carries its own last report and signature.
  • Method Details

    • allow

      boolean allow(long now, long signature, long minIntervalMs)
      Decide whether this report is due, and remember the decision.

      Synchronized because the stall report is reached from the 90s sync task and the 10s watchdog, which run on different threads.

      Parameters:
      now - current wall-clock ms
      signature - value identifying the state being reported
      minIntervalMs - shortest gap between two identical reports
      Returns:
      true if the caller should log now