[tor-commits] [metrics-web/master] Resolve deprecation warnings.

karsten at torproject.org karsten at torproject.org
Sun Apr 23 15:36:06 UTC 2017


commit 6538573b044cd6a8f9c3c36926d9bf4707d0def1
Author: Karsten Loesing <karsten.loesing at gmx.net>
Date:   Tue Feb 28 14:14:05 2017 +0100

    Resolve deprecation warnings.
    
    Fixes #21578.
---
 .../src/main/java/org/torproject/metrics/advbwdist/Main.java   |  5 +++--
 .../src/main/java/org/torproject/metrics/clients/Main.java     | 10 ++++++----
 .../torproject/ernie/cron/RelayDescriptorDatabaseImporter.java |  8 ++++++--
 .../ernie/cron/network/ConsensusStatsFileHandler.java          |  8 ++++++--
 .../torproject/ernie/cron/performance/TorperfProcessor.java    |  5 +++--
 5 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/modules/advbwdist/src/main/java/org/torproject/metrics/advbwdist/Main.java b/modules/advbwdist/src/main/java/org/torproject/metrics/advbwdist/Main.java
index 7d7678d..a3135c0 100644
--- a/modules/advbwdist/src/main/java/org/torproject/metrics/advbwdist/Main.java
+++ b/modules/advbwdist/src/main/java/org/torproject/metrics/advbwdist/Main.java
@@ -59,8 +59,8 @@ public class Main {
     descriptorReader = DescriptorSourceFactory.createDescriptorReader();
     descriptorReader.addDirectory(
         new File("../../shared/in/recent/relay-descriptors/consensuses"));
-    descriptorReader.setExcludeFiles(
-        new File("status/parsed-consensuses"));
+    File historyFile = new File("status/parsed-consensuses");
+    descriptorReader.setHistoryFile(historyFile);
     descriptorFiles = descriptorReader.readDescriptors();
     File resultsFile = new File("stats/advbwdist-validafter.csv");
     resultsFile.getParentFile().mkdirs();
@@ -152,6 +152,7 @@ public class Main {
         }
       }
     }
+    descriptorReader.saveHistoryFile(historyFile);
     bw.close();
   }
 }
