[or-cvs] [ernie/master] Log number of requested descriptors by directory.

karsten at torproject.org karsten at torproject.org
Wed Apr 28 11:39:13 UTC 2010


Author: Karsten Loesing <karsten.loesing at gmx.net>
Date: Wed, 28 Apr 2010 13:37:02 +0200
Subject: Log number of requested descriptors by directory.
Commit: 14d8396920c52e781bbddfaa9a1723b05f8b3343

---
 src/RelayDescriptorDownloader.java |   19 ++++++++++++++++++-
 1 files changed, 18 insertions(+), 1 deletions(-)

diff --git a/src/RelayDescriptorDownloader.java b/src/RelayDescriptorDownloader.java
index 5a5ac65..c3be80e 100644
--- a/src/RelayDescriptorDownloader.java
+++ b/src/RelayDescriptorDownloader.java
@@ -44,6 +44,11 @@ public class RelayDescriptorDownloader {
   private List<String> dirSources;
 
   /**
+   * Number of descriptors requested by directory to be included in logs.
+   */
+  private Map<String, Integer> dirRequests;
+
+  /**
    * Should we try to download the current consensus if we don't have it?
    */
   private boolean downloadCurrentConsensus;
@@ -208,6 +213,11 @@ public class RelayDescriptorDownloader {
         + missingVotes + " vote(s), " + missingServerDescriptors
         + " server descriptor(s), and " + missingExtraInfoDescriptors
         + " extra-info descriptor(s).\n");
+
+    dirRequests = new HashMap<String, Integer>();
+    for (String dirSource : dirSources) {
+      dirRequests.put(dirSource, 0);
+    }
   }
 
   /**
@@ -449,6 +459,7 @@ public class RelayDescriptorDownloader {
         if (!downloaded.contains(fullUrl)) {
           downloaded.add(fullUrl);
           numDownloaded++;
+          this.dirRequests.put(authority, dirRequests.get(authority) + 1);
           try {
             URL u = new URL(fullUrl);
             HttpURLConnection huc =
@@ -556,7 +567,13 @@ public class RelayDescriptorDownloader {
         + this.triedServerDescriptors + " server descriptor(s), and "
         + this.triedExtraInfoDescriptors + " extra-info descriptor(s) "
         + "from the directory authorities.\n");
-    dumpStats.append("We successfully downloaded "
+    dumpStats.append("Requests were sent to these directory "
+        + "authorities:");
+    for (String dirSource : this.dirSources) {
+      dumpStats.append(" " + dirSource + "="
+         + this.dirRequests.get(dirSource));
+    }
+    dumpStats.append("\nWe successfully downloaded "
         + this.downloadedConsensuses + " consensus(es), "
         + this.downloadedVotes + " vote(s), "
         + this.downloadedServerDescriptors + " server descriptor(s), and "
-- 
1.6.5



More information about the tor-commits mailing list