[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] [ernie/master] Fix more of the log output.
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date: Wed, 14 Apr 2010 13:47:23 +0200
Subject: Fix more of the log output.
Commit: 74a6852cf1ef7e718ed5e4afc91fc2db25518703
---
src/ArchiveWriter.java | 40 ++++++++++-------------------------
src/RelayDescriptorDownloader.java | 24 ++++++++++++++++-----
2 files changed, 30 insertions(+), 34 deletions(-)
diff --git a/src/ArchiveWriter.java b/src/ArchiveWriter.java
index cced896..d632924 100644
--- a/src/ArchiveWriter.java
+++ b/src/ArchiveWriter.java
@@ -127,21 +127,9 @@ public class ArchiveWriter {
consensuses.remove(consensuses.first());
}
}
- leftToParse.add(new File(outputDirectory + "/vote"));
- SortedSet<File> votes = new TreeSet<File>();
- while (!leftToParse.isEmpty()) {
- File pop = leftToParse.pop();
- if (pop.isDirectory()) {
- for (File f : pop.listFiles()) {
- leftToParse.add(f);
- }
- } else if (pop.length() > 0) {
- votes.add(pop);
- }
- }
for (File f : consensuses) {
BufferedReader br = new BufferedReader(new FileReader(f));
- String line = null, validAfterTime = null, votePrefix = null;
+ String line = null, validAfterTime = null, voteFilename = null;
int allVotes = 0, foundVotes = 0,
allServerDescs = 0, foundServerDescs = 0,
allExtraInfos = 0, foundExtraInfos = 0;
@@ -150,23 +138,19 @@ public class ArchiveWriter {
validAfterTime = line.substring("valid-after ".length());
long validAfter = validAfterFormat.parse(
validAfterTime).getTime();
- votePrefix = outputDirectory + "/vote/"
+ voteFilename = outputDirectory + "/vote/"
+ consensusVoteFormat.format(new Date(validAfter))
+ "-vote-";
} else if (line.startsWith("dir-source ")) {
+ voteFilename += line.split(" ")[2] + "-";
+ } else if (line.startsWith("vote-digest ")) {
+ voteFilename += line.split(" ")[1];
allVotes++;
- String pattern = votePrefix + line.split(" ")[2];
- String votefilename = null;
- for (File v : votes) {
- if (v.getName().startsWith(pattern)) {
- votefilename = v.getName();
- break;
- }
- }
- if (votefilename != null) {
+ File voteFile = new File(voteFilename);
+ if (voteFile.exists()) {
foundVotes++;
BufferedReader vbr = new BufferedReader(new FileReader(
- new File(votefilename)));
+ voteFile));
String line3 = null;
int voteAllServerDescs = 0, voteFoundServerDescs = 0,
voteAllExtraInfos = 0, voteFoundExtraInfos = 0;
@@ -211,8 +195,8 @@ public class ArchiveWriter {
}
}
vbr.close();
- sb.append(String.format("%nV, %s, NA, %d/%d (%5.1f%%), "
- + "%d/%d (%5.1f%%)", validAfterTime,
+ sb.append(String.format("%nV, %s, NA, %d/%d (%.1f%%), "
+ + "%d/%d (%.1f%%)", validAfterTime,
voteFoundServerDescs, voteAllServerDescs,
100.0D * (double) voteFoundServerDescs /
(double) voteAllServerDescs,
@@ -256,8 +240,8 @@ public class ArchiveWriter {
}
}
}
- sb.append(String.format("%nC, %s, %d/%d (%5.1f%%), "
- + "%d/%d (%5.1f%%), %d/%d (%5.1f%%)",
+ sb.append(String.format("%nC, %s, %d/%d (%.1f%%), "
+ + "%d/%d (%.1f%%), %d/%d (%.1f%%)",
validAfterTime, foundVotes, allVotes,
100.0D * (double) foundVotes / (double) allVotes,
foundServerDescs, allServerDescs,
diff --git a/src/RelayDescriptorDownloader.java b/src/RelayDescriptorDownloader.java
index 0c03532..c0d9696 100644
--- a/src/RelayDescriptorDownloader.java
+++ b/src/RelayDescriptorDownloader.java
@@ -169,7 +169,9 @@ public class RelayDescriptorDownloader {
((line.startsWith("server,") ||
line.startsWith("extra,")) &&
this.descriptorCutOff.compareTo(published) <= 0)) {
- if (line.startsWith("consensus,")) {
+ if (!line.endsWith("NA")) {
+ /* Not missing. */
+ } else if (line.startsWith("consensus,")) {
missingConsensuses++;
} else if (line.startsWith("vote,")) {
missingVotes++;
@@ -380,12 +382,10 @@ public class RelayDescriptorDownloader {
this.downloadCurrentConsensus &&
this.currentValidAfter.equals(parts[1])) {
urls.add("/tor/status-vote/current/consensus");
- this.triedConsensuses++;
} else if (parts[0].equals("vote") &&
this.downloadCurrentVotes &&
this.currentValidAfter.equals(parts[1])) {
urls.add("/tor/status-vote/current/" + parts[2]);
- this.triedVotes++;
} else if (parts[0].equals("server") &&
(this.downloadAllServerDescriptors ||
(this.downloadDescriptorsForRelays != null &&
@@ -393,7 +393,6 @@ public class RelayDescriptorDownloader {
toUpperCase()))) &&
this.descriptorCutOff.compareTo(parts[1]) <= 0) {
urls.add("/tor/server/d/" + parts[3]);
- this.triedServerDescriptors++;
} else if (parts[0].equals("extra") &&
(this.downloadAllExtraInfos ||
(this.downloadDescriptorsForRelays != null &&
@@ -401,12 +400,23 @@ public class RelayDescriptorDownloader {
toUpperCase()))) &&
this.descriptorCutOff.compareTo(parts[1]) <= 0) {
urls.add("/tor/extra/d/" + parts[3]);
- this.triedExtraInfoDescriptors++;
}
}
}
urls.removeAll(downloaded);
+ for (String url : urls) {
+ if (url.endsWith("consensus")) {
+ this.triedConsensuses++;
+ } else if (url.contains("status-vote")) {
+ this.triedVotes++;
+ } else if (url.contains("server")) {
+ this.triedServerDescriptors++;
+ } else if (url.contains("extra")) {
+ this.triedExtraInfoDescriptors++;
+ }
+ }
+
/* Log what we're downloading. */
StringBuilder sb = new StringBuilder("Downloading " + urls.size()
+ " descriptors:");
@@ -494,7 +504,9 @@ public class RelayDescriptorDownloader {
for (Map.Entry<String, String> e :
this.missingDescriptors.entrySet()) {
String key = e.getKey();
- if (key.startsWith("consensus,")) {
+ if (!e.getValue().equals("NA")) {
+ /* Not missing. */
+ } else if (key.startsWith("consensus,")) {
missingConsensuses++;
} else if (key.startsWith("vote,")) {
missingVotes++;
--
1.6.5