[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [collector/release] Make OnionPerf adhere to the standard CollecTorMain.



commit c4ab51e8dcdef8d8adb93d4cba7e35f82e1368ea
Author: iwakeh <iwakeh@xxxxxxxxxxxxxx>
Date:   Wed Jul 12 18:47:44 2017 +0000

    Make OnionPerf adhere to the standard CollecTorMain.
    
    This includes adding property 'OnionPerfSources' and renaming
    some markers properly.  In addition, all camel-case occurrences
    of 'OnionPerf' have a capitalized 'P' now.
    
    Part of task-21759.
---
 src/main/java/org/torproject/collector/Main.java            |  4 ++--
 src/main/java/org/torproject/collector/conf/Annotation.java |  2 +-
 .../java/org/torproject/collector/conf/Configuration.java   |  2 +-
 src/main/java/org/torproject/collector/conf/Key.java        |  7 ++++---
 .../torproject/collector/exitlists/ExitListDownloader.java  |  2 +-
 .../{OnionperfDownloader.java => OnionPerfDownloader.java}  | 11 ++++++-----
 src/main/resources/collector.properties                     | 13 +++++++++----
 src/test/java/org/torproject/collector/MainTest.java        |  2 +-
 .../org/torproject/collector/conf/ConfigurationTest.java    |  2 +-
 .../org/torproject/collector/cron/CollecTorMainTest.java    |  1 +
 .../java/org/torproject/collector/cron/SchedulerTest.java   | 10 +++++-----
 11 files changed, 32 insertions(+), 24 deletions(-)

diff --git a/src/main/java/org/torproject/collector/Main.java b/src/main/java/org/torproject/collector/Main.java
index 6676eb8..1377fec 100644
--- a/src/main/java/org/torproject/collector/Main.java
+++ b/src/main/java/org/torproject/collector/Main.java
@@ -12,7 +12,7 @@ import org.torproject.collector.cron.Scheduler;
 import org.torproject.collector.cron.ShutdownHook;
 import org.torproject.collector.exitlists.ExitListDownloader;
 import org.torproject.collector.index.CreateIndexJson;
-import org.torproject.collector.onionperf.OnionperfDownloader;
+import org.torproject.collector.onionperf.OnionPerfDownloader;
 import org.torproject.collector.relaydescs.ArchiveWriter;
 
 import org.slf4j.Logger;
@@ -50,7 +50,7 @@ public class Main {
     collecTorMains.put(Key.ExitlistsActivated, ExitListDownloader.class);
     collecTorMains.put(Key.UpdateindexActivated, CreateIndexJson.class);
     collecTorMains.put(Key.RelaydescsActivated, ArchiveWriter.class);
-    collecTorMains.put(Key.OnionperfActivated, OnionperfDownloader.class);
+    collecTorMains.put(Key.OnionPerfActivated, OnionPerfDownloader.class);
   }
 
   private static Configuration conf = new Configuration();
diff --git a/src/main/java/org/torproject/collector/conf/Annotation.java b/src/main/java/org/torproject/collector/conf/Annotation.java
index e4e63d6..0dab546 100644
--- a/src/main/java/org/torproject/collector/conf/Annotation.java
+++ b/src/main/java/org/torproject/collector/conf/Annotation.java
@@ -16,7 +16,7 @@ public enum Annotation {
   Microdescriptor("@type microdescriptor 1.0\n"),
   Server("@type server-descriptor 1.0\n"),
   Status("@type bridge-network-status 1.2\n"),
-  Onionperf("@type torperf 1.0\n"),
+  OnionPerf("@type torperf 1.0\n"),
   Vote("@type network-status-vote-3 1.0\n");
 
   private final String annotation;
diff --git a/src/main/java/org/torproject/collector/conf/Configuration.java b/src/main/java/org/torproject/collector/conf/Configuration.java
index 4e24a7b..1a62bc1 100644
--- a/src/main/java/org/torproject/collector/conf/Configuration.java
+++ b/src/main/java/org/torproject/collector/conf/Configuration.java
@@ -92,7 +92,7 @@ public class Configuration extends Observable implements Cloneable {
         || this.getBool(Key.BridgedescsActivated)
         || this.getBool(Key.ExitlistsActivated)
         || this.getBool(Key.UpdateindexActivated)
-        || this.getBool(Key.OnionperfActivated))) {
+        || this.getBool(Key.OnionPerfActivated))) {
       throw new ConfigurationException("Nothing is activated!\n"
           + "Please edit collector.properties. Exiting.");
     }