diff --git a/modules/clients/src/main/java/org/torproject/metrics/clients/Main.java b/modules/clients/src/main/java/org/torproject/metrics/clients/Main.java
index dff73f7..dc34d37 100644
--- a/modules/clients/src/main/java/org/torproject/metrics/clients/Main.java
+++ b/modules/clients/src/main/java/org/torproject/metrics/clients/Main.java
@@ -63,8 +63,8 @@ public class Main {
   private static void parseRelayDescriptors() throws Exception {
     DescriptorReader descriptorReader =
         DescriptorSourceFactory.createDescriptorReader();
-    descriptorReader.setExcludeFiles(new File(
-        "status/relay-descriptors"));
+    File historyFile = new File("status/relay-descriptors");
+    descriptorReader.setHistoryFile(historyFile);
     descriptorReader.addDirectory(new File(
         "../../shared/in/recent/relay-descriptors/consensuses"));
     descriptorReader.addDirectory(new File(
@@ -86,6 +86,7 @@ public class Main {
         }
       }
     }
+    descriptorReader.saveHistoryFile(historyFile);
   }
 
   private static void parseRelayExtraInfoDescriptor(
@@ -206,8 +207,8 @@ public class Main {
   private static void parseBridgeDescriptors() throws Exception {
     DescriptorReader descriptorReader =
         DescriptorSourceFactory.createDescriptorReader();
-    descriptorReader.setExcludeFiles(new File(
-        "status/bridge-descriptors"));
+    File historyFile = new File("status/bridge-descriptors");
+    descriptorReader.setHistoryFile(historyFile);
     descriptorReader.addDirectory(new File(
         "../../shared/in/recent/bridge-descriptors"));
     descriptorReader.addDirectory(new File(
@@ -225,6 +226,7 @@ public class Main {
         }
       }
     }
+    descriptorReader.saveHistoryFile(historyFile);
   }
 
   private static void parseBridgeExtraInfoDescriptor(
diff --git a/modules/legacy/src/main/java/org/torproject/ernie/cron/RelayDescriptorDatabaseImporter.java b/modules/legacy/src/main/java/org/torproject/ernie/cron/RelayDescriptorDatabaseImporter.java
index 97a330e..657f0d7 100644
--- a/modules/legacy/src/main/java/org/torproject/ernie/cron/RelayDescriptorDatabaseImporter.java
+++ b/modules/legacy/src/main/java/org/torproject/ernie/cron/RelayDescriptorDatabaseImporter.java
@@ -843,9 +843,10 @@ public final class RelayDescriptorDatabaseImporter {
           reader.addDirectory(archivesDirectory);
         }
       }
+      File historyFile = new File(statsDirectory,
+          "database-importer-relay-descriptor-history");
       if (keepImportHistory) {
-        reader.setExcludeFiles(new File(statsDirectory,
-            "database-importer-relay-descriptor-history"));
+        reader.setHistoryFile(historyFile);
       }
       Iterator<DescriptorFile> descriptorFiles = reader.readDescriptors();
       while (descriptorFiles.hasNext()) {
@@ -864,6 +865,9 @@ public final class RelayDescriptorDatabaseImporter {
           }
         }
       }
+      if (keepImportHistory) {
+        reader.saveHistoryFile(historyFile);
+      }
     }
 
     logger.info("Finished importing relay descriptors.");
diff --git a/modules/legacy/src/main/java/org/torproject/ernie/cron/network/ConsensusStatsFileHandler.java b/modules/legacy/src/main/java/org/torproject/ernie/cron/network/ConsensusStatsFileHandler.java
index aa9469e..9aef3e4 100644
--- a/modules/legacy/src/main/java/org/torproject/ernie/cron/network/ConsensusStatsFileHandler.java
+++ b/modules/legacy/src/main/java/org/torproject/ernie/cron/network/ConsensusStatsFileHandler.java
@@ -192,9 +192,10 @@ public class ConsensusStatsFileHandler {
       DescriptorReader reader =
           DescriptorSourceFactory.createDescriptorReader();
       reader.addDirectory(bridgesDir);
+      File historyFile = new File(statsDirectory,
+          "consensus-stats-bridge-descriptor-history");
       if (keepImportHistory) {
-        reader.setExcludeFiles(new File(statsDirectory,
-            "consensus-stats-bridge-descriptor-history"));
+        reader.setHistoryFile(historyFile);
       }
       Iterator<DescriptorFile> descriptorFiles = reader.readDescriptors();
       while (descriptorFiles.hasNext()) {
@@ -222,6 +223,9 @@ public class ConsensusStatsFileHandler {
           }
         }
       }
+      if (keepImportHistory) {
+        reader.saveHistoryFile(historyFile);
+      }
       logger.info("Finished importing bridge descriptors.");
     }
   }
diff --git a/modules/legacy/src/main/java/org/torproject/ernie/cron/performance/TorperfProcessor.java b/modules/legacy/src/main/java/org/torproject/ernie/cron/performance/TorperfProcessor.java
index 25b0050..0c2be9d 100644
--- a/modules/legacy/src/main/java/org/torproject/ernie/cron/performance/TorperfProcessor.java
+++ b/modules/legacy/src/main/java/org/torproject/ernie/cron/performance/TorperfProcessor.java
@@ -84,8 +84,8 @@ public class TorperfProcessor {
         DescriptorReader descriptorReader =
             DescriptorSourceFactory.createDescriptorReader();
         descriptorReader.addDirectory(torperfDirectory);
-        descriptorReader.setExcludeFiles(new File(statsDirectory,
-            "torperf-history"));
+        File historyFile = new File(statsDirectory, "torperf-history");
+        descriptorReader.setHistoryFile(historyFile);
         Iterator<DescriptorFile> descriptorFiles =
             descriptorReader.readDescriptors();
         while (descriptorFiles.hasNext()) {
@@ -139,6 +139,7 @@ public class TorperfProcessor {
             }
           }
         }
+        descriptorReader.saveHistoryFile(historyFile);
         logger.fine("Finished importing files in " + torperfDirectory
             + "/.");
       }



More information about the tor-commits mailing list