[tor-commits] [metrics-db/master] Actually parse assignments*.gz, too.
karsten at torproject.org
karsten at torproject.org
Sat May 5 17:53:10 UTC 2012
commit 7406f4df4f836b96e329bee69171a6ca196ad51b
Author: Karsten Loesing <karsten.loesing at gmx.net>
Date: Sat May 5 19:49:04 2012 +0200
Actually parse assignments*.gz, too.
---
.../ernie/db/BridgePoolAssignmentsProcessor.java | 19 +++++++++++++++----
1 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/src/org/torproject/ernie/db/BridgePoolAssignmentsProcessor.java b/src/org/torproject/ernie/db/BridgePoolAssignmentsProcessor.java
index 1eef418..f43723f 100644
--- a/src/org/torproject/ernie/db/BridgePoolAssignmentsProcessor.java
+++ b/src/org/torproject/ernie/db/BridgePoolAssignmentsProcessor.java
@@ -9,6 +9,7 @@ import java.util.logging.*;
import org.apache.commons.codec.*;
import org.apache.commons.codec.binary.*;
import org.apache.commons.codec.digest.*;
+import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream;
public class BridgePoolAssignmentsProcessor {
@@ -32,7 +33,7 @@ public class BridgePoolAssignmentsProcessor {
File file = files.pop();
if (file.isDirectory()) {
files.addAll(Arrays.asList(file.listFiles()));
- } else if (!file.getName().endsWith(".gz")) {
+ } else {
assignmentFiles.add(file);
}
}
@@ -45,8 +46,14 @@ public class BridgePoolAssignmentsProcessor {
filenameFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
for (File assignmentFile : assignmentFiles) {
try {
- BufferedReader br = new BufferedReader(new FileReader(
- assignmentFile));
+ BufferedReader br = null;
+ if (assignmentFile.getName().endsWith(".gz")) {
+ br = new BufferedReader(new InputStreamReader(
+ new GzipCompressorInputStream(new FileInputStream(
+ assignmentFile))));
+ } else {
+ br = new BufferedReader(new FileReader(assignmentFile));
+ }
String line, bridgePoolAssignmentLine = null;
SortedSet<String> sanitizedAssignments = new TreeSet<String>();
boolean wroteLastLine = false, skipBefore20120504125947 = true;
@@ -65,7 +72,11 @@ public class BridgePoolAssignmentsProcessor {
}
}
if (skipBefore20120504125947) {
- continue;
+ if (line == null) {
+ break;
+ } else {
+ continue;
+ }
}
if (line == null ||
line.startsWith("bridge-pool-assignment ")) {
More information about the tor-commits
mailing list