public class BandwidthHistory extends SimpleTimer2.TimedEvent
| Modifier and Type | Field and Description |
|---|---|
static int | CAPACITYBuffer: 1200 entries = 20 min at 1s |
static long | SAMPLE_INTERVALSample once per second |
_state, DEFAULT_FUZZ| Constructor and Description |
|---|
BandwidthHistory(RouterContext ctx)Create a bandwidth history. |
| Modifier and Type | Method and Description |
|---|---|
int | getCapacity()The ring buffer capacity. |
int | getCount()The number of stored samples. |
static BandwidthHistory | getInstance()The singleton instance. |
String | getLastRx(int n)Return the last n receive values as a comma-separated string. |
String | getLastTx(int n)Return the last n send values as a comma-separated string. |
void | record(long rx,
long tx)Add a sample to the ring buffer. |
(package private) void | save()Write the ring buffer to disk. |
void | timeReached()Sample bandwidth limiter and record. |
cancel, forceReschedule, reschedule, reschedule, run, schedule, setFuzz, setPool, toStringpublic static final int CAPACITY
public static final long SAMPLE_INTERVAL
public BandwidthHistory(RouterContext ctx)
ctx - may be null in unit testspublic int getCapacity()
public int getCount()
public static BandwidthHistory getInstance()
public String getLastRx(int n)
n receive values as a comma-separated string.
Oldest value first, most recent last. Empty string if no data.n - the number of values to returnpublic String getLastTx(int n)
n send values as a comma-separated string.
Oldest value first, most recent last. Empty string if no data.n - the number of values to returnpublic void record(long rx,
long tx)rx - the receive bandwidth in Bpstx - the transmit bandwidth in Bpsvoid save()
public void timeReached()
timeReached in class SimpleTimer2.TimedEvent