commit 26fdd26de0d34794415313556b7092bf2a274d31 Author: Karsten Loesing karsten.loesing@gmx.net Date: Sun Feb 22 13:11:47 2015 +0100
Fix bandwidth graphs of relays running 0.2.6.3 and later.
Relays running tor 0.2.6.3 or later report bandwidth histories for four-hour intervals rather than fifteen minutes. But our most detailed bandwidth graphs use a fifteen-minute interval and don't handle the reported four-hours intervals very well. The fix is to exclude reported data points if the reported interval is longer than the graphed interval. These data points will be included in another graph covering a longer time period, which at the same time uses a longer interval for graphed data points.
Fixes #14984. --- .../torproject/onionoo/writer/BandwidthDocumentWriter.java | 12 ++++++++++-- web/protocol.html | 2 ++ 2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/src/main/java/org/torproject/onionoo/writer/BandwidthDocumentWriter.java b/src/main/java/org/torproject/onionoo/writer/BandwidthDocumentWriter.java index 9bad965..551fc71 100644 --- a/src/main/java/org/torproject/onionoo/writer/BandwidthDocumentWriter.java +++ b/src/main/java/org/torproject/onionoo/writer/BandwidthDocumentWriter.java @@ -107,6 +107,12 @@ public class BandwidthDocumentWriter implements DocumentWriter { if (endMillis < intervalStartMillis) { continue; } + if (endMillis - startMillis > dataPointInterval) { + /* This history interval is too long for this graph's data point + * interval. Maybe the next graph will contain it, but not this + * one. */ + continue; + } while ((intervalStartMillis / dataPointInterval) != (endMillis / dataPointInterval)) { dataPoints.add(totalMillis * 5L < dataPointInterval @@ -142,11 +148,13 @@ public class BandwidthDocumentWriter implements DocumentWriter { long firstDataPointMillis = (((this.now - graphInterval) / dataPointInterval) + firstNonNullIndex) * dataPointInterval + dataPointInterval / 2L; - if (i > 0 && + if (i > 0 && !graphs.isEmpty() && firstDataPointMillis >= this.now - graphIntervals[i - 1]) { /* Skip bandwidth history object, because it doesn't contain * anything new that wasn't already contained in the last - * bandwidth history object(s). */ + * bandwidth history object(s). Unless we did not include any of + * the previous bandwidth history objects for other reasons, in + * which case we should include this one. */ continue; } long lastDataPointMillis = firstDataPointMillis diff --git a/web/protocol.html b/web/protocol.html index f19d0d8..2a13be8 100644 --- a/web/protocol.html +++ b/web/protocol.html @@ -1613,6 +1613,8 @@ when the bandwidth document was published. A graph history object is only contained if the time period it covers is not already contained in another graph history object with shorter time period and higher data resolution. +Similarly, a graph history object is excluded if the relay did not provide +bandwidth histories on the required level of detail. The unit is bytes per second. Contained graph history objects may contain null values if the relay did not provide any bandwidth data or only data for less than 20% of a given
tor-commits@lists.torproject.org