java.lang.Object
org.klomp.snark.BWLimits
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
FieldsModifier and TypeFieldDescriptionprivate static int[]The limits last read, reused until the next update.private static longWhen the limits were last read, in msprivate static final longMilliseconds between reads of the router's limitsConstructor Summary
ConstructorsMethod Summary
All MethodsModifier and TypeMethodDescriptionstatic int[]getBWLimits(String host, int port) Retrieves the bandwidth limits from the I2P router at the given host and port.
Field Details
cachedResult
private static int[] cachedResultThe limits last read, reused until the next update.lastUpdateTime
private static long lastUpdateTimeWhen the limits were last read, in msUPDATE_INTERVAL
private static final long UPDATE_INTERVALMilliseconds 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
Retrieves the bandwidth limits from the I2P router at the given host and port.- Parameters:
host- the I2CP host to connect toport- the I2CP port to connect to- Returns:
- an int array of bandwidth limits, or null on failure