tor-commits
Threads by month
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
August 2018
- 17 participants
- 2582 discussions
[metrics-web/master] Delete methods that only call their super.
by karsten@torproject.org 27 Aug '18
by karsten@torproject.org 27 Aug '18
27 Aug '18
commit af0900d18c1461db90a9512231e9342ad4c57a64
Author: Karsten Loesing <karsten.loesing(a)gmx.net>
Date: Mon Aug 20 20:16:06 2018 +0200
Delete methods that only call their super.
---
.../metrics/stats/hidserv/DateTimeHelper.java | 19 +------------------
.../java/org/torproject/metrics/web/AboutServlet.java | 5 -----
.../org/torproject/metrics/web/BubblesServlet.java | 5 -----
.../torproject/metrics/web/DevelopmentServlet.java | 5 -----
.../java/org/torproject/metrics/web/ErrorServlet.java | 5 -----
.../org/torproject/metrics/web/GlossaryServlet.java | 5 -----
.../java/org/torproject/metrics/web/IndexServlet.java | 5 -----
.../java/org/torproject/metrics/web/LinkServlet.java | 5 -----
.../org/torproject/metrics/web/MetricsLibServlet.java | 5 -----
.../org/torproject/metrics/web/OnionooServlet.java | 5 -----
.../org/torproject/metrics/web/OperationServlet.java | 5 -----
.../torproject/metrics/web/RelaySearchServlet.java | 5 -----
.../metrics/web/ReproducibleMetricsServlet.java | 5 -----
.../org/torproject/metrics/web/ResearchServlet.java | 5 -----
.../org/torproject/metrics/web/ServicesServlet.java | 5 -----
.../org/torproject/metrics/web/SourcesServlet.java | 5 -----
.../java/org/torproject/metrics/web/StatsServlet.java | 5 -----
17 files changed, 1 insertion(+), 98 deletions(-)
diff --git a/src/main/java/org/torproject/metrics/stats/hidserv/DateTimeHelper.java b/src/main/java/org/torproject/metrics/stats/hidserv/DateTimeHelper.java
index 58a785e..ade7024 100644
--- a/src/main/java/org/torproject/metrics/stats/hidserv/DateTimeHelper.java
+++ b/src/main/java/org/torproject/metrics/stats/hidserv/DateTimeHelper.java
@@ -40,24 +40,7 @@ public class DateTimeHelper {
* timestamps, protected using ThreadLocal to ensure that each thread
* uses its own instances. */
private static ThreadLocal<Map<String, DateFormat>> dateFormats =
- new ThreadLocal<Map<String, DateFormat>>() {
-
- public Map<String, DateFormat> get() {
- return super.get();
- }
-
- protected Map<String, DateFormat> initialValue() {
- return new HashMap<>();
- }
-
- public void remove() {
- super.remove();
- }
-
- public void set(Map<String, DateFormat> value) {
- super.set(value);
- }
- };
+ ThreadLocal.withInitial(HashMap::new);
/** Returns an instance of DateFormat for the given format, and if no
* such instance exists, creates one and puts it in the map. */
diff --git a/src/main/java/org/torproject/metrics/web/AboutServlet.java b/src/main/java/org/torproject/metrics/web/AboutServlet.java
index 30cb606..db39120 100644
--- a/src/main/java/org/torproject/metrics/web/AboutServlet.java
+++ b/src/main/java/org/torproject/metrics/web/AboutServlet.java
@@ -14,11 +14,6 @@ public class AboutServlet extends AnyServlet {
private static final long serialVersionUID = 97168997894664L;
@Override
- public void init() throws ServletException {
- super.init();
- }
-
- @Override
public void doGet(HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException {
diff --git a/src/main/java/org/torproject/metrics/web/BubblesServlet.java b/src/main/java/org/torproject/metrics/web/BubblesServlet.java
index 8f83184..d59c0f5 100644
--- a/src/main/java/org/torproject/metrics/web/BubblesServlet.java
+++ b/src/main/java/org/torproject/metrics/web/BubblesServlet.java
@@ -16,11 +16,6 @@ public class BubblesServlet extends MetricServlet {
private static final long serialVersionUID = -6011833075497881033L;
@Override
- public void init() throws ServletException {
- super.init();
- }
-
- @Override
public void doGet(HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException {
String requestUri = request.getRequestURI();
diff --git a/src/main/java/org/torproject/metrics/web/DevelopmentServlet.java b/src/main/java/org/torproject/metrics/web/DevelopmentServlet.java
index a330ab1..540273d 100644
--- a/src/main/java/org/torproject/metrics/web/DevelopmentServlet.java
+++ b/src/main/java/org/torproject/metrics/web/DevelopmentServlet.java
@@ -14,11 +14,6 @@ public class DevelopmentServlet extends AnyServlet {
private static final long serialVersionUID = 6850919895248020945L;
@Override
- public void init() throws ServletException {
- super.init();
- }
-
- @Override
public void doGet(HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException {
diff --git a/src/main/java/org/torproject/metrics/web/ErrorServlet.java b/src/main/java/org/torproject/metrics/web/ErrorServlet.java
index f3d6974..49fbd68 100644
--- a/src/main/java/org/torproject/metrics/web/ErrorServlet.java
+++ b/src/main/java/org/torproject/metrics/web/ErrorServlet.java
@@ -14,11 +14,6 @@ public class ErrorServlet extends AnyServlet {
private static final long serialVersionUID = 6850919895248020945L;
@Override
- public void init() throws ServletException {
- super.init();
- }
-
- @Override
public void doGet(HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException {
diff --git a/src/main/java/org/torproject/metrics/web/GlossaryServlet.java b/src/main/java/org/torproject/metrics/web/GlossaryServlet.java
index 30fd3c6..7f199c1 100644
--- a/src/main/java/org/torproject/metrics/web/GlossaryServlet.java
+++ b/src/main/java/org/torproject/metrics/web/GlossaryServlet.java
@@ -14,11 +14,6 @@ public class GlossaryServlet extends AnyServlet {
private static final long serialVersionUID = -971194326457109601L;
@Override
- public void init() throws ServletException {
- super.init();
- }
-
- @Override
public void doGet(HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException {
diff --git a/src/main/java/org/torproject/metrics/web/IndexServlet.java b/src/main/java/org/torproject/metrics/web/IndexServlet.java
index ed76081..0bde0ae 100644
--- a/src/main/java/org/torproject/metrics/web/IndexServlet.java
+++ b/src/main/java/org/torproject/metrics/web/IndexServlet.java
@@ -14,11 +14,6 @@ public class IndexServlet extends AnyServlet {
private static final long serialVersionUID = -5156539049907533057L;
@Override
- public void init() throws ServletException {
- super.init();
- }
-
- @Override
public void doGet(HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException {
diff --git a/src/main/java/org/torproject/metrics/web/LinkServlet.java b/src/main/java/org/torproject/metrics/web/LinkServlet.java
index 3dcaeb1..7c5cb02 100644
--- a/src/main/java/org/torproject/metrics/web/LinkServlet.java
+++ b/src/main/java/org/torproject/metrics/web/LinkServlet.java
@@ -15,11 +15,6 @@ import javax.servlet.http.HttpServletResponse;
public class LinkServlet extends MetricServlet {
@Override
- public void init() throws ServletException {
- super.init();
- }
-
- @Override
public void doGet(HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException {
String requestUri = request.getRequestURI();
diff --git a/src/main/java/org/torproject/metrics/web/MetricsLibServlet.java b/src/main/java/org/torproject/metrics/web/MetricsLibServlet.java
index 4f1915e..b82ccf8 100644
--- a/src/main/java/org/torproject/metrics/web/MetricsLibServlet.java
+++ b/src/main/java/org/torproject/metrics/web/MetricsLibServlet.java
@@ -14,11 +14,6 @@ public class MetricsLibServlet extends AnyServlet {
private static final long serialVersionUID = -6009422570527820853L;
@Override
- public void init() throws ServletException {
- super.init();
- }
-
- @Override
public void doGet(HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException {
diff --git a/src/main/java/org/torproject/metrics/web/OnionooServlet.java b/src/main/java/org/torproject/metrics/web/OnionooServlet.java
index 848790e..65fbe58 100644
--- a/src/main/java/org/torproject/metrics/web/OnionooServlet.java
+++ b/src/main/java/org/torproject/metrics/web/OnionooServlet.java
@@ -14,11 +14,6 @@ public class OnionooServlet extends AnyServlet {
private static final long serialVersionUID = 3036525855022445178L;
@Override
- public void init() throws ServletException {
- super.init();
- }
-
- @Override
public void doGet(HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException {
diff --git a/src/main/java/org/torproject/metrics/web/OperationServlet.java b/src/main/java/org/torproject/metrics/web/OperationServlet.java
index 1e434f5..bc13648 100644
--- a/src/main/java/org/torproject/metrics/web/OperationServlet.java
+++ b/src/main/java/org/torproject/metrics/web/OperationServlet.java
@@ -14,11 +14,6 @@ public class OperationServlet extends AnyServlet {
private static final long serialVersionUID = 6850919895248020945L;
@Override
- public void init() throws ServletException {
- super.init();
- }
-
- @Override
public void doGet(HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException {
diff --git a/src/main/java/org/torproject/metrics/web/RelaySearchServlet.java b/src/main/java/org/torproject/metrics/web/RelaySearchServlet.java
index a9c0dcb..101b99c 100644
--- a/src/main/java/org/torproject/metrics/web/RelaySearchServlet.java
+++ b/src/main/java/org/torproject/metrics/web/RelaySearchServlet.java
@@ -14,11 +14,6 @@ public class RelaySearchServlet extends AnyServlet {
private static final long serialVersionUID = 1L;
@Override
- public void init() throws ServletException {
- super.init();
- }
-
- @Override
public void doGet(HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException {
diff --git a/src/main/java/org/torproject/metrics/web/ReproducibleMetricsServlet.java b/src/main/java/org/torproject/metrics/web/ReproducibleMetricsServlet.java
index 3299cd2..813ec6c 100644
--- a/src/main/java/org/torproject/metrics/web/ReproducibleMetricsServlet.java
+++ b/src/main/java/org/torproject/metrics/web/ReproducibleMetricsServlet.java
@@ -14,11 +14,6 @@ public class ReproducibleMetricsServlet extends AnyServlet {
private static final long serialVersionUID = 6099009779662419291L;
@Override
- public void init() throws ServletException {
- super.init();
- }
-
- @Override
public void doGet(HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException {
diff --git a/src/main/java/org/torproject/metrics/web/ResearchServlet.java b/src/main/java/org/torproject/metrics/web/ResearchServlet.java
index fbfb70d..2c3cb09 100644
--- a/src/main/java/org/torproject/metrics/web/ResearchServlet.java
+++ b/src/main/java/org/torproject/metrics/web/ResearchServlet.java
@@ -14,11 +14,6 @@ public class ResearchServlet extends AnyServlet {
private static final long serialVersionUID = 7380914323836427960L;
@Override
- public void init() throws ServletException {
- super.init();
- }
-
- @Override
public void doGet(HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException {
diff --git a/src/main/java/org/torproject/metrics/web/ServicesServlet.java b/src/main/java/org/torproject/metrics/web/ServicesServlet.java
index c9fa3ad..df4fe1e 100644
--- a/src/main/java/org/torproject/metrics/web/ServicesServlet.java
+++ b/src/main/java/org/torproject/metrics/web/ServicesServlet.java
@@ -14,11 +14,6 @@ public class ServicesServlet extends AnyServlet {
private static final long serialVersionUID = 516625494518844400L;
@Override
- public void init() throws ServletException {
- super.init();
- }
-
- @Override
public void doGet(HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException {
diff --git a/src/main/java/org/torproject/metrics/web/SourcesServlet.java b/src/main/java/org/torproject/metrics/web/SourcesServlet.java
index 03dcfc5..d1296cc 100644
--- a/src/main/java/org/torproject/metrics/web/SourcesServlet.java
+++ b/src/main/java/org/torproject/metrics/web/SourcesServlet.java
@@ -14,11 +14,6 @@ public class SourcesServlet extends AnyServlet {
private static final long serialVersionUID = 6850919895248020945L;
@Override
- public void init() throws ServletException {
- super.init();
- }
-
- @Override
public void doGet(HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException {
diff --git a/src/main/java/org/torproject/metrics/web/StatsServlet.java b/src/main/java/org/torproject/metrics/web/StatsServlet.java
index ca04a5c..79b2ebc 100644
--- a/src/main/java/org/torproject/metrics/web/StatsServlet.java
+++ b/src/main/java/org/torproject/metrics/web/StatsServlet.java
@@ -14,11 +14,6 @@ public class StatsServlet extends AnyServlet {
private static final long serialVersionUID = 6850919895248020945L;
@Override
- public void init() throws ServletException {
- super.init();
- }
-
- @Override
public void doGet(HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException {
1
0
27 Aug '18
commit 9892034b2d9df696c618e11cc0bd8d563128e79f
Author: Karsten Loesing <karsten.loesing(a)gmx.net>
Date: Tue Aug 21 09:45:59 2018 +0200
Remove some more redundant modifiers.
---
src/main/java/org/torproject/metrics/stats/hidserv/Document.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/main/java/org/torproject/metrics/stats/hidserv/Document.java b/src/main/java/org/torproject/metrics/stats/hidserv/Document.java
index 7c915a1..5711a53 100644
--- a/src/main/java/org/torproject/metrics/stats/hidserv/Document.java
+++ b/src/main/java/org/torproject/metrics/stats/hidserv/Document.java
@@ -15,12 +15,12 @@ public interface Document {
* group. Ideally, the first string is equivalent for many documents
* stored in the same file, and the second string is different for those
* documents.</p> */
- public String[] format();
+ String[] format();
/** Initializes an object using the given array of two strings.
*
* <p>These are the same two strings that the format method
* provides.</p> */
- public boolean parse(String[] formattedStrings);
+ boolean parse(String[] formattedStrings);
}
1
0
[metrics-web/master] Replace System.{out|err} calls with proper logging.
by karsten@torproject.org 27 Aug '18
by karsten@torproject.org 27 Aug '18
27 Aug '18
commit 344f7a5da0436ded44eb49fd0874473aa6b18b1a
Author: Karsten Loesing <karsten.loesing(a)gmx.net>
Date: Mon Aug 20 21:51:29 2018 +0200
Replace System.{out|err} calls with proper logging.
---
.../org/torproject/metrics/stats/clients/Main.java | 9 ++-
.../metrics/stats/connbidirect/Main.java | 80 +++++++++++-----------
.../metrics/stats/hidserv/Aggregator.java | 11 ++-
.../stats/hidserv/ComputedNetworkFractions.java | 19 ++---
.../metrics/stats/hidserv/DocumentStore.java | 40 ++++++-----
.../stats/hidserv/ExtrapolatedHidServStats.java | 13 +++-
.../metrics/stats/hidserv/Extrapolator.java | 9 ++-
.../org/torproject/metrics/stats/hidserv/Main.java | 21 +++---
.../torproject/metrics/stats/hidserv/Parser.java | 30 ++++----
.../stats/hidserv/ReportedHidServStats.java | 9 ++-
.../torproject/metrics/stats/hidserv/Simulate.java | 16 +++--
.../org/torproject/metrics/web/UpdateNews.java | 9 ++-
12 files changed, 160 insertions(+), 106 deletions(-)
diff --git a/src/main/java/org/torproject/metrics/stats/clients/Main.java b/src/main/java/org/torproject/metrics/stats/clients/Main.java
index 4f083b9..3ccfe96 100644
--- a/src/main/java/org/torproject/metrics/stats/clients/Main.java
+++ b/src/main/java/org/torproject/metrics/stats/clients/Main.java
@@ -12,6 +12,9 @@ import org.torproject.descriptor.ExtraInfoDescriptor;
import org.torproject.descriptor.NetworkStatusEntry;
import org.torproject.descriptor.RelayNetworkStatusConsensus;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
@@ -25,6 +28,8 @@ import java.util.TreeMap;
public class Main {
+ private static Logger log = LoggerFactory.getLogger(Main.class);
+
/** Executes this data-processing module. */
public static void main(String[] args) throws Exception {
parseArgs(args);
@@ -46,8 +51,8 @@ public class Main {
writeToSingleFile = false;
byStatsDateNotByDescHour = false;
} else {
- System.err.println("Usage: java " + Main.class.getName()
- + " [ --stats-date | --desc-hour ]");
+ log.warn("Usage: java {} [ --stats-date | --desc-hour ]",
+ Main.class.getName());
System.exit(1);
}
}
diff --git a/src/main/java/org/torproject/metrics/stats/connbidirect/Main.java b/src/main/java/org/torproject/metrics/stats/connbidirect/Main.java
index 4474966..c4f1b34 100644
--- a/src/main/java/org/torproject/metrics/stats/connbidirect/Main.java
+++ b/src/main/java/org/torproject/metrics/stats/connbidirect/Main.java
@@ -8,6 +8,9 @@ import org.torproject.descriptor.DescriptorReader;
import org.torproject.descriptor.DescriptorSourceFactory;
import org.torproject.descriptor.ExtraInfoDescriptor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
@@ -30,6 +33,8 @@ import java.util.TreeSet;
public class Main {
+ private static Logger log = LoggerFactory.getLogger(Main.class);
+
static class RawStat implements Comparable<RawStat> {
/* Date when the statistics interval ended in days since the epoch. */
@@ -73,13 +78,13 @@ public class Main {
return new RawStat(dateDays, fingerprint, fractionRead,
fractionWrite, fractionBoth);
} else {
- System.err.println("Could not deserialize raw statistic from "
- + "string '" + string + "'.");
+ log.warn("Could not deserialize raw statistic from string '" + string
+ + "'.");
return null;
}
} catch (NumberFormatException e) {
- System.err.println("Could not deserialize raw statistic from "
- + "string '" + string + "'.");
+ log.warn("Could not deserialize raw statistic from string '{}'.",
+ string, e);
return null;
}
}
@@ -133,14 +138,13 @@ public class Main {
SortedMap<String, Long> parseHistory = parseParseHistory(
readStringFromFile(parseHistoryFile));
if (parseHistory == null) {
- System.err.println("Could not parse "
- + parseHistoryFile.getAbsolutePath() + ". Proceeding without "
- + "parse history.");
+ log.warn("Could not parse {}. Proceeding without parse history.",
+ parseHistoryFile.getAbsolutePath());
}
SortedMap<String, Short> aggregateStats = parseAggregateStats(
readStringFromFile(aggregateStatsFile));
if (aggregateStats == null) {
- System.err.println("Could not parse previously aggregated "
+ log.warn("Could not parse previously aggregated "
+ "statistics. Not proceeding, because we would otherwise "
+ "lose previously aggregated values for which we don't have "
+ "raw statistics anymore.");
@@ -150,7 +154,7 @@ public class Main {
parseHistory = addRawStatsFromDescriptors(newRawStats,
descriptorsDirectories, parseHistory);
if (parseHistory == null) {
- System.err.println("Could not parse raw statistics from "
+ log.warn("Could not parse raw statistics from "
+ "descriptors. Not proceeding, because we would otherwise "
+ "leave out those descriptors in future runs.");
return;
@@ -159,7 +163,7 @@ public class Main {
SortedSet<RawStat> rawStats = parseRawStats(
readStringFromFile(rawStatsFile));
if (rawStats == null) {
- System.err.println("Could not parse previously parsed raw "
+ log.warn("Could not parse previously parsed raw "
+ "statistics. Not proceeding, because we might otherwise "
+ "leave out previously parsed statistics in the aggregates.");
return;
@@ -167,7 +171,8 @@ public class Main {
SortedSet<Long> conflictingDates = mergeRawStats(rawStats,
newRawStats);
if (!conflictingDates.isEmpty()) {
- System.err.print("Could not update aggregate statistics, because "
+ StringBuilder sb = new StringBuilder(
+ "Could not update aggregate statistics, because "
+ "we already aggregated statistics for at least one contained "
+ "date and discarded the underlying raw statistics. Not "
+ "proceeding. To fix this, you'll have to re-import "
@@ -175,10 +180,10 @@ public class Main {
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
for (long conflictingDate : conflictingDates) {
- System.err.print(" " + dateFormat.format(conflictingDate
- * ONE_DAY_IN_MILLIS));
+ sb.append("\n "
+ + dateFormat.format(conflictingDate * ONE_DAY_IN_MILLIS));
}
- System.err.println();
+ log.warn(sb.toString());
return;
}
updateAggregateStats(aggregateStats, rawStats);
@@ -237,20 +242,19 @@ public class Main {
while ((line = lnr.readLine()) != null) {
String[] parts = line.split(",");
if (parts.length < 2) {
- System.err.println("Invalid line " + lnr.getLineNumber()
- + " in parse history: '" + line + "'.");
+ log.warn("Invalid line {} in parse history: '{}'.",
+ lnr.getLineNumber(), line);
return null;
}
parsedParseHistory.put(parts[0], Long.parseLong(parts[1]));
}
} catch (IOException e) {
- System.err.println("Unexpected I/O exception while reading line "
- + lnr.getLineNumber() + " from parse history.");
- e.printStackTrace();
+ log.warn("Unexpected I/O exception while reading line {} from parse "
+ + "history.", lnr.getLineNumber(), e);
return null;
} catch (NumberFormatException e) {
- System.err.println("Invalid line " + lnr.getLineNumber()
- + " in parse history: '" + line + "'.");
+ log.warn("Invalid line {} in parse history: '{}'.", lnr.getLineNumber(),
+ line, e);
return null;
}
return parsedParseHistory;
@@ -285,28 +289,27 @@ public class Main {
String line = "";
try {
if (!AGGREGATE_STATS_HEADER.equals(lnr.readLine())) {
- System.err.println("First line of aggregate statistics does not "
- + "contain the header line. Is this the correct file?");
+ log.warn("First line of aggregate statistics does not "
+ + "contain the header line. Is this the correct file?");
return null;
}
while ((line = lnr.readLine()) != null) {
String[] parts = line.split(",");
if (parts.length != 4) {
- System.err.println("Invalid line " + lnr.getLineNumber()
- + " in aggregate statistics: '" + line + "'.");
+ log.warn("Invalid line {} in aggregate statistics: '{}'.",
+ lnr.getLineNumber(), line);
return null;
}
parsedAggregateStats.put(parts[0] + "," + parts[1] + ","
+ parts[2], Short.parseShort(parts[3]));
}
} catch (IOException e) {
- System.err.println("Unexpected I/O exception while reading line "
- + lnr.getLineNumber() + " from aggregate statistics.");
- e.printStackTrace();
+ log.warn("Unexpected I/O exception while reading line {} from aggregate "
+ + "statistics.", lnr.getLineNumber(), e);
return null;
} catch (NumberFormatException e) {
- System.err.println("Invalid line " + lnr.getLineNumber()
- + " in aggregate statistics: '" + line + "'.");
+ log.warn("Invalid line {} in aggregate statistics: '{}'.",
+ lnr.getLineNumber(), line, e);
return null;
}
return parsedAggregateStats;
@@ -332,20 +335,19 @@ public class Main {
while ((line = lnr.readLine()) != null) {
RawStat rawStat = RawStat.fromString(line);
if (rawStat == null) {
- System.err.println("Invalid line " + lnr.getLineNumber()
- + " in raw statistics: '" + line + "'.");
+ log.warn("Invalid line {} in raw statistics: '{}'.",
+ lnr.getLineNumber(), line);
return null;
}
parsedRawStats.add(rawStat);
}
} catch (IOException e) {
- System.err.println("Unexpected I/O exception while reading line "
- + lnr.getLineNumber() + " from raw statistics.");
- e.printStackTrace();
+ log.warn("Unexpected I/O exception while reading line {} from raw "
+ + "statistics.", lnr.getLineNumber(), e);
return null;
} catch (NumberFormatException e) {
- System.err.println("Invalid line " + lnr.getLineNumber()
- + " in raw statistics: '" + line + "'.");
+ log.warn("Invalid line {} in raw statistics: '{}'.", lnr.getLineNumber(),
+ line, e);
return null;
}
return parsedRawStats;
@@ -384,8 +386,8 @@ public class Main {
int write = extraInfo.getConnBiDirectWrite();
int both = extraInfo.getConnBiDirectBoth();
if (below < 0 || read < 0 || write < 0 || both < 0) {
- System.err.println("Could not parse incomplete conn-bi-direct "
- + "statistics. Skipping descriptor.");
+ log.debug("Could not parse incomplete conn-bi-direct statistics. "
+ + "Skipping descriptor.");
return null;
}
long statsEndMillis = extraInfo.getConnBiDirectStatsEndMillis();
diff --git a/src/main/java/org/torproject/metrics/stats/hidserv/Aggregator.java b/src/main/java/org/torproject/metrics/stats/hidserv/Aggregator.java
index 9ef3ee8..14fc31f 100644
--- a/src/main/java/org/torproject/metrics/stats/hidserv/Aggregator.java
+++ b/src/main/java/org/torproject/metrics/stats/hidserv/Aggregator.java
@@ -3,6 +3,9 @@
package org.torproject.metrics.stats.hidserv;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
@@ -21,6 +24,8 @@ import java.util.TreeMap;
* statistics and the total network fraction of reporting relays. */
public class Aggregator {
+ private static Logger log = LoggerFactory.getLogger(Aggregator.class);
+
/** Document file containing extrapolated hidden-service statistics. */
private File extrapolatedHidServStatsFile;
@@ -57,8 +62,8 @@ public class Aggregator {
this.extrapolatedHidServStatsStore.retrieve(
this.extrapolatedHidServStatsFile);
if (extrapolatedStats == null) {
- System.err.printf("Unable to retrieve extrapolated hidden-service "
- + "statistics from file %s. Skipping aggregation step.%n",
+ log.warn("Unable to retrieve extrapolated hidden-service "
+ + "statistics from file {}. Skipping aggregation step.",
this.extrapolatedHidServStatsFile.getAbsolutePath());
return;
}
@@ -187,7 +192,7 @@ public class Aggregator {
this.hidservStatsCsvFile))) {
bw.write(sb.toString());
} catch (IOException e) {
- System.err.printf("Unable to write results to %s. Ignoring.",
+ log.warn("Unable to write results to {}. Ignoring.",
this.extrapolatedHidServStatsFile.getAbsolutePath());
}
}
diff --git a/src/main/java/org/torproject/metrics/stats/hidserv/ComputedNetworkFractions.java b/src/main/java/org/torproject/metrics/stats/hidserv/ComputedNetworkFractions.java
index 64547cc..d5fd279 100644
--- a/src/main/java/org/torproject/metrics/stats/hidserv/ComputedNetworkFractions.java
+++ b/src/main/java/org/torproject/metrics/stats/hidserv/ComputedNetworkFractions.java
@@ -3,6 +3,9 @@
package org.torproject.metrics.stats.hidserv;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
@@ -12,6 +15,9 @@ import java.util.Map;
* status entries and bandwidth weights in a network status consensus. */
public class ComputedNetworkFractions implements Document {
+ private static Logger log
+ = LoggerFactory.getLogger(ComputedNetworkFractions.class);
+
/** Relay fingerprint consisting of 40 upper-case hex characters. */
private String fingerprint;
@@ -131,21 +137,18 @@ public class ComputedNetworkFractions implements Document {
@Override
public boolean parse(String[] formattedStrings) {
if (formattedStrings.length != 2) {
- System.err.printf("Invalid number of formatted strings. "
- + "Skipping.%n");
+ log.warn("Invalid number of formatted strings. Skipping.");
return false;
}
String[] firstParts = formattedStrings[0].split(",", 2);
if (firstParts.length != 2) {
- System.err.printf("Invalid number of comma-separated values. "
- + "Skipping.%n");
+ log.warn("Invalid number of comma-separated values. Skipping.");
return false;
}
String fingerprint = firstParts[0];
String[] secondParts = formattedStrings[1].split(",", 3);
if (secondParts.length != 3) {
- System.err.printf("Invalid number of comma-separated values. "
- + "Skipping.%n");
+ log.warn("Invalid number of comma-separated values. Skipping.");
return false;
}
String validAfterDate = firstParts[1];
@@ -163,7 +166,7 @@ public class ComputedNetworkFractions implements Document {
if (validAfterDateMillis == DateTimeHelper.NO_TIME_AVAILABLE
|| validAfterTimeMillis < 0L
|| validAfterTimeMillis >= DateTimeHelper.ONE_DAY) {
- System.err.printf("Invalid date/hour format. Skipping.%n");
+ log.warn("Invalid date/hour format. Skipping.");
return false;
}
long validAfterMillis = validAfterDateMillis + validAfterTimeMillis;
@@ -176,7 +179,7 @@ public class ComputedNetworkFractions implements Document {
? 0.0 : Double.parseDouble(secondParts[2]);
return true;
} catch (NumberFormatException e) {
- System.err.printf("Invalid number format. Skipping.%n");
+ log.warn("Invalid number format. Skipping.");
return false;
}
}
diff --git a/src/main/java/org/torproject/metrics/stats/hidserv/DocumentStore.java b/src/main/java/org/torproject/metrics/stats/hidserv/DocumentStore.java
index 118071e..f73812a 100644
--- a/src/main/java/org/torproject/metrics/stats/hidserv/DocumentStore.java
+++ b/src/main/java/org/torproject/metrics/stats/hidserv/DocumentStore.java
@@ -3,6 +3,9 @@
package org.torproject.metrics.stats.hidserv;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
@@ -22,6 +25,8 @@ import java.util.TreeSet;
* interface to a file and later to retrieve them. */
public class DocumentStore<T extends Document> {
+ private static Logger log = LoggerFactory.getLogger(DocumentStore.class);
+
/** Document class, needed to create new instances when retrieving
* documents. */
private Class<T> clazz;
@@ -41,8 +46,8 @@ public class DocumentStore<T extends Document> {
/* Retrieve existing documents. */
Set<T> retrievedDocuments = this.retrieve(documentFile);
if (retrievedDocuments == null) {
- System.err.printf("Unable to read and update %s. Not storing "
- + "documents.%n", documentFile.getAbsoluteFile());
+ log.warn("Unable to read and update {}. Not storing documents.",
+ documentFile.getAbsoluteFile());
return false;
}
@@ -64,9 +69,9 @@ public class DocumentStore<T extends Document> {
File documentTempFile = new File(documentFile.getAbsoluteFile()
+ ".tmp");
if (documentTempFile.exists()) {
- System.err.printf("Temporary document file %s still exists, "
+ log.warn("Temporary document file {} still exists, "
+ "indicating that a previous execution did not terminate "
- + "cleanly. Not storing documents.%n",
+ + "cleanly. Not storing documents.",
documentTempFile.getAbsoluteFile());
return false;
}
@@ -86,8 +91,8 @@ public class DocumentStore<T extends Document> {
documentFile.delete();
documentTempFile.renameTo(documentFile);
} catch (IOException e) {
- System.err.printf("Unable to write %s. Not storing documents.%n",
- documentFile.getAbsolutePath());
+ log.warn("Unable to write {}. Not storing documents.",
+ documentFile.getAbsolutePath(), e);
return false;
}
@@ -121,9 +126,9 @@ public class DocumentStore<T extends Document> {
if (!line.startsWith(" ")) {
formattedString0 = line;
} else if (formattedString0 == null) {
- System.err.printf("First line in %s must not start with a "
- + "space. Not retrieving any previously stored "
- + "documents.%n", documentFile.getAbsolutePath());
+ log.warn("First line in {} must not start with a space. Not "
+ + "retrieving any previously stored documents.",
+ documentFile.getAbsolutePath());
return null;
} else if (prefix.length() > formattedString0.length()
&& !(formattedString0 + line.substring(1))
@@ -138,24 +143,21 @@ public class DocumentStore<T extends Document> {
T document = this.clazz.newInstance();
if (!document.parse(new String[] { formattedString0,
line.substring(1) })) {
- System.err.printf("Unable to read line %d from %s. Not "
- + "retrieving any previously stored documents.%n",
- lnr.getLineNumber(), documentFile.getAbsolutePath());
+ log.warn("Unable to read line {} from {}. Not retrieving any "
+ + "previously stored documents.", lnr.getLineNumber(),
+ documentFile.getAbsolutePath());
return null;
}
result.add(document);
}
}
} catch (IOException e) {
- System.err.printf("Unable to read %s. Not retrieving any "
- + "previously stored documents.%n",
- documentFile.getAbsolutePath());
- e.printStackTrace();
+ log.warn("Unable to read {}. Not retrieving any previously stored "
+ + "documents.", documentFile.getAbsolutePath(), e);
return null;
} catch (InstantiationException | IllegalAccessException e) {
- System.err.printf("Unable to read %s. Cannot instantiate document "
- + "object.%n", documentFile.getAbsolutePath());
- e.printStackTrace();
+ log.warn("Unable to read {}. Cannot instantiate document object.",
+ documentFile.getAbsolutePath(), e);
return null;
}
return result;
diff --git a/src/main/java/org/torproject/metrics/stats/hidserv/ExtrapolatedHidServStats.java b/src/main/java/org/torproject/metrics/stats/hidserv/ExtrapolatedHidServStats.java
index 9379d87..ec09630 100644
--- a/src/main/java/org/torproject/metrics/stats/hidserv/ExtrapolatedHidServStats.java
+++ b/src/main/java/org/torproject/metrics/stats/hidserv/ExtrapolatedHidServStats.java
@@ -3,11 +3,17 @@
package org.torproject.metrics.stats.hidserv;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
/** Extrapolated network totals of hidden-service statistics reported by a
* single relay. Extrapolated values are based on reported statistics and
* computed network fractions in the statistics interval. */
public class ExtrapolatedHidServStats implements Document {
+ private static Logger log
+ = LoggerFactory.getLogger(ExtrapolatedHidServStats.class);
+
/** Date of statistics interval end in milliseconds. */
private long statsDateMillis;
@@ -130,15 +136,16 @@ public class ExtrapolatedHidServStats implements Document {
@Override
public boolean parse(String[] formattedStrings) {
if (formattedStrings.length != 2) {
- System.err.printf("Invalid number of formatted strings. Skipping.%n");
+ log.warn("Invalid number of formatted strings: {}. Skipping.",
+ formattedStrings.length);
return false;
}
long statsDateMillis = DateTimeHelper.parse(formattedStrings[0],
DateTimeHelper.ISO_DATE_FORMAT);
String[] secondParts = formattedStrings[1].split(",", 5);
if (secondParts.length != 5) {
- System.err.printf("Invalid number of comma-separated values. "
- + "Skipping.%n");
+ log.warn("Invalid number of comma-separated values: {}. Skipping.",
+ secondParts.length);
return false;
}
String fingerprint = secondParts[0];
diff --git a/src/main/java/org/torproject/metrics/stats/hidserv/Extrapolator.java b/src/main/java/org/torproject/metrics/stats/hidserv/Extrapolator.java
index 4bce0e6..2c4a8f8 100644
--- a/src/main/java/org/torproject/metrics/stats/hidserv/Extrapolator.java
+++ b/src/main/java/org/torproject/metrics/stats/hidserv/Extrapolator.java
@@ -3,6 +3,9 @@
package org.torproject.metrics.stats.hidserv;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import java.io.File;
import java.util.HashSet;
import java.util.Map;
@@ -17,6 +20,8 @@ import java.util.TreeSet;
* observed by the relay. */
public class Extrapolator {
+ private static Logger log = LoggerFactory.getLogger(Extrapolator.class);
+
/** Document file containing previously parsed reported hidden-service
* statistics. */
private File reportedHidServStatsFile;
@@ -84,8 +89,8 @@ public class Extrapolator {
/* Make sure that all documents could be retrieved correctly. */
if (extrapolatedStats == null || reportedStats == null) {
- System.err.printf("Could not read previously parsed or "
- + "extrapolated hidserv-stats. Skipping.");
+ log.warn("Could not read previously parsed or extrapolated "
+ + "hidserv-stats. Skipping.");
return false;
}
diff --git a/src/main/java/org/torproject/metrics/stats/hidserv/Main.java b/src/main/java/org/torproject/metrics/stats/hidserv/Main.java
index eafeeb1..b6a4e43 100644
--- a/src/main/java/org/torproject/metrics/stats/hidserv/Main.java
+++ b/src/main/java/org/torproject/metrics/stats/hidserv/Main.java
@@ -3,6 +3,9 @@
package org.torproject.metrics.stats.hidserv;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import java.io.File;
/** Main class for updating extrapolated network totals of hidden-service
@@ -11,6 +14,8 @@ import java.io.File;
* do not overlap. */
public class Main {
+ private static Logger log = LoggerFactory.getLogger(Main.class);
+
/** Parses new descriptors, extrapolate contained statistics using
* computed network fractions, aggregate results, and writes results to
* disk. */
@@ -24,8 +29,7 @@ public class Main {
/* Initialize parser and read parse history to avoid parsing
* descriptor files that haven't changed since the last execution. */
- System.out.println("Initializing parser and reading parse "
- + "history...");
+ log.info("Initializing parser and reading parse history...");
DocumentStore<ReportedHidServStats> reportedHidServStatsStore =
new DocumentStore<>(ReportedHidServStats.class);
DocumentStore<ComputedNetworkFractions>
@@ -37,29 +41,28 @@ public class Main {
/* Parse new descriptors and store their contents using the document
* stores. */
- System.out.println("Parsing descriptors...");
+ log.info("Parsing descriptors...");
parser.parseDescriptors();
/* Write the parse history to avoid parsing descriptor files again
* next time. It's okay to do this now and not at the end of the
* execution, because even if something breaks apart below, it's safe
* not to parse descriptor files again. */
- System.out.println("Writing parse history...");
+ log.info("Writing parse history...");
parser.writeParseHistory();
/* Extrapolate reported statistics using computed network fractions
* and write the result to disk using a document store. The result is
* a single file with extrapolated network totals based on reports by
* single relays. */
- System.out.println("Extrapolating statistics...");
+ log.info("Extrapolating statistics...");
DocumentStore<ExtrapolatedHidServStats> extrapolatedHidServStatsStore
= new DocumentStore<>(ExtrapolatedHidServStats.class);
Extrapolator extrapolator = new Extrapolator(statusDirectory,
reportedHidServStatsStore, computedNetworkFractionsStore,
extrapolatedHidServStatsStore);
if (!extrapolator.extrapolateHidServStats()) {
- System.err.println("Could not extrapolate statistics. "
- + "Terminating.");
+ log.warn("Could not extrapolate statistics. Terminating.");
return;
}
@@ -67,14 +70,14 @@ public class Main {
* This includes calculating daily weighted interquartile means, among
* other statistics. Write the result to a .csv file that can be
* processed by other tools. */
- System.out.println("Aggregating statistics...");
+ log.info("Aggregating statistics...");
File hidservStatsExtrapolatedCsvFile = new File("stats/hidserv.csv");
Aggregator aggregator = new Aggregator(statusDirectory,
extrapolatedHidServStatsStore, hidservStatsExtrapolatedCsvFile);
aggregator.aggregateHidServStats();
/* End this execution. */
- System.out.println("Terminating.");
+ log.info("Terminating.");
}
}
diff --git a/src/main/java/org/torproject/metrics/stats/hidserv/Parser.java b/src/main/java/org/torproject/metrics/stats/hidserv/Parser.java
index 9c95db5..4f7ac6c 100644
--- a/src/main/java/org/torproject/metrics/stats/hidserv/Parser.java
+++ b/src/main/java/org/torproject/metrics/stats/hidserv/Parser.java
@@ -10,6 +10,9 @@ import org.torproject.descriptor.ExtraInfoDescriptor;
import org.torproject.descriptor.NetworkStatusEntry;
import org.torproject.descriptor.RelayNetworkStatusConsensus;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
@@ -32,6 +35,8 @@ import java.util.TreeSet;
* document files for later use. */
public class Parser {
+ private static Logger log = LoggerFactory.getLogger(Parser.class);
+
/** File containing tuples of last-modified times and file names of
* descriptor files parsed in the previous execution. */
private File parseHistoryFile;
@@ -106,14 +111,14 @@ public class Parser {
String[] parts = line.split(" ", 2);
excludedFiles.put(parts[1], Long.parseLong(parts[0]));
} catch (NumberFormatException e) {
- System.err.printf("Illegal line '%s' in parse history. "
- + "Skipping line.%n", line);
+ log.warn("Illegal line '{}' in parse history. Skipping line.", line,
+ e);
}
}
} catch (IOException e) {
- System.err.printf("Could not read history file '%s'. Not "
+ log.warn("Could not read history file '{}'. Not "
+ "excluding descriptors in this execution.",
- this.parseHistoryFile.getAbsolutePath());
+ this.parseHistoryFile.getAbsolutePath(), e);
}
/* Tell the descriptor reader to exclude the files contained in the
@@ -146,9 +151,8 @@ public class Parser {
+ "\n");
}
} catch (IOException e) {
- System.err.printf("Could not write history file '%s'. Not "
- + "excluding descriptors in next execution.",
- this.parseHistoryFile.getAbsolutePath());
+ log.warn("Could not write history file '{}'. Not excluding descriptors "
+ + "in next execution.", this.parseHistoryFile.getAbsolutePath(), e);
}
}
@@ -234,8 +238,8 @@ public class Parser {
* because relays can in theory write anything in their extra-info
* descriptors. But maybe we'll want to know. */
} else {
- System.err.println("Relay " + fingerprint + " published "
- + "incomplete hidserv-stats. Ignoring.");
+ log.warn("Relay {} published incomplete hidserv-stats. Ignoring.",
+ fingerprint);
}
}
@@ -257,8 +261,8 @@ public class Parser {
SortedMap<String, Integer> bandwidthWeights =
consensus.getBandwidthWeights();
if (bandwidthWeights == null) {
- System.err.printf("Consensus with valid-after time %s doesn't "
- + "contain any Wxx weights. Skipping.%n",
+ log.warn("Consensus with valid-after time {} doesn't contain any Wxx "
+ + "weights. Skipping.",
DateTimeHelper.format(consensus.getValidAfterMillis()));
return;
}
@@ -269,8 +273,8 @@ public class Parser {
new TreeSet<>(Arrays.asList("Wmg,Wmm,Wme,Wmd".split(",")));
expectedWeightKeys.removeAll(bandwidthWeights.keySet());
if (!expectedWeightKeys.isEmpty()) {
- System.err.printf("Consensus with valid-after time %s doesn't "
- + "contain expected Wmx weights. Skipping.%n",
+ log.warn("Consensus with valid-after time {} doesn't contain expected "
+ + "Wmx weights. Skipping.",
DateTimeHelper.format(consensus.getValidAfterMillis()));
return;
}
diff --git a/src/main/java/org/torproject/metrics/stats/hidserv/ReportedHidServStats.java b/src/main/java/org/torproject/metrics/stats/hidserv/ReportedHidServStats.java
index 08ab024..58abbf7 100644
--- a/src/main/java/org/torproject/metrics/stats/hidserv/ReportedHidServStats.java
+++ b/src/main/java/org/torproject/metrics/stats/hidserv/ReportedHidServStats.java
@@ -3,11 +3,17 @@
package org.torproject.metrics.stats.hidserv;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
/* Hidden-service statistics reported by a single relay covering a single
* statistics interval of usually 24 hours. These statistics are reported
* by the relay in the "hidserv-" lines of its extra-info descriptor. */
public class ReportedHidServStats implements Document {
+ private static Logger log
+ = LoggerFactory.getLogger(ReportedHidServStats.class);
+
/* Relay fingerprint consisting of 40 upper-case hex characters. */
private String fingerprint;
@@ -109,7 +115,8 @@ public class ReportedHidServStats implements Document {
@Override
public boolean parse(String[] formattedStrings) {
if (formattedStrings.length != 2) {
- System.err.printf("Invalid number of formatted strings. Skipping.%n");
+ log.warn("Invalid number of formatted strings: {} Skipping.",
+ formattedStrings.length);
return false;
}
String[] secondParts = formattedStrings[1].split(",", 4);
diff --git a/src/main/java/org/torproject/metrics/stats/hidserv/Simulate.java b/src/main/java/org/torproject/metrics/stats/hidserv/Simulate.java
index 7acf1e8..ac8a82e 100644
--- a/src/main/java/org/torproject/metrics/stats/hidserv/Simulate.java
+++ b/src/main/java/org/torproject/metrics/stats/hidserv/Simulate.java
@@ -3,6 +3,9 @@
package org.torproject.metrics.stats.hidserv;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
@@ -20,6 +23,9 @@ import java.util.TreeSet;
/* NOTE: This class is not required for running the Main class! (It
* contains its own main method.) */
public class Simulate {
+
+ private static Logger log = LoggerFactory.getLogger(Simulate.class);
+
private static File simCellsCsvFile =
new File("out/csv/sim-cells.csv");
@@ -28,11 +34,11 @@ public class Simulate {
/** Runs two simulations to evaluate this data-processing module. */
public static void main(String[] args) throws Exception {
- System.out.print("Simulating extrapolation of rendezvous cells");
+ log.info("Simulating extrapolation of rendezvous cells");
simulateManyCells();
- System.out.print("\nSimulating extrapolation of .onions");
+ log.info("Simulating extrapolation of .onions");
simulateManyOnions();
- System.out.println("\nTerminating.");
+ log.info("Terminating.");
}
private static Random rnd = new Random();
@@ -45,7 +51,7 @@ public class Simulate {
final int numberOfExtrapolations = 1000;
for (int i = 0; i < numberOfExtrapolations; i++) {
bw.write(simulateCells(i));
- System.out.print(".");
+ log.info(".");
}
bw.close();
}
@@ -58,7 +64,7 @@ public class Simulate {
final int numberOfExtrapolations = 1000;
for (int i = 0; i < numberOfExtrapolations; i++) {
bw.write(simulateOnions(i));
- System.out.print(".");
+ log.info(".");
}
bw.close();
}
diff --git a/src/main/java/org/torproject/metrics/web/UpdateNews.java b/src/main/java/org/torproject/metrics/web/UpdateNews.java
index 2865516..abce4f1 100644
--- a/src/main/java/org/torproject/metrics/web/UpdateNews.java
+++ b/src/main/java/org/torproject/metrics/web/UpdateNews.java
@@ -5,6 +5,8 @@ import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.io.BufferedReader;
import java.io.FileWriter;
@@ -14,6 +16,9 @@ import java.util.ArrayList;
import java.util.List;
public class UpdateNews {
+
+ private static Logger log = LoggerFactory.getLogger(UpdateNews.class);
+
/** Update news. */
public static void main(String[] args) throws Exception {
URL textFile = new URL(
@@ -72,7 +77,7 @@ public class UpdateNews {
int space = desc.indexOf(" ", open);
int close = desc.indexOf("]", open);
if (open < 0 || space < 0 || close < 0) {
- System.err.println("Cannot convert link.");
+ log.warn("Cannot convert link in line {}. Exiting.");
System.exit(1);
}
desc = desc.substring(0, open) + "<a href=\""
@@ -84,7 +89,7 @@ public class UpdateNews {
int open = desc.indexOf("`");
int close = desc.indexOf("`", open + 1);
if (open < 0 || close < 0) {
- System.err.println("Cannot convert code fragment.");
+ log.warn("Cannot convert code fragment in line {}. Exiting.");
System.exit(1);
}
desc = desc.substring(0, open) + "<code>"
1
0
[metrics-web/master] Remove redundant escape in regular expression.
by karsten@torproject.org 27 Aug '18
by karsten@torproject.org 27 Aug '18
27 Aug '18
commit ab164e7a4b5228d9b7dc53d72f36d9ab070bf934
Author: Karsten Loesing <karsten.loesing(a)gmx.net>
Date: Mon Aug 20 20:50:53 2018 +0200
Remove redundant escape in regular expression.
---
src/main/java/org/torproject/metrics/web/UpdateNews.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/main/java/org/torproject/metrics/web/UpdateNews.java b/src/main/java/org/torproject/metrics/web/UpdateNews.java
index 4de7952..2865516 100644
--- a/src/main/java/org/torproject/metrics/web/UpdateNews.java
+++ b/src/main/java/org/torproject/metrics/web/UpdateNews.java
@@ -99,7 +99,7 @@ public class UpdateNews {
.replaceAll("“", "“")
.replaceAll("”", "”");
String shortDesc = desc
- .replaceAll("\\<.*?\\>", "")
+ .replaceAll("<.*?>", "")
.replaceAll("&.*;", "");
if (shortDesc.contains(". ")) {
shortDesc = shortDesc.substring(0, shortDesc.indexOf(". "));
1
0
27 Aug '18
commit e04eec7cb742efb5348925524d9a37d5d0a66a7a
Author: Karsten Loesing <karsten.loesing(a)gmx.net>
Date: Tue Aug 21 14:09:58 2018 +0200
Inline redundant local variables.
---
src/main/java/org/torproject/metrics/stats/hidserv/Parser.java | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/src/main/java/org/torproject/metrics/stats/hidserv/Parser.java b/src/main/java/org/torproject/metrics/stats/hidserv/Parser.java
index 5970e32..558ce39 100644
--- a/src/main/java/org/torproject/metrics/stats/hidserv/Parser.java
+++ b/src/main/java/org/torproject/metrics/stats/hidserv/Parser.java
@@ -241,9 +241,7 @@ public class Parser {
private long removeNoise(long reportedNumber, long binSize) {
long roundedToNearestRightSideOfTheBin =
Math.floorDiv((reportedNumber + binSize / 2), binSize) * binSize;
- long subtractedHalfOfBinSize =
- roundedToNearestRightSideOfTheBin - binSize / 2;
- return subtractedHalfOfBinSize;
+ return roundedToNearestRightSideOfTheBin - binSize / 2;
}
/** Parses the given consensus. */
1
0
[metrics-web/master] Use StringBuilder's append rather than string concatenation.
by karsten@torproject.org 27 Aug '18
by karsten@torproject.org 27 Aug '18
27 Aug '18
commit 21277083a87fe409fb9bcdb4e676984f9856fcd1
Author: Karsten Loesing <karsten.loesing(a)gmx.net>
Date: Tue Aug 21 12:09:45 2018 +0200
Use StringBuilder's append rather than string concatenation.
---
src/main/java/org/torproject/metrics/stats/connbidirect/Main.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/main/java/org/torproject/metrics/stats/connbidirect/Main.java b/src/main/java/org/torproject/metrics/stats/connbidirect/Main.java
index 426a7cf..a069d84 100644
--- a/src/main/java/org/torproject/metrics/stats/connbidirect/Main.java
+++ b/src/main/java/org/torproject/metrics/stats/connbidirect/Main.java
@@ -180,8 +180,8 @@ public class Main {
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
for (long conflictingDate : conflictingDates) {
- sb.append("\n "
- + dateFormat.format(conflictingDate * ONE_DAY_IN_MILLIS));
+ sb.append("\n ")
+ .append(dateFormat.format(conflictingDate * ONE_DAY_IN_MILLIS));
}
log.warn(sb.toString());
return;
1
0
[metrics-web/master] Use Map.putIfAbsent and Map.getOrDefault where possible.
by karsten@torproject.org 27 Aug '18
by karsten@torproject.org 27 Aug '18
27 Aug '18
commit 5e4ef944eccf18b5276647828162fa2bc76a2f8f
Author: Karsten Loesing <karsten.loesing(a)gmx.net>
Date: Tue Aug 21 15:12:01 2018 +0200
Use Map.putIfAbsent and Map.getOrDefault where possible.
---
src/main/java/org/torproject/metrics/stats/connbidirect/Main.java | 7 ++-----
.../java/org/torproject/metrics/stats/hidserv/Aggregator.java | 8 ++------
.../java/org/torproject/metrics/stats/hidserv/DocumentStore.java | 4 +---
.../java/org/torproject/metrics/stats/hidserv/Extrapolator.java | 4 +---
.../metrics/stats/servers/ConsensusStatsFileHandler.java | 8 ++------
src/main/java/org/torproject/metrics/web/MetricServlet.java | 4 +---
6 files changed, 9 insertions(+), 26 deletions(-)
diff --git a/src/main/java/org/torproject/metrics/stats/connbidirect/Main.java b/src/main/java/org/torproject/metrics/stats/connbidirect/Main.java
index a069d84..b2dc1b6 100644
--- a/src/main/java/org/torproject/metrics/stats/connbidirect/Main.java
+++ b/src/main/java/org/torproject/metrics/stats/connbidirect/Main.java
@@ -447,11 +447,8 @@ public class Main {
rawStat.fractionWrite, rawStat.fractionBoth };
for (int i = 0; i < directions.length; i++) {
String dateAndDirection = date + "," + directions[i];
- if (!fractionsByDateAndDirection.containsKey(
- dateAndDirection)) {
- fractionsByDateAndDirection.put(dateAndDirection,
- new ArrayList<>());
- }
+ fractionsByDateAndDirection.putIfAbsent(dateAndDirection,
+ new ArrayList<>());
fractionsByDateAndDirection.get(dateAndDirection).add(
fractions[i]);
}
diff --git a/src/main/java/org/torproject/metrics/stats/hidserv/Aggregator.java b/src/main/java/org/torproject/metrics/stats/hidserv/Aggregator.java
index 14fc31f..36e7967 100644
--- a/src/main/java/org/torproject/metrics/stats/hidserv/Aggregator.java
+++ b/src/main/java/org/torproject/metrics/stats/hidserv/Aggregator.java
@@ -88,17 +88,13 @@ public class Aggregator {
continue;
}
if (extrapolated.getFractionRendRelayedCells() > 0.0) {
- if (!extrapolatedCells.containsKey(date)) {
- extrapolatedCells.put(date, new ArrayList<>());
- }
+ extrapolatedCells.putIfAbsent(date, new ArrayList<>());
extrapolatedCells.get(date).add(new double[] {
extrapolated.getExtrapolatedRendRelayedCells(),
extrapolated.getFractionRendRelayedCells() });
}
if (extrapolated.getFractionDirOnionsSeen() > 0.0) {
- if (!extrapolatedOnions.containsKey(date)) {
- extrapolatedOnions.put(date, new ArrayList<>());
- }
+ extrapolatedOnions.putIfAbsent(date, new ArrayList<>());
extrapolatedOnions.get(date).add(new double[] {
extrapolated.getExtrapolatedDirOnionsSeen(),
extrapolated.getFractionDirOnionsSeen() });
diff --git a/src/main/java/org/torproject/metrics/stats/hidserv/DocumentStore.java b/src/main/java/org/torproject/metrics/stats/hidserv/DocumentStore.java
index f73812a..61b9fa8 100644
--- a/src/main/java/org/torproject/metrics/stats/hidserv/DocumentStore.java
+++ b/src/main/java/org/torproject/metrics/stats/hidserv/DocumentStore.java
@@ -58,9 +58,7 @@ public class DocumentStore<T extends Document> {
SortedMap<String, SortedSet<String>> formattedDocuments = new TreeMap<>();
for (T retrieveDocument : retrievedDocuments) {
String[] formattedDocument = retrieveDocument.format();
- if (!formattedDocuments.containsKey(formattedDocument[0])) {
- formattedDocuments.put(formattedDocument[0], new TreeSet<>());
- }
+ formattedDocuments.putIfAbsent(formattedDocument[0], new TreeSet<>());
formattedDocuments.get(formattedDocument[0]).add(
formattedDocument[1]);
}
diff --git a/src/main/java/org/torproject/metrics/stats/hidserv/Extrapolator.java b/src/main/java/org/torproject/metrics/stats/hidserv/Extrapolator.java
index 2c4a8f8..0dcc638 100644
--- a/src/main/java/org/torproject/metrics/stats/hidserv/Extrapolator.java
+++ b/src/main/java/org/torproject/metrics/stats/hidserv/Extrapolator.java
@@ -99,9 +99,7 @@ public class Extrapolator {
new TreeMap<>();
for (ReportedHidServStats stat : reportedStats) {
String fingerprint = stat.getFingerprint();
- if (!parsedStatsByFingerprint.containsKey(fingerprint)) {
- parsedStatsByFingerprint.put(fingerprint, new HashSet<>());
- }
+ parsedStatsByFingerprint.putIfAbsent(fingerprint, new HashSet<>());
parsedStatsByFingerprint.get(fingerprint).add(stat);
}
diff --git a/src/main/java/org/torproject/metrics/stats/servers/ConsensusStatsFileHandler.java b/src/main/java/org/torproject/metrics/stats/servers/ConsensusStatsFileHandler.java
index f4f99cd..491170e 100644
--- a/src/main/java/org/torproject/metrics/stats/servers/ConsensusStatsFileHandler.java
+++ b/src/main/java/org/torproject/metrics/stats/servers/ConsensusStatsFileHandler.java
@@ -257,13 +257,9 @@ public class ConsensusStatsFileHandler {
continue;
}
String date = bridgesRawLine.substring(0, 10);
- if (!bridgesPerDayAndAuthority.containsKey(date)) {
- bridgesPerDayAndAuthority.put(date, new TreeMap<>());
- }
+ bridgesPerDayAndAuthority.putIfAbsent(date, new TreeMap<>());
String authority = parts[1];
- if (!bridgesPerDayAndAuthority.get(date).containsKey(authority)) {
- bridgesPerDayAndAuthority.get(date).put(authority, new int[3]);
- }
+ bridgesPerDayAndAuthority.get(date).putIfAbsent(authority, new int[3]);
int[] bridges = bridgesPerDayAndAuthority.get(date).get(authority);
bridges[0] += brunning;
bridges[1] += Integer.parseInt(parts[3]);
diff --git a/src/main/java/org/torproject/metrics/web/MetricServlet.java b/src/main/java/org/torproject/metrics/web/MetricServlet.java
index 3b279a9..353af63 100644
--- a/src/main/java/org/torproject/metrics/web/MetricServlet.java
+++ b/src/main/java/org/torproject/metrics/web/MetricServlet.java
@@ -44,9 +44,7 @@ public abstract class MetricServlet extends AnyServlet {
String id = metric.getId();
String title = metric.getTitle();
String type = metric.getType();
- if (!this.idsByType.containsKey(type)) {
- this.idsByType.put(type, new HashSet<>());
- }
+ this.idsByType.putIfAbsent(type, new HashSet<>());
this.idsByType.get(type).add(id);
this.titles.put(id, title);
this.descriptions.put(id, metric.getDescription());
1
0
27 Aug '18
commit 79994eb3e1a4e89f6904a33a1591b375ab8f104e
Author: Karsten Loesing <karsten.loesing(a)gmx.net>
Date: Tue Aug 21 11:47:07 2018 +0200
Remove unnecessary return statements.
---
.../java/org/torproject/metrics/stats/hidserv/Parser.java | 15 ++++-----------
.../java/org/torproject/metrics/web/RObjectGenerator.java | 2 +-
2 files changed, 5 insertions(+), 12 deletions(-)
diff --git a/src/main/java/org/torproject/metrics/stats/hidserv/Parser.java b/src/main/java/org/torproject/metrics/stats/hidserv/Parser.java
index 4f7ac6c..5970e32 100644
--- a/src/main/java/org/torproject/metrics/stats/hidserv/Parser.java
+++ b/src/main/java/org/torproject/metrics/stats/hidserv/Parser.java
@@ -199,19 +199,10 @@ public class Parser {
/* Extract the fingerprint from the parsed descriptor. */
String fingerprint = extraInfoDescriptor.getFingerprint();
- /* If the descriptor did not contain any of the expected hidserv-*
- * lines, don't do anything. This applies to the majority of
- * descriptors, at least as long as only a minority of relays reports
- * these statistics. */
- if (extraInfoDescriptor.getHidservStatsEndMillis() < 0L
- && extraInfoDescriptor.getHidservRendRelayedCells() == null
- && extraInfoDescriptor.getHidservDirOnionsSeen() == null) {
- return;
-
/* If the descriptor contained all expected hidserv-* lines, create a
* new stats object and put it in the local map, so that it will later
* be written to a document file. */
- } else if (extraInfoDescriptor.getHidservStatsEndMillis() >= 0L
+ if (extraInfoDescriptor.getHidservStatsEndMillis() >= 0L
&& extraInfoDescriptor.getHidservStatsIntervalLength() >= 0L
&& extraInfoDescriptor.getHidservRendRelayedCells() != null
&& extraInfoDescriptor.getHidservRendRelayedCellsParameters() != null
@@ -237,7 +228,9 @@ public class Parser {
* out a warning. This case does not warrant any further action,
* because relays can in theory write anything in their extra-info
* descriptors. But maybe we'll want to know. */
- } else {
+ } else if (extraInfoDescriptor.getHidservStatsEndMillis() >= 0L
+ || extraInfoDescriptor.getHidservRendRelayedCells() != null
+ || extraInfoDescriptor.getHidservDirOnionsSeen() != null) {
log.warn("Relay {} published incomplete hidserv-stats. Ignoring.",
fingerprint);
}
diff --git a/src/main/java/org/torproject/metrics/web/RObjectGenerator.java b/src/main/java/org/torproject/metrics/web/RObjectGenerator.java
index 8490eef..a529830 100644
--- a/src/main/java/org/torproject/metrics/web/RObjectGenerator.java
+++ b/src/main/java/org/torproject/metrics/web/RObjectGenerator.java
@@ -345,7 +345,7 @@ public class RObjectGenerator implements ServletContextListener {
this.result = new RObject(baos.toByteArray(), this.fileName,
lastModified);
} catch (IOException e) {
- return;
+ /* Nothing to do here. */
}
}
1
0
27 Aug '18
commit 406d0e93210d1839390d58205b05fb5748531b2a
Author: Karsten Loesing <karsten.loesing(a)gmx.net>
Date: Tue Aug 21 20:47:33 2018 +0200
Replace Java logging with slf4j.
Fixes the last part of #26190.
---
.../metrics/stats/servers/Configuration.java | 37 ++++----
.../stats/servers/ConsensusStatsFileHandler.java | 81 ++++++++----------
.../torproject/metrics/stats/servers/LockFile.java | 18 ++--
.../stats/servers/LoggingConfiguration.java | 98 ----------------------
.../org/torproject/metrics/stats/servers/Main.java | 16 ++--
.../servers/RelayDescriptorDatabaseImporter.java | 86 ++++++++-----------
6 files changed, 108 insertions(+), 228 deletions(-)
diff --git a/src/main/java/org/torproject/metrics/stats/servers/Configuration.java b/src/main/java/org/torproject/metrics/stats/servers/Configuration.java
index 5be8d88..8435b90 100644
--- a/src/main/java/org/torproject/metrics/stats/servers/Configuration.java
+++ b/src/main/java/org/torproject/metrics/stats/servers/Configuration.java
@@ -3,6 +3,9 @@
package org.torproject.metrics.stats.servers;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
@@ -11,8 +14,6 @@ import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
/**
* Initialize configuration with hard-coded defaults, overwrite with
@@ -21,6 +22,8 @@ import java.util.logging.Logger;
*/
public class Configuration {
+ private static Logger log = LoggerFactory.getLogger(Configuration.class);
+
private boolean importDirectoryArchives = false;
private List<File> directoryArchivesDirectories = new ArrayList<>();
@@ -47,21 +50,16 @@ public class Configuration {
/** Initializes this configuration class. */
public Configuration() {
- /* Initialize logger. */
- Logger logger = Logger.getLogger(Configuration.class.getName());
-
/* Read config file, if present. */
File configFile = new File("config");
if (!configFile.exists()) {
- logger.warning("Could not find config file.");
+ log.warn("Could not find config file.");
return;
}
String line = null;
try (BufferedReader br = new BufferedReader(new FileReader(configFile))) {
while ((line = br.readLine()) != null) {
- if (line.startsWith("#") || line.length() < 1) {
- continue;
- } else if (line.startsWith("ImportDirectoryArchives")) {
+ if (line.startsWith("ImportDirectoryArchives")) {
this.importDirectoryArchives = Integer.parseInt(
line.split(" ")[1]) != 0;
} else if (line.startsWith("DirectoryArchivesDirectory")) {
@@ -90,27 +88,26 @@ public class Configuration {
} else if (line.startsWith("WriteBridgeStats")) {
this.writeBridgeStats = Integer.parseInt(
line.split(" ")[1]) != 0;
- } else {
- logger.severe("Configuration file contains unrecognized "
- + "configuration key in line '" + line + "'! Exiting!");
+ } else if (!line.startsWith("#") && line.length() > 0) {
+ log.error("Configuration file contains unrecognized "
+ + "configuration key in line '{}'! Exiting!", line);
System.exit(1);
}
}
} catch (ArrayIndexOutOfBoundsException e) {
- logger.severe("Configuration file contains configuration key "
- + "without value in line '" + line + "'. Exiting!");
+ log.warn("Configuration file contains configuration key without value in "
+ + "line '{}'. Exiting!", line);
System.exit(1);
} catch (MalformedURLException e) {
- logger.severe("Configuration file contains illegal URL or IP:port "
- + "pair in line '" + line + "'. Exiting!");
+ log.warn("Configuration file contains illegal URL or IP:port pair in "
+ + "line '{}'. Exiting!", line);
System.exit(1);
} catch (NumberFormatException e) {
- logger.severe("Configuration file contains illegal value in line '"
- + line + "' with legal values being 0 or 1. Exiting!");
+ log.warn("Configuration file contains illegal value in line '{}' with "
+ + "legal values being 0 or 1. Exiting!", line);
System.exit(1);
} catch (IOException e) {
- logger.log(Level.SEVERE, "Unknown problem while reading config "
- + "file! Exiting!", e);
+ log.error("Unknown problem while reading config file! Exiting!", e);
System.exit(1);
}
}
diff --git a/src/main/java/org/torproject/metrics/stats/servers/ConsensusStatsFileHandler.java b/src/main/java/org/torproject/metrics/stats/servers/ConsensusStatsFileHandler.java
index 491170e..960069c 100644
--- a/src/main/java/org/torproject/metrics/stats/servers/ConsensusStatsFileHandler.java
+++ b/src/main/java/org/torproject/metrics/stats/servers/ConsensusStatsFileHandler.java
@@ -9,6 +9,9 @@ import org.torproject.descriptor.DescriptorReader;
import org.torproject.descriptor.DescriptorSourceFactory;
import org.torproject.descriptor.NetworkStatusEntry;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
@@ -28,8 +31,6 @@ import java.util.Map;
import java.util.SortedMap;
import java.util.TimeZone;
import java.util.TreeMap;
-import java.util.logging.Level;
-import java.util.logging.Logger;
/**
* Generates statistics on the average number of relays and bridges per
@@ -63,10 +64,8 @@ public class ConsensusStatsFileHandler {
*/
private SortedMap<String, String> bridgesPerDay;
- /**
- * Logger for this class.
- */
- private Logger logger;
+ private static Logger log = LoggerFactory.getLogger(
+ ConsensusStatsFileHandler.class);
private int bridgeResultsAdded = 0;
@@ -113,14 +112,10 @@ public class ConsensusStatsFileHandler {
this.dateTimeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
this.dateTimeFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
- /* Initialize logger. */
- this.logger = Logger.getLogger(
- ConsensusStatsFileHandler.class.getName());
-
/* Read in number of running bridges per bridge status. */
if (this.bridgeConsensusStatsRawFile.exists()) {
- this.logger.fine("Reading file "
- + this.bridgeConsensusStatsRawFile.getAbsolutePath() + "...");
+ log.debug("Reading file {}...",
+ this.bridgeConsensusStatsRawFile.getAbsolutePath());
try (BufferedReader br = new BufferedReader(new FileReader(
this.bridgeConsensusStatsRawFile))) {
String line;
@@ -131,9 +126,9 @@ public class ConsensusStatsFileHandler {
}
String[] parts = line.split(",");
if (parts.length < 2 || parts.length > 4) {
- this.logger.warning("Corrupt line '" + line + "' in file "
- + this.bridgeConsensusStatsRawFile.getAbsolutePath()
- + "! Aborting to read this file!");
+ log.warn("Corrupt line '{}' in file {}! Aborting to read this "
+ + "file!", line,
+ this.bridgeConsensusStatsRawFile.getAbsolutePath());
break;
}
/* Assume that all lines without authority nickname are based on
@@ -149,12 +144,11 @@ public class ConsensusStatsFileHandler {
} /* No more cases as we already checked the range above. */
this.bridgesRaw.put(key, value);
}
- this.logger.fine("Finished reading file "
- + this.bridgeConsensusStatsRawFile.getAbsolutePath() + ".");
+ log.debug("Finished reading file {}.",
+ this.bridgeConsensusStatsRawFile.getAbsolutePath());
} catch (IOException e) {
- this.logger.log(Level.WARNING, "Failed to read file "
- + this.bridgeConsensusStatsRawFile.getAbsolutePath() + "!",
- e);
+ log.warn("Failed to read file {}!",
+ this.bridgeConsensusStatsRawFile.getAbsolutePath(), e);
}
}
}
@@ -169,14 +163,13 @@ public class ConsensusStatsFileHandler {
+ authorityNickname;
String line = publishedAuthority + "," + running + "," + runningEc2Bridges;
if (!this.bridgesRaw.containsKey(publishedAuthority)) {
- this.logger.finer("Adding new bridge numbers: " + line);
+ log.debug("Adding new bridge numbers: {}", line);
this.bridgesRaw.put(publishedAuthority, line);
this.bridgeResultsAdded++;
} else if (!line.equals(this.bridgesRaw.get(publishedAuthority))) {
- this.logger.warning("The numbers of running bridges we were just "
- + "given (" + line + ") are different from what we learned "
- + "before (" + this.bridgesRaw.get(publishedAuthority) + ")! "
- + "Overwriting!");
+ log.warn("The numbers of running bridges we were just given ({}) are "
+ + "different from what we learned before ({})! Overwriting!", line,
+ this.bridgesRaw.get(publishedAuthority));
this.bridgesRaw.put(publishedAuthority, line);
}
}
@@ -184,7 +177,7 @@ public class ConsensusStatsFileHandler {
/** Imports sanitized bridge descriptors. */
public void importSanitizedBridges() {
if (bridgesDir.exists()) {
- logger.fine("Importing files in directory " + bridgesDir + "/...");
+ log.debug("Importing files in directory {}/...", bridgesDir);
DescriptorReader reader =
DescriptorSourceFactory.createDescriptorReader();
File historyFile = new File(statsDirectory,
@@ -207,8 +200,8 @@ public class ConsensusStatsFileHandler {
authority = "Serge";
}
if (authority == null) {
- this.logger.warning("Did not recognize the bridge authority "
- + "that generated " + descriptorFileName + ". Skipping.");
+ log.warn("Did not recognize the bridge authority that generated "
+ + "{}. Skipping.", descriptorFileName);
continue;
}
this.addBridgeNetworkStatus(
@@ -218,7 +211,7 @@ public class ConsensusStatsFileHandler {
if (keepImportHistory) {
reader.saveHistoryFile(historyFile);
}
- logger.info("Finished importing bridge descriptors.");
+ log.info("Finished importing bridge descriptors.");
}
}
@@ -285,18 +278,18 @@ public class ConsensusStatsFileHandler {
String line = "," + brunning + "," + brunningEc2;
/* Are our results new? */
if (!this.bridgesPerDay.containsKey(date)) {
- this.logger.finer("Adding new average bridge numbers: " + date + line);
+ log.debug("Adding new average bridge numbers: {}{}", date, line);
this.bridgesPerDay.put(date, line);
} else if (!line.equals(this.bridgesPerDay.get(date))) {
- this.logger.finer("Replacing existing average bridge numbers ("
- + this.bridgesPerDay.get(date) + " with new numbers: " + line);
+ log.debug("Replacing existing average bridge numbers ({} with new "
+ + "numbers: {}", this.bridgesPerDay.get(date), line);
this.bridgesPerDay.put(date, line);
}
}
/* Write raw numbers of running bridges to disk. */
- this.logger.fine("Writing file "
- + this.bridgeConsensusStatsRawFile.getAbsolutePath() + "...");
+ log.debug("Writing file {}...",
+ this.bridgeConsensusStatsRawFile.getAbsolutePath());
this.bridgeConsensusStatsRawFile.getParentFile().mkdirs();
try (BufferedWriter bw = new BufferedWriter(
new FileWriter(this.bridgeConsensusStatsRawFile))) {
@@ -306,12 +299,11 @@ public class ConsensusStatsFileHandler {
bw.append(line);
bw.newLine();
}
- this.logger.fine("Finished writing file "
- + this.bridgeConsensusStatsRawFile.getAbsolutePath() + ".");
+ log.debug("Finished writing file {}.",
+ this.bridgeConsensusStatsRawFile.getAbsolutePath());
} catch (IOException e) {
- this.logger.log(Level.WARNING, "Failed to write file "
- + this.bridgeConsensusStatsRawFile.getAbsolutePath() + "!",
- e);
+ log.warn("Failed to write file {}!",
+ this.bridgeConsensusStatsRawFile.getAbsolutePath(), e);
}
/* Add average number of bridges per day to the database. */
@@ -372,8 +364,7 @@ public class ConsensusStatsFileHandler {
conn.commit();
conn.close();
} catch (SQLException e) {
- logger.log(Level.WARNING, "Failed to add average bridge numbers "
- + "to database.", e);
+ log.warn("Failed to add average bridge numbers to database.", e);
}
}
@@ -394,14 +385,14 @@ public class ConsensusStatsFileHandler {
try {
if (now - 6L * 60L * 60L * 1000L > dateTimeFormat.parse(
this.bridgesRaw.lastKey()).getTime()) {
- logger.warning("Last known bridge status is more than 6 hours "
- + "old: " + this.bridgesRaw.lastKey());
+ log.warn("Last known bridge status is more than 6 hours old: {}",
+ this.bridgesRaw.lastKey());
}
} catch (ParseException e) {
- logger.warning("Can't parse the timestamp? Reason: " + e);
+ log.warn("Can't parse the timestamp? Reason: {}", e);
}
}
- logger.info(dumpStats.toString());
+ log.info(dumpStats.toString());
}
}
diff --git a/src/main/java/org/torproject/metrics/stats/servers/LockFile.java b/src/main/java/org/torproject/metrics/stats/servers/LockFile.java
index c6c63bb..c6063d1 100644
--- a/src/main/java/org/torproject/metrics/stats/servers/LockFile.java
+++ b/src/main/java/org/torproject/metrics/stats/servers/LockFile.java
@@ -3,29 +3,31 @@
package org.torproject.metrics.stats.servers;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
-import java.util.logging.Logger;
public class LockFile {
private File lockFile;
- private Logger logger;
+
+ private static Logger log = LoggerFactory.getLogger(LockFile.class);
public LockFile() {
this.lockFile = new File("lock");
- this.logger = Logger.getLogger(LockFile.class.getName());
}
/** Acquires the lock by checking whether a lock file already exists,
* and if not, by creating one with the current system time as
* content. */
public boolean acquireLock() {
- this.logger.fine("Trying to acquire lock...");
+ log.debug("Trying to acquire lock...");
try {
if (this.lockFile.exists()) {
BufferedReader br = new BufferedReader(new FileReader("lock"));
@@ -40,10 +42,10 @@ public class LockFile {
bw.append("").append(String.valueOf(System.currentTimeMillis()))
.append("\n");
bw.close();
- this.logger.fine("Acquired lock.");
+ log.debug("Acquired lock.");
return true;
} catch (IOException e) {
- this.logger.warning("Caught exception while trying to acquire "
+ log.warn("Caught exception while trying to acquire "
+ "lock!");
return false;
}
@@ -51,9 +53,9 @@ public class LockFile {
/** Releases the lock by deleting the lock file, if present. */
public void releaseLock() {
- this.logger.fine("Releasing lock...");
+ log.debug("Releasing lock...");
this.lockFile.delete();
- this.logger.fine("Released lock.");
+ log.debug("Released lock.");
}
}
diff --git a/src/main/java/org/torproject/metrics/stats/servers/LoggingConfiguration.java b/src/main/java/org/torproject/metrics/stats/servers/LoggingConfiguration.java
deleted file mode 100644
index a11c6c4..0000000
--- a/src/main/java/org/torproject/metrics/stats/servers/LoggingConfiguration.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/* Copyright 2011--2018 The Tor Project
- * See LICENSE for licensing information */
-
-package org.torproject.metrics.stats.servers;
-
-import java.io.IOException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.TimeZone;
-import java.util.logging.ConsoleHandler;
-import java.util.logging.FileHandler;
-import java.util.logging.Formatter;
-import java.util.logging.Handler;
-import java.util.logging.Level;
-import java.util.logging.LogRecord;
-import java.util.logging.Logger;
-
-/**
- * Initialize logging configuration.
- *
- * <p>Log levels used by ERNIE:</p>
- *
- * <ul>
- * <li>SEVERE: An event made it impossible to continue program execution.
- * WARNING: A potential problem occurred that requires the operator to
- * look after the otherwise unattended setup</li>
- * <li>INFO: Messages on INFO level are meant to help the operator in
- * making sure that operation works as expected.</li>
- * <li>FINE: Debug messages that are used to identify problems and which
- * are turned on by default.</li>
- * <li>FINER: More detailed debug messages to investigate problems in more
- * detail. Not turned on by default. Increase log file limit when
- * using FINER.</li>
- * <li>FINEST: Most detailed debug messages. Not used.</li>
- * </ul>
- */
-public class LoggingConfiguration {
-
- /** Initializes the logging configuration. */
- public LoggingConfiguration() {
-
- /* Remove default console handler. */
- for (Handler h : Logger.getLogger("").getHandlers()) {
- Logger.getLogger("").removeHandler(h);
- }
-
- /* Disable logging of internal Sun classes. */
- Logger.getLogger("sun").setLevel(Level.OFF);
-
- /* Set minimum log level we care about from INFO to FINER. */
- Logger.getLogger("").setLevel(Level.FINER);
-
- /* Create log handler that writes messages on WARNING or higher to the
- * console. */
- final SimpleDateFormat dateTimeFormat =
- new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- dateTimeFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
- Formatter cf = new Formatter() {
- public String format(LogRecord record) {
- return dateTimeFormat.format(new Date(record.getMillis())) + " "
- + record.getMessage() + "\n";
- }
- };
- Handler ch = new ConsoleHandler();
- ch.setFormatter(cf);
- ch.setLevel(Level.WARNING);
- Logger.getLogger("").addHandler(ch);
-
- /* Initialize own logger for this class. */
- Logger logger = Logger.getLogger(
- LoggingConfiguration.class.getName());
-
- /* Create log handler that writes all messages on FINE or higher to a
- * local file. */
- Formatter ff = new Formatter() {
- public String format(LogRecord record) {
- return dateTimeFormat.format(new Date(record.getMillis())) + " "
- + record.getLevel() + " " + record.getSourceClassName() + " "
- + record.getSourceMethodName() + " " + record.getMessage()
- + (record.getThrown() != null ? " " + record.getThrown() : "")
- + "\n";
- }
- };
- try {
- FileHandler fh = new FileHandler("log", 5000000, 5, true);
- fh.setFormatter(ff);
- fh.setLevel(Level.FINE);
- Logger.getLogger("").addHandler(fh);
- } catch (SecurityException e) {
- logger.log(Level.WARNING, "No permission to create log file. "
- + "Logging to file is disabled.", e);
- } catch (IOException e) {
- logger.log(Level.WARNING, "Could not write to log file. Logging to "
- + "file is disabled.", e);
- }
- }
-}
-
diff --git a/src/main/java/org/torproject/metrics/stats/servers/Main.java b/src/main/java/org/torproject/metrics/stats/servers/Main.java
index 5db867d..080b6e4 100644
--- a/src/main/java/org/torproject/metrics/stats/servers/Main.java
+++ b/src/main/java/org/torproject/metrics/stats/servers/Main.java
@@ -3,8 +3,10 @@
package org.torproject.metrics.stats.servers;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import java.io.File;
-import java.util.logging.Logger;
/**
* Coordinate downloading and parsing of descriptors and extraction of
@@ -12,14 +14,12 @@ import java.util.logging.Logger;
*/
public class Main {
+ private static Logger log = LoggerFactory.getLogger(Main.class);
+
/** Executes this data-processing module. */
public static void main(String[] args) {
- /* Initialize logging configuration. */
- new LoggingConfiguration();
-
- Logger logger = Logger.getLogger(Main.class.getName());
- logger.info("Starting ERNIE.");
+ log.info("Starting ERNIE.");
// Initialize configuration
Configuration config = new Configuration();
@@ -27,7 +27,7 @@ public class Main {
// Use lock file to avoid overlapping runs
LockFile lf = new LockFile();
if (!lf.acquireLock()) {
- logger.severe("Warning: ERNIE is already running or has not exited "
+ log.error("Warning: ERNIE is already running or has not exited "
+ "cleanly! Exiting!");
System.exit(1);
}
@@ -74,7 +74,7 @@ public class Main {
// Remove lock file
lf.releaseLock();
- logger.info("Terminating ERNIE.");
+ log.info("Terminating ERNIE.");
}
}
diff --git a/src/main/java/org/torproject/metrics/stats/servers/RelayDescriptorDatabaseImporter.java b/src/main/java/org/torproject/metrics/stats/servers/RelayDescriptorDatabaseImporter.java
index 750e231..c9a6fa7 100644
--- a/src/main/java/org/torproject/metrics/stats/servers/RelayDescriptorDatabaseImporter.java
+++ b/src/main/java/org/torproject/metrics/stats/servers/RelayDescriptorDatabaseImporter.java
@@ -13,6 +13,9 @@ import org.torproject.descriptor.ServerDescriptor;
import org.postgresql.util.PGbytea;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
@@ -37,8 +40,6 @@ import java.util.Set;
import java.util.SortedSet;
import java.util.TimeZone;
import java.util.TreeSet;
-import java.util.logging.Level;
-import java.util.logging.Logger;
/**
* Parse directory data.
@@ -130,10 +131,8 @@ public final class RelayDescriptorDatabaseImporter {
*/
private PreparedStatement psC;
- /**
- * Logger for this class.
- */
- private Logger logger;
+ private static Logger log
+ = LoggerFactory.getLogger(RelayDescriptorDatabaseImporter.class);
/**
* Directory for writing raw import files.
@@ -202,10 +201,6 @@ public final class RelayDescriptorDatabaseImporter {
this.statsDirectory = statsDirectory;
this.keepImportHistory = keepImportHistory;
- /* Initialize logger. */
- this.logger = Logger.getLogger(
- RelayDescriptorDatabaseImporter.class.getName());
-
if (connectionUrl != null) {
try {
/* Connect to database. */
@@ -244,8 +239,7 @@ public final class RelayDescriptorDatabaseImporter {
this.scheduledUpdates = new HashSet<>();
this.importIntoDatabase = true;
} catch (SQLException e) {
- this.logger.log(Level.WARNING, "Could not connect to database or "
- + "prepare statements.", e);
+ log.warn("Could not connect to database or prepare statements.", e);
}
}
@@ -271,7 +265,7 @@ public final class RelayDescriptorDatabaseImporter {
this.dateTimeFormat.format(timestamp).substring(0, 10)
+ " 00:00:00").getTime();
} catch (ParseException e) {
- this.logger.log(Level.WARNING, "Internal parsing error.", e);
+ log.warn("Internal parsing error.", e);
return;
}
if (!this.scheduledUpdates.contains(dateMillis)) {
@@ -341,9 +335,8 @@ public final class RelayDescriptorDatabaseImporter {
insertedStatusEntries.add(fingerprint);
}
} catch (SQLException e) {
- this.logger.log(Level.WARNING, "Could not add network status "
- + "consensus entry. We won't make any further SQL requests "
- + "in this execution.", e);
+ log.warn("Could not add network status consensus entry. We won't make "
+ + "any further SQL requests in this execution.", e);
this.importIntoDatabase = false;
}
}
@@ -387,7 +380,7 @@ public final class RelayDescriptorDatabaseImporter {
this.statusentryOut.write(PGbytea.toPGString(rawDescriptor)
.replaceAll("\\\\", "\\\\\\\\") + "\n");
} catch (IOException e) {
- this.logger.log(Level.WARNING, "Could not write network status "
+ log.warn("Could not write network status "
+ "consensus entry to raw database import file. We won't "
+ "make any further attempts to write raw import files in "
+ "this execution.", e);
@@ -444,7 +437,7 @@ public final class RelayDescriptorDatabaseImporter {
}
}
} catch (SQLException e) {
- this.logger.log(Level.WARNING, "Could not add server "
+ log.warn("Could not add server "
+ "descriptor. We won't make any further SQL requests in "
+ "this execution.", e);
this.importIntoDatabase = false;
@@ -472,7 +465,7 @@ public final class RelayDescriptorDatabaseImporter {
+ (extraInfoDigest != null ? extraInfoDigest : "\\N")
+ "\n");
} catch (IOException e) {
- this.logger.log(Level.WARNING, "Could not write server "
+ log.warn("Could not write server "
+ "descriptor to raw database import file. We won't make "
+ "any further attempts to write raw import files in this "
+ "execution.", e);
@@ -573,7 +566,7 @@ public final class RelayDescriptorDatabaseImporter {
for (String bandwidthHistoryString : bandwidthHistoryStrings) {
String[] parts = bandwidthHistoryString.split(" ");
if (parts.length != 6) {
- this.logger.finer("Bandwidth history line does not have expected "
+ log.debug("Bandwidth history line does not have expected "
+ "number of elements. Ignoring this line.");
continue;
}
@@ -581,14 +574,13 @@ public final class RelayDescriptorDatabaseImporter {
try {
intervalLength = Long.parseLong(parts[3].substring(1));
} catch (NumberFormatException e) {
- this.logger.fine("Bandwidth history line does not have valid "
- + "interval length '" + parts[3] + " " + parts[4] + "'. "
- + "Ignoring this line.");
+ log.debug("Bandwidth history line does not have valid interval length "
+ + "'{} {}'. Ignoring this line.", parts[3], parts[4]);
continue;
}
String[] values = parts[5].split(",");
if (intervalLength % 900L != 0L) {
- this.logger.fine("Bandwidth history line does not contain "
+ log.debug("Bandwidth history line does not contain "
+ "multiples of 15-minute intervals. Ignoring this line.");
continue;
} else if (intervalLength != 900L) {
@@ -606,7 +598,7 @@ public final class RelayDescriptorDatabaseImporter {
values = newValues;
intervalLength = 900L;
} catch (NumberFormatException e) {
- this.logger.fine("Number format exception while parsing "
+ log.debug("Number format exception while parsing "
+ "bandwidth history line. Ignoring this line.");
continue;
}
@@ -620,16 +612,15 @@ public final class RelayDescriptorDatabaseImporter {
dateStart = dateTimeFormat.parse(parts[1] + " 00:00:00")
.getTime();
} catch (ParseException e) {
- this.logger.fine("Parse exception while parsing timestamp in "
+ log.debug("Parse exception while parsing timestamp in "
+ "bandwidth history line. Ignoring this line.");
continue;
}
if (Math.abs(published - intervalEnd)
> 7L * 24L * 60L * 60L * 1000L) {
- this.logger.fine("Extra-info descriptor publication time "
- + dateTimeFormat.format(published) + " and last interval "
- + "time " + intervalEndTime + " in " + type + " line differ "
- + "by more than 7 days! Not adding this line!");
+ log.debug("Extra-info descriptor publication time {} and last interval "
+ + "time {} in {} line differ by more than 7 days! Not adding this "
+ + "line!", dateTimeFormat.format(published), intervalEndTime, type);
continue;
}
long currentIntervalEnd = intervalEnd;
@@ -655,7 +646,7 @@ public final class RelayDescriptorDatabaseImporter {
currentIntervalEnd -= intervalLength * 1000L;
}
} catch (NumberFormatException e) {
- this.logger.fine("Number format exception while parsing "
+ log.debug("Number format exception while parsing "
+ "bandwidth history line. Ignoring this line.");
continue;
}
@@ -703,7 +694,7 @@ public final class RelayDescriptorDatabaseImporter {
this.csH.executeBatch();
}
} catch (SQLException | ParseException e) {
- this.logger.log(Level.WARNING, "Could not insert bandwidth "
+ log.warn("Could not insert bandwidth "
+ "history line into database. We won't make any "
+ "further SQL requests in this execution.", e);
this.importIntoDatabase = false;
@@ -722,7 +713,7 @@ public final class RelayDescriptorDatabaseImporter {
+ dirreadIntArray.toString() + "','"
+ dirwrittenIntArray.toString() + "');\n");
} catch (IOException e) {
- this.logger.log(Level.WARNING, "Could not write bandwidth "
+ log.warn("Could not write bandwidth "
+ "history to raw database import file. We won't make "
+ "any further attempts to write raw import files in "
+ "this execution.", e);
@@ -797,7 +788,7 @@ public final class RelayDescriptorDatabaseImporter {
}
}
} catch (SQLException e) {
- this.logger.log(Level.WARNING, "Could not add network status "
+ log.warn("Could not add network status "
+ "consensus. We won't make any further SQL requests in "
+ "this execution.", e);
this.importIntoDatabase = false;
@@ -815,7 +806,7 @@ public final class RelayDescriptorDatabaseImporter {
String validAfterString = this.dateTimeFormat.format(validAfter);
this.consensusOut.write(validAfterString + "\n");
} catch (IOException e) {
- this.logger.log(Level.WARNING, "Could not write network status "
+ log.warn("Could not write network status "
+ "consensus to raw database import file. We won't make "
+ "any further attempts to write raw import files in this "
+ "execution.", e);
@@ -826,7 +817,7 @@ public final class RelayDescriptorDatabaseImporter {
/** Imports relay descriptors into the database. */
public void importRelayDescriptors() {
- logger.fine("Importing files in directories " + archivesDirectories
+ log.info("Importing files in directories " + archivesDirectories
+ "/...");
if (!this.archivesDirectories.isEmpty()) {
DescriptorReader reader =
@@ -854,7 +845,7 @@ public final class RelayDescriptorDatabaseImporter {
}
}
- logger.info("Finished importing relay descriptors.");
+ log.info("Finished importing relay descriptors.");
}
private void addRelayNetworkStatusConsensus(
@@ -913,12 +904,12 @@ public final class RelayDescriptorDatabaseImporter {
public void closeConnection() {
/* Log stats about imported descriptors. */
- this.logger.info(String.format("Finished importing relay "
- + "descriptors: %d consensuses, %d network status entries, %d "
- + "votes, %d server descriptors, %d extra-info descriptors, %d "
- + "bandwidth history elements, and %d dirreq stats elements",
+ log.info("Finished importing relay "
+ + "descriptors: {} consensuses, {} network status entries, {} "
+ + "votes, {} server descriptors, {} extra-info descriptors, {} "
+ + "bandwidth history elements, and {} dirreq stats elements",
rcsCount, rrsCount, rvsCount, rdsCount, resCount, rhsCount,
- rqsCount));
+ rqsCount);
/* Insert scheduled updates a second time, just in case the refresh
* run has started since inserting them the first time in which case
@@ -933,7 +924,7 @@ public final class RelayDescriptorDatabaseImporter {
this.psU.execute();
}
} catch (SQLException e) {
- this.logger.log(Level.WARNING, "Could not add scheduled dates "
+ log.warn("Could not add scheduled dates "
+ "for the next refresh run.", e);
}
}
@@ -945,14 +936,12 @@ public final class RelayDescriptorDatabaseImporter {
this.conn.commit();
} catch (SQLException e) {
- this.logger.log(Level.WARNING, "Could not commit final records "
- + "to database", e);
+ log.warn("Could not commit final records to database", e);
}
try {
this.conn.close();
} catch (SQLException e) {
- this.logger.log(Level.WARNING, "Could not close database "
- + "connection.", e);
+ log.warn("Could not close database connection.", e);
}
}
@@ -975,8 +964,7 @@ public final class RelayDescriptorDatabaseImporter {
this.consensusOut.close();
}
} catch (IOException e) {
- this.logger.log(Level.WARNING, "Could not close one or more raw "
- + "database import files.", e);
+ log.warn("Could not close one or more raw database import files.", e);
}
}
}
1
0
[metrics-web/master] Use empty parameterized Map when generating tables.
by karsten@torproject.org 27 Aug '18
by karsten@torproject.org 27 Aug '18
27 Aug '18
commit 175d4c8aeb49db5907fa6591a9513c22dd1486e0
Author: Karsten Loesing <karsten.loesing(a)gmx.net>
Date: Tue Aug 21 09:46:30 2018 +0200
Use empty parameterized Map when generating tables.
---
src/main/java/org/torproject/metrics/web/RObjectGenerator.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/main/java/org/torproject/metrics/web/RObjectGenerator.java b/src/main/java/org/torproject/metrics/web/RObjectGenerator.java
index 196e834..8490eef 100644
--- a/src/main/java/org/torproject/metrics/web/RObjectGenerator.java
+++ b/src/main/java/org/torproject/metrics/web/RObjectGenerator.java
@@ -89,7 +89,7 @@ public class RObjectGenerator implements ServletContextListener {
}
}
for (String tableId : availableTables.keySet()) {
- generateTable(tableId, new HashMap(), false);
+ generateTable(tableId, new HashMap<>(), false);
}
for (String graphId : availableGraphs.keySet()) {
generateGraph(graphId, "png", new HashMap<>(), false);
1
0