diff --git a/src/main/java/org/torproject/collector/conf/Key.java b/src/main/java/org/torproject/collector/conf/Key.java
index e3bcff1..4341432 100644
--- a/src/main/java/org/torproject/collector/conf/Key.java
+++ b/src/main/java/org/torproject/collector/conf/Key.java
@@ -27,6 +27,7 @@ public enum Key {
   RelaySources(SourceType[].class),
   BridgeSources(SourceType[].class),
   ExitlistSources(SourceType[].class),
+  OnionPerfSources(SourceType[].class),
   RelayCacheOrigins(String[].class),
   RelayLocalOrigins(Path.class),
   RelaySyncOrigins(URL[].class),
@@ -42,9 +43,9 @@ public enum Key {
   RelaydescsActivated(Boolean.class),
   RelaydescsOffsetMinutes(Integer.class),
   RelaydescsPeriodMinutes(Integer.class),
-  OnionperfActivated(Boolean.class),
-  OnionperfOffsetMinutes(Integer.class),
-  OnionperfPeriodMinutes(Integer.class),
+  OnionPerfActivated(Boolean.class),
+  OnionPerfOffsetMinutes(Integer.class),
+  OnionPerfPeriodMinutes(Integer.class),
   UpdateindexActivated(Boolean.class),
   UpdateindexOffsetMinutes(Integer.class),
   UpdateindexPeriodMinutes(Integer.class),
diff --git a/src/main/java/org/torproject/collector/exitlists/ExitListDownloader.java b/src/main/java/org/torproject/collector/exitlists/ExitListDownloader.java
index c27c970..b49189d 100644
--- a/src/main/java/org/torproject/collector/exitlists/ExitListDownloader.java
+++ b/src/main/java/org/torproject/collector/exitlists/ExitListDownloader.java
@@ -43,7 +43,7 @@ public class ExitListDownloader extends CollecTorMain {
 
   private String recentPathName;
 
-  /** Instanciate the exit-lists module using the given configuration. */
+  /** Instantiate the exit-lists module using the given configuration. */
   public ExitListDownloader(Configuration config) {
     super(config);
     this.mapPathDescriptors.put("recent/exit-lists", ExitList.class);
diff --git a/src/main/java/org/torproject/collector/onionperf/OnionperfDownloader.java b/src/main/java/org/torproject/collector/onionperf/OnionPerfDownloader.java
similarity index 97%
rename from src/main/java/org/torproject/collector/onionperf/OnionperfDownloader.java
rename to src/main/java/org/torproject/collector/onionperf/OnionPerfDownloader.java
index 577d16d..b2a27d4 100644
--- a/src/main/java/org/torproject/collector/onionperf/OnionperfDownloader.java
+++ b/src/main/java/org/torproject/collector/onionperf/OnionPerfDownloader.java
@@ -41,14 +41,15 @@ import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 /** Download download .tpf files from OnionPerf hosts. */
-public class OnionperfDownloader extends CollecTorMain {
+public class OnionPerfDownloader extends CollecTorMain {
 
   private static final Logger logger = LoggerFactory.getLogger(
-      OnionperfDownloader.class);
+      OnionPerfDownloader.class);
 
   private static final String TORPERF = "torperf";
 
-  public OnionperfDownloader(Configuration config) {
+  /** Instantiate the OnionPerf module using the given configuration. */
+  public OnionPerfDownloader(Configuration config) {
     super(config);
   }
 
@@ -72,12 +73,12 @@ public class OnionperfDownloader extends CollecTorMain {
 
   @Override
   public String module() {
-    return TORPERF;
+    return "onionperf";
   }
 
   @Override
   protected String syncMarker() {
-    return "TorperfFiles";
+    return "OnionPerf";
   }
 
   @Override
diff --git a/src/main/resources/collector.properties b/src/main/resources/collector.properties
index 54caf5a..d49bd58 100644
--- a/src/main/resources/collector.properties
+++ b/src/main/resources/collector.properties
@@ -30,11 +30,11 @@ RelaydescsPeriodMinutes = 30
 # offset in minutes since the epoch and
 RelaydescsOffsetMinutes = 5
 ## the following defines, if this module is activated
-OnionperfActivated = false
+OnionPerfActivated = false
 # period in minutes
-OnionperfPeriodMinutes = 360
+OnionPerfPeriodMinutes = 360
 # offset in minutes since the epoch and
-OnionperfOffsetMinutes = 1
+OnionPerfOffsetMinutes = 1
 # the following defines, if this module is activated
 UpdateindexActivated = false
 # period in minutes
@@ -139,7 +139,11 @@ ExitlistSyncOrigins = https://collector.torproject.org
 ## Where to download exit-lists from.
 ExitlistUrl = https://check.torproject.org/exit-addresses
 #
-######## Onionperf downloader ########
+######## OnionPerf downloader ########
+#
+## Define descriptor sources
+#  possible values: Remote
+OnionPerfSources = Remote
 #
 ## OnionPerf base URLs
 ## Hosts must be configured to use the first subdomain part of the given URL as
@@ -147,3 +151,4 @@ ExitlistUrl = https://check.torproject.org/exit-addresses
 ## the second, etc.:
 ## OnionPerfHosts = http://first.torproject.org/, http://second.torproject.org/
 OnionPerfHosts = https://op-us.onionperf.torproject.net/
+
diff --git a/src/test/java/org/torproject/collector/MainTest.java b/src/test/java/org/torproject/collector/MainTest.java
index 2e9c0ce..b9cf5f8 100644
--- a/src/test/java/org/torproject/collector/MainTest.java
+++ b/src/test/java/org/torproject/collector/MainTest.java
@@ -100,7 +100,7 @@ public class MainTest {
     Main.main(new String[]{conf.toString()});
     assertTrue(4_000L <= conf.length());
     changeFilePathsAndSetActivation(conf,
-        Key.OnionperfActivated.name());
+        Key.OnionPerfActivated.name());
     Main.main(new String[]{conf.toString()});
     waitSec(2);
   }
diff --git a/src/test/java/org/torproject/collector/conf/ConfigurationTest.java b/src/test/java/org/torproject/collector/conf/ConfigurationTest.java
index a0c1dd1..bbe7832 100644
--- a/src/test/java/org/torproject/collector/conf/ConfigurationTest.java
+++ b/src/test/java/org/torproject/collector/conf/ConfigurationTest.java
@@ -40,7 +40,7 @@ public class ConfigurationTest {
   public void testKeyCount() throws Exception {
     assertEquals("The number of properties keys in enum Key changed."
         + "\n This test class should be adapted.",
-        43, Key.values().length);
+        44, Key.values().length);
   }
 
   @Test()
diff --git a/src/test/java/org/torproject/collector/cron/CollecTorMainTest.java b/src/test/java/org/torproject/collector/cron/CollecTorMainTest.java
index dc3e575..49f07ef 100644
--- a/src/test/java/org/torproject/collector/cron/CollecTorMainTest.java
+++ b/src/test/java/org/torproject/collector/cron/CollecTorMainTest.java
@@ -70,6 +70,7 @@ public class CollecTorMainTest {
         case "Relay":
         case "Bridge":
         case "Exitlist":
+        case "OnionPerf":
           assertNotNull("Property '" + key
               + "' not specified in " + Main.CONF_FILE + ".",
               props.getProperty(key));
diff --git a/src/test/java/org/torproject/collector/cron/SchedulerTest.java b/src/test/java/org/torproject/collector/cron/SchedulerTest.java
index 63eb5af..062009f 100644
--- a/src/test/java/org/torproject/collector/cron/SchedulerTest.java
+++ b/src/test/java/org/torproject/collector/cron/SchedulerTest.java
@@ -22,8 +22,8 @@ import java.util.concurrent.ScheduledThreadPoolExecutor;
 public class SchedulerTest {
 
   private static final String runConfigProperties =
-      "OnionperfActivated=true\nOnionperfPeriodMinutes=1\n"
-      + "OnionperfOffsetMinutes=0\n"
+      "OnionPerfActivated=true\nOnionPerfPeriodMinutes=1\n"
+      + "OnionPerfOffsetMinutes=0\n"
       + "RelaydescsActivated=true\nRelaydescsPeriodMinutes=1\n"
       + "RelaydescsOffsetMinutes=0\n"
       + "ExitlistsActivated=true\nExitlistsPeriodMinutes=1\n"
@@ -38,7 +38,7 @@ public class SchedulerTest {
     Map<Key, Class<? extends CollecTorMain>> ctms = new HashMap<>();
     Configuration conf = new Configuration();
     conf.load(new ByteArrayInputStream(runConfigProperties.getBytes()));
-    ctms.put(Key.OnionperfActivated, Dummy.class);
+    ctms.put(Key.OnionPerfActivated, Dummy.class);
     ctms.put(Key.BridgedescsActivated, Dummy.class);
     ctms.put(Key.RelaydescsActivated, Dummy.class);
     ctms.put(Key.ExitlistsActivated, Dummy.class);
@@ -70,7 +70,7 @@ public class SchedulerTest {
     conf.load(new ByteArrayInputStream(("ShutdownGraceWaitMinutes=1\n"
         + runConfigProperties).getBytes()));
     conf.setProperty(Key.RunOnce.name(), "true");
-    ctms.put(Key.OnionperfActivated, Counter.class);
+    ctms.put(Key.OnionPerfActivated, Counter.class);
     ctms.put(Key.BridgedescsActivated, Counter.class);
     ctms.put(Key.RelaydescsActivated, Counter.class);
     ctms.put(Key.ExitlistsActivated, Counter.class);
@@ -93,7 +93,7 @@ public class SchedulerTest {
     Map<Key, Class<? extends CollecTorMain>> ctms = new HashMap<>();
     Configuration conf = new Configuration();
     conf.load(new ByteArrayInputStream(runConfigProperties.getBytes()));
-    ctms.put(Key.OnionperfActivated, Broken.class);
+    ctms.put(Key.OnionPerfActivated, Broken.class);
     ctms.put(Key.BridgedescsActivated, Broken.class);
     ctms.put(Key.RelaydescsActivated, Broken.class);
     ctms.put(Key.ExitlistsActivated, Broken.class);



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits