[or-cvs] [ernie/master] Make logs about written relay descriptors more useful.

karsten at torproject.org karsten at torproject.org
Wed Apr 14 14:52:11 UTC 2010


Author: Karsten Loesing <karsten.loesing at gmx.net>
Date: Wed, 14 Apr 2010 16:51:34 +0200
Subject: Make logs about written relay descriptors more useful.
Commit: 6ddf33e5c2a17f6b8e33cc5345ae1d3f41f214a2

---
 src/ArchiveWriter.java |   19 +++++++++++++------
 src/Main.java          |    6 ++++++
 2 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/src/ArchiveWriter.java b/src/ArchiveWriter.java
index 9c96d42..9a02daf 100644
--- a/src/ArchiveWriter.java
+++ b/src/ArchiveWriter.java
@@ -86,17 +86,24 @@ public class ArchiveWriter {
     }
   }
 
+  private StringBuilder intermediateStats = new StringBuilder();
+  public void intermediateStats(String event) {
+    intermediateStats.append("While " + event + ", we stored "
+        + this.storedConsensuses + " consensus(es), " + this.storedVotes
+        + " vote(s), " + this.storedServerDescriptors
+        + " server descriptor(s), and " + this.storedExtraInfoDescriptors
+        + " extra-info descriptor(s) to disk. Resetting counters.\n");
+    this.storedConsensuses = 0;
+    this.storedVotes = 0;
+    this.storedServerDescriptors = 0;
+    this.storedExtraInfoDescriptors = 0;
+  }
   /**
    * Dump some statistics on the completeness of descriptors to the logs
    * on level INFO.
    */
   public void dumpStats() {
-    StringBuilder sb = new StringBuilder("Finished writing relay "
-        + "descriptors to disk:\nIn this execution, we stored "
-        + this.storedConsensuses + " consensus(es), " + this.storedVotes
-        + " vote(s), " + this.storedServerDescriptors
-        + " server descriptor(s), and " + this.storedExtraInfoDescriptors
-        + " extra-info descriptor(s) to disk.\n");
+    StringBuilder sb = new StringBuilder(intermediateStats.toString());
     sb.append("Statistics on the completeness of written relay "
         + "descriptors of the past 12 consensuses (Consensus/Vote, "
         + "valid-after, votes, server descriptors, extra-infos):");
diff --git a/src/Main.java b/src/Main.java
index a147cc9..9ee09f6 100644
--- a/src/Main.java
+++ b/src/Main.java
@@ -84,15 +84,21 @@ public class Main {
       if (config.getImportCachedRelayDescriptors()) {
         new CachedRelayDescriptorReader(rdp,
             config.getCachedRelayDescriptorDirectory());
+        aw.intermediateStats("importing relay descriptors from local Tor "
+            + "data directories");
       }
       if (config.getImportDirectoryArchives()) {
         new ArchiveReader(rdp, config.getDirectoryArchivesDirectory(),
             config.getKeepDirectoryArchiveImportHistory());
+        aw.intermediateStats("importing relay descriptors from local "
+            + "directory");
       }
       if (rdd != null) {
         rdd.downloadMissingDescriptors();
         rdd.writeFile();
         rdd = null;
+        aw.intermediateStats("downloading relay descriptors from the "
+            + "directory authorities");
       }
     }
 
-- 
1.6.5



More information about the tor-commits mailing list