[metrics-bugs] #16553 [Metrics/Onionoo]: Add support for searching by (partial) host name
Tor Bug Tracker & Wiki
blackhole at torproject.org
Mon Oct 30 14:12:48 UTC 2017
#16553: Add support for searching by (partial) host name
-----------------------------+-------------------------------
Reporter: karsten | Owner: metrics-team
Type: enhancement | Status: needs_review
Priority: Very Low | Milestone: Onionoo-1.7.0
Component: Metrics/Onionoo | Version:
Severity: Normal | Resolution:
Keywords: metrics-2018 | Actual Points:
Parent ID: | Points:
Reviewer: | Sponsor:
-----------------------------+-------------------------------
Comment (by iwakeh):
There are checkstyle complaints for the tests (line length and method
names).
For SummayDocument the variables should be named correctly and instead of
suppressing warnings using `@SuppressWarnings("checkstyle:membername")`
the exposed values should be annotated (`@Expose`) and the
`@SerializedName` should be defined. Of course, here only variable `h`
was added, but this is a good time to overhaul all fields.
Rather use `if(null == this.hostName)` than `if(this.hostName == null)`
(cf.
[https://gitweb.torproject.org/user/karsten/onionoo.git/tree/src/main/java/org/torproject/onionoo/server/RequestHandler.java?id=c373daca4275b4fe558514e782fd6e1a59f75d84#n547
RequestHandler]).
Consider using Java8 idiom, for example:
{{{
--- a/src/main/java/org/torproject/onionoo/server/RequestHandler.java
+++ b/src/main/java/org/torproject/onionoo/server/RequestHandler.java
@@ -551,15 +551,12 @@ public class RequestHandler {
}
String hostName = this.hostName.toLowerCase();
Set<String> removeRelays = new
HashSet<>(this.filteredRelays.keySet());
- for (Map.Entry<String, Set<String>> e :
- this.nodeIndex.getRelaysByHostName().entrySet()) {
- if (e.getKey().endsWith(hostName)) {
- removeRelays.removeAll(e.getValue());
- }
- }
- for (String fingerprint : removeRelays) {
- this.filteredRelays.remove(fingerprint);
- }
+ this.nodeIndex.getRelaysByHostName().entrySet().stream()
+ .filter((mapEntry) -> mapEntry.getKey().endsWith(hostName))
+ .forEach((mapEntry) ->
removeRelays.removeAll(mapEntry.getValue()));
+ removeRelays.stream()
+ .forEach((fingerprint) ->
this.filteredRelays.remove(fingerprint));
this.filteredBridges.clear();
}
}}}
(Again timeout for `testCountryDeDe` needed to be increased; weird, the
stack trace is usually in a native method when the timeout occurs. Maybe,
simply increase this timeout to 200ms?)
--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/16553#comment:16>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online
More information about the metrics-bugs
mailing list