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

public class WizardHelperextends HelperBase
The new user wizard.

This bean has SESSION scope so the results may be retrieved. All necessary methods are synchronized.

  • Field Details

    • PROP_COMPLETE

      public static final String PROP_COMPLETE
      Session property recording that the welcome wizard already ran.
      See Also:
    • BW_SCALE

      public static final float BW_SCALE
      Fraction of the measured bandwidth applied to the limiter settings.
      See Also:
    • MIN_DOWN_BW

      private static final float MIN_DOWN_BW
      Smallest download bandwidth the wizard accepts, in KBps.
      See Also:
    • MIN_UP_BW

      private static final float MIN_UP_BW
      Smallest upload bandwidth the wizard accepts, in KBps.
      See Also:
    • _mlab

      private MLabRunner _mlab
      The bandwidth test runner, a singleton under the hood.
    • _listener

      private WizardHelper.TestListener _listener
      Listener recording the test results, session scope.
    • _runner

      private MLabRunner.ToolRun _runner
      The test running now, null if none.
    • _lastTestStatus

      private String _lastTestStatus
      Status text of the last test.
    • _lastTestCount

      private int _lastTestCount
      Number of tests run so far.
  • Constructor Details

    • WizardHelper

      public WizardHelper()
      A session-scoped bean with no test run yet: the listener, the runner and the cached status are all filled in as the bandwidth test runs.
  • Method Details

    • setContextId

      public void setContextId(String contextId)
      Overriden to only do this once.
      Overrides:
      setContextId in class HelperBase
      Parameters:
      contextId - beginning few characters of the routerHash, or null to pick the first one we come across.
    • complete

      public void complete()
      Record that the setup wizard has been finished, so it is not shown again.
    • isNDTComplete

      public boolean isNDTComplete()
      Whether the NDT bandwidth test listener reports the test as finished.
      Returns:
      whether n d t complete
    • isNDTRunning

      public boolean isNDTRunning()
      Whether the NDT bandwidth test is in progress.
      Returns:
      whether n d t running
    • isNDTSuccessful

      public boolean isNDTSuccessful()
      Whether the NDT bandwidth test completed and moved any bandwidth in both directions.
      Returns:
      whether n d t successful
    • getTestStatus

      public String getTestStatus()
      Return the current NDT bandwidth test status.
      Returns:
      HTML-escaped status string or ""
    • getCompletionStatus

      public String getCompletionStatus()
      Return the NDT test completion status.
      Returns:
      HTML-escaped status string or ""
    • getDetailStatus

      public String getDetailStatus()
      Return detailed NDT test status information.
      Returns:
      HTML-escaped status string or ""
    • getUpBandwidth

      public long getUpBandwidth()
      Return the measured upload bandwidth.
      Returns:
      bytes per second or 0
    • getDownBandwidth

      public long getDownBandwidth()
      Return the measured download bandwidth.
      Returns:
      bytes per second or 0
    • getServerLocation

      public String getServerLocation()
      Return the NDT test server location.
      Returns:
      HTML-escaped location or ""
    • getLongResult

      private long getLongResult(String key)
      Reads a numeric result of the last test.
      Parameters:
      key - the result name
      Returns:
      the value, zero if absent
    • getStringResult

      private String getStringResult(String key)
      Reads a text result of the last test.
      Parameters:
      key - the result name
      Returns:
      the value, null if absent
    • getInboundBurstRate

      public String getInboundBurstRate()
      To populate form with. Uses the test result if available, else the current setting Adapted from ConfigNetHelper.
      Returns:
      the inbound bandwidth limit in decimal KB/sec, rounded to an integer
    • getOutboundBurstRate

      public String getOutboundBurstRate()
      To populate form with. Uses the test result if available, else the current setting Adapted from ConfigNetHelper.
      Returns:
      the outbound bandwidth limit in decimal KB/sec, rounded to an integer
    • getInboundBurstRateBits

      public String getInboundBurstRateBits()
      Copied from ConfigNetHelper.
      Returns:
      the inbound burst rate in bits per second and the per-month maximum
    • getOutboundBurstRateBits

      public String getOutboundBurstRateBits()
      Copied from ConfigNetHelper.
      Returns:
      the outbound burst rate in bits per second and the per-month maximum
    • getShareRateBits

      public String getShareRateBits()
      Copied from ConfigNetHelper.
      Returns:
      the shared bandwidth in bits per second and the per-month maximum
    • kbytesToBits

      private String kbytesToBits(float kbytes)
      Copied from ConfigNetHelper.
      Parameters:
      kbytes - the bandwidth in KB/sec, where 1 KB is 1024 bytes
      Returns:
      the rate in bits per second, plus the per-month byte maximum
    • getShareBandwidth

      public int getShareBandwidth()
      Adapted from ConfigNetHelper.
      Returns:
      in binary KBytes per second
    • startNDT

      boolean startNDT()
      Start the test. Called from the Handler.
      Returns:
      whether the test was started; false if one is already running
    • cancelNDT

      boolean cancelNDT()
      Cancel the test. Called from the Handler.
      Returns:
      whether a running test was cancelled