diff --git a/core/java/src/net/i2p/stat/RateStat.java b/core/java/src/net/i2p/stat/RateStat.java index 8dc1583d1760cab32689f854fdc306dda646e357..092050845704ae476527a1735c7a3155f8cd5975 100644 --- a/core/java/src/net/i2p/stat/RateStat.java +++ b/core/java/src/net/i2p/stat/RateStat.java @@ -46,6 +46,17 @@ public class RateStat { r.addData(value, eventDuration); } + /** + * Update all of the rates for the various periods with the given value. + * Zero duration. + * @since 0.8.10 + */ + public void addData(long value) { + if (_statLog != null) _statLog.addData(_groupName, _statName, value, 0); + for (Rate r: _rates.values()) + r.addData(value); + } + /** coalesce all the stats */ public void coalesceStats() { for (Rate r: _rates.values()){ diff --git a/core/java/src/net/i2p/stat/StatManager.java b/core/java/src/net/i2p/stat/StatManager.java index 7dfcf5e303ca3f0b4b6a7da20e360dd99133375b..ba50620ae9f1fe5964bd9c06b9f48253d584a601 100644 --- a/core/java/src/net/i2p/stat/StatManager.java +++ b/core/java/src/net/i2p/stat/StatManager.java @@ -150,6 +150,16 @@ public class StatManager { if (stat != null) stat.addData(data, eventDuration); } + /** + * Update the given rate statistic, taking note that the given data point was received (and recalculating all rates). + * Zero duration. + * @since 0.8.10 + */ + public void addRateData(String name, long data) { + RateStat stat = _rateStats.get(name); // unsynchronized + if (stat != null) stat.addData(data); + } + private int coalesceCounter; /** every this many minutes for frequencies */ private static final int FREQ_COALESCE_RATE = 9;