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

[tor-commits] [metrics-web/master] Rename Parsed* to Ipv6*.



commit c39409096ee1531b0c0b0a8fc79ae295d84e6e27
Author: iwakeh <iwakeh@xxxxxxxxxxxxxx>
Date:   Wed Dec 20 13:06:53 2017 +0000

    Rename Parsed* to Ipv6*.
    
    Indicate that this is not the typical descriptor, but only provides relevant
    information for the ipv6servers module.
---
 .../metrics/stats/ipv6servers/Database.java        | 29 ++++++++++------------
 ...edNetworkStatus.java => Ipv6NetworkStatus.java} |  2 +-
 ...erDescriptor.java => Ipv6ServerDescriptor.java} |  2 +-
 .../metrics/stats/ipv6servers/Parser.java          | 14 +++++------
 ...kStatusTest.java => Ipv6NetworkStatusTest.java} |  6 ++---
 ...ptorTest.java => Ipv6ServerDescriptorTest.java} |  4 +--
 6 files changed, 27 insertions(+), 30 deletions(-)

diff --git a/src/main/java/org/torproject/metrics/stats/ipv6servers/Database.java b/src/main/java/org/torproject/metrics/stats/ipv6servers/Database.java
index e95aba0..1d5187b 100644
--- a/src/main/java/org/torproject/metrics/stats/ipv6servers/Database.java
+++ b/src/main/java/org/torproject/metrics/stats/ipv6servers/Database.java
@@ -84,10 +84,10 @@ class Database implements AutoCloseable {
 
   /** Insert a server descriptor into the server_descriptors table. */
   void insertServerDescriptor(
-      ParsedServerDescriptor parsedServerDescriptor) throws SQLException {
+      Ipv6ServerDescriptor serverDescriptor) throws SQLException {
     this.psServerDescriptorsSelect.clearParameters();
     this.psServerDescriptorsSelect.setString(1,
-        parsedServerDescriptor.digest);
+        serverDescriptor.digest);
     try (ResultSet rs = psServerDescriptorsSelect.executeQuery()) {
       if (rs.next()) {
         if (rs.getBoolean(1)) {
@@ -97,28 +97,25 @@ class Database implements AutoCloseable {
       }
     }
     this.psServerDescriptorsInsert.clearParameters();
-    this.psServerDescriptorsInsert.setString(1,
-        parsedServerDescriptor.digest);
+    this.psServerDescriptorsInsert.setString(1, serverDescriptor.digest);
     this.psServerDescriptorsInsert.setInt(2,
-        parsedServerDescriptor.advertisedBandwidth);
-    this.psServerDescriptorsInsert.setBoolean(3,
-        parsedServerDescriptor.announced);
-    this.psServerDescriptorsInsert.setBoolean(4,
-        parsedServerDescriptor.exiting);
+        serverDescriptor.advertisedBandwidth);
+    this.psServerDescriptorsInsert.setBoolean(3, serverDescriptor.announced);
+    this.psServerDescriptorsInsert.setBoolean(4, serverDescriptor.exiting);
     this.psServerDescriptorsInsert.execute();
   }
 
   /** Insert a status and all contained entries into the statuses and
    * status_entries table. */
-  void insertStatus(ParsedNetworkStatus parsedNetworkStatus)
+  void insertStatus(Ipv6NetworkStatus networkStatus)
       throws SQLException {
     this.psStatusesSelect.clearParameters();
     this.psStatusesSelect.setString(1,
-        parsedNetworkStatus.isRelay ? "relay" : "bridge");
+        networkStatus.isRelay ? "relay" : "bridge");
     Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC"),
         Locale.US);
     this.psStatusesSelect.setTimestamp(2,
-        Timestamp.from(ZonedDateTime.of(parsedNetworkStatus.timestamp,
+        Timestamp.from(ZonedDateTime.of(networkStatus.timestamp,
         ZoneId.of("UTC")).toInstant()), calendar);
     try (ResultSet rs = this.psStatusesSelect.executeQuery()) {
       if (rs.next()) {
@@ -131,11 +128,11 @@ class Database implements AutoCloseable {
     int statusId = -1;
     this.psStatusesInsert.clearParameters();
     this.psStatusesInsert.setString(1,
-        parsedNetworkStatus.isRelay ? "relay" : "bridge");
+        networkStatus.isRelay ? "relay" : "bridge");
     this.psStatusesInsert.setTimestamp(2,
-        Timestamp.from(ZonedDateTime.of(parsedNetworkStatus.timestamp,
+        Timestamp.from(ZonedDateTime.of(networkStatus.timestamp,
         ZoneId.of("UTC")).toInstant()), calendar);
-    this.psStatusesInsert.setInt(3, parsedNetworkStatus.running);
+    this.psStatusesInsert.setInt(3, networkStatus.running);
     this.psStatusesInsert.execute();
     try (ResultSet rs = this.psStatusesInsert.getGeneratedKeys()) {
       if (rs.next()) {
@@ -146,7 +143,7 @@ class Database implements AutoCloseable {
       throw new SQLException("Could not retrieve auto-generated key for new "
           + "statuses entry.");
     }
-    for (ParsedNetworkStatus.Entry entry : parsedNetworkStatus.entries) {
+    for (Ipv6NetworkStatus.Entry entry : networkStatus.entries) {
       this.psStatusEntriesInsert.clearParameters();
       this.psStatusEntriesInsert.setInt(1, statusId);
       this.psStatusEntriesInsert.setString(2, entry.digest);
diff --git a/src/main/java/org/torproject/metrics/stats/ipv6servers/ParsedNetworkStatus.java b/src/main/java/org/torproject/metrics/stats/ipv6servers/Ipv6NetworkStatus.java
similarity index 97%
rename from src/main/java/org/torproject/metrics/stats/ipv6servers/ParsedNetworkStatus.java
rename to src/main/java/org/torproject/metrics/stats/ipv6servers/Ipv6NetworkStatus.java
index f185250..1600d47 100644
--- a/src/main/java/org/torproject/metrics/stats/ipv6servers/ParsedNetworkStatus.java
+++ b/src/main/java/org/torproject/metrics/stats/ipv6servers/Ipv6NetworkStatus.java
@@ -9,7 +9,7 @@ import java.util.List;
 
 /** Data object holding all relevant parts parsed from a (relay or bridge)
  * network status. */
-class ParsedNetworkStatus {
+class Ipv6NetworkStatus {
 
   /** Whether this is a relay network status as opposed to a bridge network
    * status. */
diff --git a/src/main/java/org/torproject/metrics/stats/ipv6servers/ParsedServerDescriptor.java b/src/main/java/org/torproject/metrics/stats/ipv6servers/Ipv6ServerDescriptor.java
similarity index 96%
rename from src/main/java/org/torproject/metrics/stats/ipv6servers/ParsedServerDescriptor.java
rename to src/main/java/org/torproject/metrics/stats/ipv6servers/Ipv6ServerDescriptor.java
index c8d0ceb..3655d3e 100644
--- a/src/main/java/org/torproject/metrics/stats/ipv6servers/ParsedServerDescriptor.java
+++ b/src/main/java/org/torproject/metrics/stats/ipv6servers/Ipv6ServerDescriptor.java
@@ -5,7 +5,7 @@ package org.torproject.metrics.stats.ipv6servers;
 
 /** Data object holding all relevant parts parsed from a (relay or bridge)
  * server descriptor. */
-class ParsedServerDescriptor {
+class Ipv6ServerDescriptor {
 
   /** Hex-encoded SHA-1 server descriptor digest. */
   String digest;
diff --git a/src/main/java/org/torproject/metrics/stats/ipv6servers/Parser.java b/src/main/java/org/torproject/metrics/stats/ipv6servers/Parser.java
index 95b1d5a..a66ad23 100644
--- a/src/main/java/org/torproject/metrics/stats/ipv6servers/Parser.java
+++ b/src/main/java/org/torproject/metrics/stats/ipv6servers/Parser.java
@@ -20,9 +20,9 @@ import java.time.ZoneId;
 class Parser {
 
   /** Parse a (relay or bridge) server descriptor. */
-  ParsedServerDescriptor parseServerDescriptor(
+  Ipv6ServerDescriptor parseServerDescriptor(
       ServerDescriptor serverDescriptor) {
-    ParsedServerDescriptor parsedDescriptor = new ParsedServerDescriptor();
+    Ipv6ServerDescriptor parsedDescriptor = new Ipv6ServerDescriptor();
     parsedDescriptor.digest = serverDescriptor.getDigestSha1Hex();
     for (String orAddress : serverDescriptor.getOrAddresses()) {
       if (StringUtils.countMatches(orAddress, ":") >= 2) {
@@ -48,22 +48,22 @@ class Parser {
   }
 
   /** Parse a relay network status. */
-  ParsedNetworkStatus parseRelayNetworkStatusConsensus(
+  Ipv6NetworkStatus parseRelayNetworkStatusConsensus(
       RelayNetworkStatusConsensus consensus) throws Exception {
     return this.parseStatus(true, consensus.getValidAfterMillis(),
         consensus.getStatusEntries().values());
   }
 
   /** Parse a bridge network status. */
-  ParsedNetworkStatus parseBridgeNetworkStatus(BridgeNetworkStatus status)
+  Ipv6NetworkStatus parseBridgeNetworkStatus(BridgeNetworkStatus status)
       throws Exception {
     return this.parseStatus(false, status.getPublishedMillis(),
         status.getStatusEntries().values());
   }
 
-  private ParsedNetworkStatus parseStatus(boolean isRelay, long timestampMillis,
+  private Ipv6NetworkStatus parseStatus(boolean isRelay, long timestampMillis,
       Iterable<NetworkStatusEntry> entries) {
-    ParsedNetworkStatus parsedStatus = new ParsedNetworkStatus();
+    Ipv6NetworkStatus parsedStatus = new Ipv6NetworkStatus();
     parsedStatus.isRelay = isRelay;
     parsedStatus.timestamp = Instant.ofEpochMilli(timestampMillis)
         .atZone(ZoneId.of("UTC")).toLocalDateTime();
@@ -77,7 +77,7 @@ class Parser {
       if (!entry.getFlags().contains("Running")) {
         continue;
       }
-      ParsedNetworkStatus.Entry parsedEntry = new ParsedNetworkStatus.Entry();
+      Ipv6NetworkStatus.Entry parsedEntry = new Ipv6NetworkStatus.Entry();
       parsedEntry.digest = entry.getDescriptor().toLowerCase();
       if (isRelay) {
         parsedEntry.guard = entry.getFlags().contains("Guard");
diff --git a/src/test/java/org/torproject/metrics/stats/ipv6servers/ParsedNetworkStatusTest.java b/src/test/java/org/torproject/metrics/stats/ipv6servers/Ipv6NetworkStatusTest.java
similarity index 97%
rename from src/test/java/org/torproject/metrics/stats/ipv6servers/ParsedNetworkStatusTest.java
rename to src/test/java/org/torproject/metrics/stats/ipv6servers/Ipv6NetworkStatusTest.java
index c2642b8..9069218 100644
--- a/src/test/java/org/torproject/metrics/stats/ipv6servers/ParsedNetworkStatusTest.java
+++ b/src/test/java/org/torproject/metrics/stats/ipv6servers/Ipv6NetworkStatusTest.java
@@ -28,7 +28,7 @@ import java.util.Arrays;
 import java.util.Collection;
 
 @RunWith(Parameterized.class)
-public class ParsedNetworkStatusTest {
+public class Ipv6NetworkStatusTest {
 
   /** Provide test data. */
   @Parameters
@@ -102,7 +102,7 @@ public class ParsedNetworkStatusTest {
     for (Descriptor descriptor
         : DescriptorSourceFactory.createDescriptorParser().parseDescriptors(
         sb.toString().getBytes(), new File(this.fileName), this.fileName)) {
-      ParsedNetworkStatus parsedNetworkStatus;
+      Ipv6NetworkStatus parsedNetworkStatus;
       if (descriptor instanceof RelayNetworkStatusConsensus) {
         parsedNetworkStatus = new Parser().parseRelayNetworkStatusConsensus(
             (RelayNetworkStatusConsensus) descriptor);
@@ -119,7 +119,7 @@ public class ParsedNetworkStatusTest {
       assertEquals(this.description, this.running, parsedNetworkStatus.running);
       if (null != this.digest) {
         boolean foundEntry = false;
-        for (ParsedNetworkStatus.Entry parsedEntry
+        for (Ipv6NetworkStatus.Entry parsedEntry
             : parsedNetworkStatus.entries) {
           if (this.digest.equals(parsedEntry.digest)) {
             assertEquals(this.description, this.guard, parsedEntry.guard);
diff --git a/src/test/java/org/torproject/metrics/stats/ipv6servers/ParsedServerDescriptorTest.java b/src/test/java/org/torproject/metrics/stats/ipv6servers/Ipv6ServerDescriptorTest.java
similarity index 97%
rename from src/test/java/org/torproject/metrics/stats/ipv6servers/ParsedServerDescriptorTest.java
rename to src/test/java/org/torproject/metrics/stats/ipv6servers/Ipv6ServerDescriptorTest.java
index baff31b..1842315 100644
--- a/src/test/java/org/torproject/metrics/stats/ipv6servers/ParsedServerDescriptorTest.java
+++ b/src/test/java/org/torproject/metrics/stats/ipv6servers/Ipv6ServerDescriptorTest.java
@@ -25,7 +25,7 @@ import java.util.Arrays;
 import java.util.Collection;
 
 @RunWith(Parameterized.class)
-public class ParsedServerDescriptorTest {
+public class Ipv6ServerDescriptorTest {
 
   /** Provide test data. */
   @Parameters
@@ -83,7 +83,7 @@ public class ParsedServerDescriptorTest {
         : DescriptorSourceFactory.createDescriptorParser().parseDescriptors(
         sb.toString().getBytes(), new File(this.fileName), this.fileName)) {
       assertTrue(this.description, descriptor instanceof ServerDescriptor);
-      ParsedServerDescriptor parsedServerDescriptor
+      Ipv6ServerDescriptor parsedServerDescriptor
           = new Parser().parseServerDescriptor((ServerDescriptor) descriptor);
       assertEquals(this.description, this.advertisedBandwidth,
           parsedServerDescriptor.advertisedBandwidth);



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