commit 23bf1292718eac23c4c09daf0c2d10dcda333ca5 Author: Karsten Loesing karsten.loesing@gmx.net Date: Tue Aug 22 09:39:34 2017 +0200
Remove extraneous (BETA) fields from clients objects.
This change deserves a minor protocol version update to 4.1.
Implements #22033. --- CHANGELOG.md | 4 +- .../torproject/onionoo/docs/ClientsDocument.java | 4 +- .../onionoo/docs/ClientsGraphHistory.java | 102 --------------------- .../onionoo/writer/ClientsDocumentWriter.java | 74 +-------------- 4 files changed, 10 insertions(+), 174 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md index 8412f87..acfe8df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,10 @@ -# Changes in version 4.0-1.?.? - 2017-0?-?? +# Changes in version 4.1-1.?.? - 2017-0?-??
* Medium changes - Reset IPv6 exit-policy summary in details status if a newer server descriptor doesn't contain such a summary anymore. + - Remove optional fields "countries", "transports", and "versions" + from clients objects which were still labeled as beta.
# Changes in version 4.0-1.3.0 - 2017-08-04 diff --git a/src/main/java/org/torproject/onionoo/docs/ClientsDocument.java b/src/main/java/org/torproject/onionoo/docs/ClientsDocument.java index 2cc69c0..0b625b0 100644 --- a/src/main/java/org/torproject/onionoo/docs/ClientsDocument.java +++ b/src/main/java/org/torproject/onionoo/docs/ClientsDocument.java @@ -16,10 +16,10 @@ public class ClientsDocument extends Document { }
@SuppressWarnings("unused") - private Map<String, ClientsGraphHistory> average_clients; + private Map<String, GraphHistory> average_clients;
public void setAverageClients( - Map<String, ClientsGraphHistory> averageClients) { + Map<String, GraphHistory> averageClients) { this.average_clients = averageClients; } } diff --git a/src/main/java/org/torproject/onionoo/docs/ClientsGraphHistory.java b/src/main/java/org/torproject/onionoo/docs/ClientsGraphHistory.java deleted file mode 100644 index 6b2bd3d..0000000 --- a/src/main/java/org/torproject/onionoo/docs/ClientsGraphHistory.java +++ /dev/null @@ -1,102 +0,0 @@ -/* Copyright 2014--2017 The Tor Project - * See LICENSE for licensing information */ - -package org.torproject.onionoo.docs; - -import java.util.ArrayList; -import java.util.List; -import java.util.SortedMap; - -public class ClientsGraphHistory { - - private String first; - - public void setFirst(long first) { - this.first = DateTimeHelper.format(first); - } - - public long getFirst() { - return DateTimeHelper.parse(this.first); - } - - private String last; - - public void setLast(long last) { - this.last = DateTimeHelper.format(last); - } - - public long getLast() { - return DateTimeHelper.parse(this.last); - } - - private Integer interval; - - public void setInterval(Integer interval) { - this.interval = interval; - } - - public Integer getInterval() { - return this.interval; - } - - private Double factor; - - public void setFactor(Double factor) { - this.factor = factor; - } - - public Double getFactor() { - return this.factor; - } - - private Integer count; - - public void setCount(Integer count) { - this.count = count; - } - - public Integer getCount() { - return this.count; - } - - private List<Integer> values = new ArrayList<>(); - - public void setValues(List<Integer> values) { - this.values = values; - } - - public List<Integer> getValues() { - return this.values; - } - - private SortedMap<String, Float> countries; - - public void setCountries(SortedMap<String, Float> countries) { - this.countries = countries; - } - - public SortedMap<String, Float> getCountries() { - return this.countries; - } - - private SortedMap<String, Float> transports; - - public void setTransports(SortedMap<String, Float> transports) { - this.transports = transports; - } - - public SortedMap<String, Float> getTransports() { - return this.transports; - } - - private SortedMap<String, Float> versions; - - public void setVersions(SortedMap<String, Float> versions) { - this.versions = versions; - } - - public SortedMap<String, Float> getVersions() { - return this.versions; - } -} - diff --git a/src/main/java/org/torproject/onionoo/writer/ClientsDocumentWriter.java b/src/main/java/org/torproject/onionoo/writer/ClientsDocumentWriter.java index 599ecff..f65a53a 100644 --- a/src/main/java/org/torproject/onionoo/writer/ClientsDocumentWriter.java +++ b/src/main/java/org/torproject/onionoo/writer/ClientsDocumentWriter.java @@ -4,12 +4,12 @@ package org.torproject.onionoo.writer;
import org.torproject.onionoo.docs.ClientsDocument; -import org.torproject.onionoo.docs.ClientsGraphHistory; import org.torproject.onionoo.docs.ClientsHistory; import org.torproject.onionoo.docs.ClientsStatus; import org.torproject.onionoo.docs.DateTimeHelper; import org.torproject.onionoo.docs.DocumentStore; import org.torproject.onionoo.docs.DocumentStoreFactory; +import org.torproject.onionoo.docs.GraphHistory; import org.torproject.onionoo.docs.UpdateStatus; import org.torproject.onionoo.util.FormattingUtils;
@@ -20,9 +20,7 @@ import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import java.util.SortedMap; import java.util.SortedSet; -import java.util.TreeMap;
/* * Clients status file produced as intermediate output: @@ -111,11 +109,11 @@ public class ClientsDocumentWriter implements DocumentWriter { SortedSet<ClientsHistory> history) { ClientsDocument clientsDocument = new ClientsDocument(); clientsDocument.setFingerprint(hashedFingerprint); - Map<String, ClientsGraphHistory> averageClients = new LinkedHashMap<>(); + Map<String, GraphHistory> averageClients = new LinkedHashMap<>(); for (int graphIntervalIndex = 0; graphIntervalIndex < this.graphIntervals.length; graphIntervalIndex++) { String graphName = this.graphNames[graphIntervalIndex]; - ClientsGraphHistory graphHistory = this.compileClientsHistory( + GraphHistory graphHistory = this.compileClientsHistory( graphIntervalIndex, history); if (graphHistory != null) { averageClients.put(graphName, graphHistory); @@ -125,7 +123,7 @@ public class ClientsDocumentWriter implements DocumentWriter { return clientsDocument; }
- private ClientsGraphHistory compileClientsHistory( + private GraphHistory compileClientsHistory( int graphIntervalIndex, SortedSet<ClientsHistory> history) { long graphInterval = this.graphIntervals[graphIntervalIndex]; long dataPointInterval = @@ -135,10 +133,6 @@ public class ClientsDocumentWriter implements DocumentWriter { / dataPointInterval) * dataPointInterval; long millis = 0L; double responses = 0.0; - double totalResponses = 0.0; - SortedMap<String, Double> totalResponsesByCountry = new TreeMap<>(); - SortedMap<String, Double> totalResponsesByTransport = new TreeMap<>(); - SortedMap<String, Double> totalResponsesByVersion = new TreeMap<>(); for (ClientsHistory hist : history) { if (hist.getEndMillis() < intervalStartMillis) { continue; @@ -153,31 +147,6 @@ public class ClientsDocumentWriter implements DocumentWriter { intervalStartMillis += dataPointInterval; } responses += hist.getTotalResponses(); - totalResponses += hist.getTotalResponses(); - for (Map.Entry<String, Double> e : - hist.getResponsesByCountry().entrySet()) { - if (!totalResponsesByCountry.containsKey(e.getKey())) { - totalResponsesByCountry.put(e.getKey(), 0.0); - } - totalResponsesByCountry.put(e.getKey(), e.getValue() - + totalResponsesByCountry.get(e.getKey())); - } - for (Map.Entry<String, Double> e : - hist.getResponsesByTransport().entrySet()) { - if (!totalResponsesByTransport.containsKey(e.getKey())) { - totalResponsesByTransport.put(e.getKey(), 0.0); - } - totalResponsesByTransport.put(e.getKey(), e.getValue() - + totalResponsesByTransport.get(e.getKey())); - } - for (Map.Entry<String, Double> e : - hist.getResponsesByVersion().entrySet()) { - if (!totalResponsesByVersion.containsKey(e.getKey())) { - totalResponsesByVersion.put(e.getKey(), 0.0); - } - totalResponsesByVersion.put(e.getKey(), e.getValue() - + totalResponsesByVersion.get(e.getKey())); - } millis += (hist.getEndMillis() - hist.getStartMillis()); } dataPoints.add(millis * 2L < dataPointInterval @@ -217,7 +186,7 @@ public class ClientsDocumentWriter implements DocumentWriter { + (lastNonNullIndex - firstNonNullIndex) * dataPointInterval; double factor = ((double) maxValue) / 999.0; int count = lastNonNullIndex - firstNonNullIndex + 1; - ClientsGraphHistory graphHistory = new ClientsGraphHistory(); + GraphHistory graphHistory = new GraphHistory(); graphHistory.setFirst(firstDataPointMillis); graphHistory.setLast(lastDataPointMillis); graphHistory.setInterval((int) (dataPointInterval @@ -240,39 +209,6 @@ public class ClientsDocumentWriter implements DocumentWriter { (int) ((dataPoint * 999.0) / maxValue)); } graphHistory.setValues(values); - if (!totalResponsesByCountry.isEmpty()) { - SortedMap<String, Float> countries = new TreeMap<>(); - for (Map.Entry<String, Double> e : - totalResponsesByCountry.entrySet()) { - if (e.getValue() > totalResponses / 100.0) { - countries.put(e.getKey(), - (float) (e.getValue() / totalResponses)); - } - } - graphHistory.setCountries(countries); - } - if (!totalResponsesByTransport.isEmpty()) { - SortedMap<String, Float> transports = new TreeMap<>(); - for (Map.Entry<String, Double> e : - totalResponsesByTransport.entrySet()) { - if (e.getValue() > totalResponses / 100.0) { - transports.put(e.getKey(), - (float) (e.getValue() / totalResponses)); - } - } - graphHistory.setTransports(transports); - } - if (!totalResponsesByVersion.isEmpty()) { - SortedMap<String, Float> versions = new TreeMap<>(); - for (Map.Entry<String, Double> e : - totalResponsesByVersion.entrySet()) { - if (e.getValue() > totalResponses / 100.0) { - versions.put(e.getKey(), - (float) (e.getValue() / totalResponses)); - } - } - graphHistory.setVersions(versions); - } if (foundTwoAdjacentDataPoints) { return graphHistory; } else {
tor-commits@lists.torproject.org