java.lang.Object
org.klomp.snark.BWLimits

public class BWLimitsextends Object
Retrieves bandwidth limits from an I2P router via I2CP. Caches results and updates at most once every 10 minutes.

This method is blocking and returns cached results if called again within the update interval. Returns null on failure.

Uses a 5-second timeout internally but typically completes faster. Thread-safe via method synchronization.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static int[]
    The limits last read, reused until the next update.
    private static long
    When the limits were last read, in ms
    private static final long
    Milliseconds between reads of the router's limits
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor.
  • Method Summary

    All Methods
    Modifier and Type
    Method
    Description
    static int[]
    getBWLimits(String host, int port)
    Retrieves the bandwidth limits from the I2P router at the given host and port.

    Methods inherited from class Object

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

    • cachedResult

      private static int[] cachedResult
      The limits last read, reused until the next update.
    • lastUpdateTime

      private static long lastUpdateTime
      When the limits were last read, in ms
    • UPDATE_INTERVAL

      private static final long UPDATE_INTERVAL
      Milliseconds between reads of the router's limits
      See Also:
  • Constructor Details

    • BWLimits

      public BWLimits()
      Constructor. The cached limits and their timestamp are static, so an instance carries no state of its own; only the static accessor is used.
  • Method Details

    • getBWLimits

      public static int[] getBWLimits(String host, int port)
      Retrieves the bandwidth limits from the I2P router at the given host and port.
      Parameters:
      host - the I2CP host to connect to
      port - the I2CP port to connect to
      Returns:
      an int array of bandwidth limits, or null on failure