[tor-commits] [metrics-lib/master] Remove GetTor statistics parsing code.

karsten at torproject.org karsten at torproject.org
Tue Aug 7 11:11:28 UTC 2012


commit ba8cb725d2f4cfb9f1495925d79aeaa7c05b2482
Author: Karsten Loesing <karsten.loesing at gmx.net>
Date:   Tue Aug 7 12:25:42 2012 +0200

    Remove GetTor statistics parsing code.
---
 README                                             |    6 +-
 .../torproject/descriptor/GetTorStatistics.java    |   13 ---
 .../torproject/descriptor/impl/DescriptorImpl.java |    3 -
 .../descriptor/impl/GetTorStatisticsImpl.java      |   78 --------------------
 4 files changed, 3 insertions(+), 97 deletions(-)

diff --git a/README b/README
index 1450048..c8bab00 100644
--- a/README
+++ b/README
@@ -8,9 +8,9 @@ network data and for building services and applications.
 
 The descriptor types supported by DescripTor include relay and bridge
 descriptors which are part of Tor's directory protocol as well as Torperf
-data files, GetTor statistics files, and TorDNSEL's exit lists.  Access to
-these descriptors is unified to facilitate access to publicly available
-data about the Tor network.
+data files and TorDNSEL's exit lists.  Access to these descriptors is
+unified to facilitate access to publicly available data about the Tor
+network.
 
 This API is designed for Java programs that process Tor descriptors in
 batches.  A Java program using this API first sets up a descriptor source
diff --git a/src/org/torproject/descriptor/GetTorStatistics.java b/src/org/torproject/descriptor/GetTorStatistics.java
deleted file mode 100644
index b6ba1e7..0000000
--- a/src/org/torproject/descriptor/GetTorStatistics.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package org.torproject.descriptor;
-
-import java.util.SortedMap;
-
-public interface GetTorStatistics {
-
-  /* Return the date of these GetTor statistics in milliseconds since
-   * 1970-01-01 00:00:00. */
-  public long getDateMillis();
-
-  /* Return the number of downloaded packages. */
-  public SortedMap<String, Integer> getDownloadedPackages();
-}
diff --git a/src/org/torproject/descriptor/impl/DescriptorImpl.java b/src/org/torproject/descriptor/impl/DescriptorImpl.java
index bb6e415..b1e4408 100644
--- a/src/org/torproject/descriptor/impl/DescriptorImpl.java
+++ b/src/org/torproject/descriptor/impl/DescriptorImpl.java
@@ -88,9 +88,6 @@ public abstract class DescriptorImpl implements Descriptor {
     } else if (firstLines.startsWith("@type torperf 1.")) {
       parsedDescriptors.addAll(TorperfResultImpl.parseTorperfResults(
           rawDescriptorBytes, failUnrecognizedDescriptorLines));
-    } else if (firstLines.startsWith("@type gettor 1.")) {
-      parsedDescriptors.addAll(GetTorStatisticsImpl.parseGetTorStatistics(
-          rawDescriptorBytes, failUnrecognizedDescriptorLines));
     } else {
       throw new DescriptorParseException("Could not detect descriptor "
           + "type in descriptor starting with '" + firstLines + "'.");
diff --git a/src/org/torproject/descriptor/impl/GetTorStatisticsImpl.java b/src/org/torproject/descriptor/impl/GetTorStatisticsImpl.java
deleted file mode 100644
index 202cf03..0000000
--- a/src/org/torproject/descriptor/impl/GetTorStatisticsImpl.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/* Copyright 2012 The Tor Project
- * See LICENSE for licensing information */
-package org.torproject.descriptor.impl;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Scanner;
-import java.util.SortedMap;
-import java.util.TreeMap;
-
-import org.torproject.descriptor.Descriptor;
-import org.torproject.descriptor.GetTorStatistics;
-
-public class GetTorStatisticsImpl extends DescriptorImpl
-    implements GetTorStatistics {
-
-  public static List<Descriptor> parseGetTorStatistics(
-      byte[] rawDescriptorBytes, boolean failUnrecognizedDescriptorLines)
-      throws DescriptorParseException {
-    if (rawDescriptorBytes.length == 0) {
-      throw new DescriptorParseException("Descriptor is empty.");
-    }
-    List<Descriptor> parsedDescriptors = new ArrayList<Descriptor>();
-    String descriptorString = new String(rawDescriptorBytes);
-    Scanner s = new Scanner(descriptorString).useDelimiter("\n");
-    while (s.hasNext()) {
-      String line = s.next();
-      if (line.startsWith("@type gettor ")) {
-        String[] parts = line.split(" ");
-        if (parts.length != 3) {
-          throw new DescriptorParseException("Illegal line '" + line
-              + "'.");
-        }
-        String version = parts[2];
-        if (!version.startsWith("1.")) {
-          throw new DescriptorParseException("Unsupported version in "
-              + " line '" + line + "'.");
-        }
-      } else {
-        parsedDescriptors.add(new GetTorStatisticsImpl(line.getBytes(),
-            failUnrecognizedDescriptorLines));
-      }
-    }
-    return parsedDescriptors;
-  }
-
-  protected GetTorStatisticsImpl(byte[] rawDescriptorBytes,
-      boolean failUnrecognizedDescriptorLines)
-      throws DescriptorParseException {
-    super(rawDescriptorBytes, failUnrecognizedDescriptorLines, false);
-    this.parseGetTorStatisticsLine(new String(rawDescriptorBytes));
-  }
-
-  private void parseGetTorStatisticsLine(String line)
-      throws DescriptorParseException {
-    if (line.isEmpty()) {
-      throw new DescriptorParseException("Blank lines are not allowed.");
-    }
-    String[] parts = line.split(" ");
-    if (parts.length < 3) {
-      throw new DescriptorParseException("Illegal GetTor statistics line "
-          + "'" + line + "'.");
-    }
-    this.dateMillis = ParseHelper.parseDateAtIndex(line, parts, 0);
-    this.downloadedPackages = ParseHelper.parseKeyValuePairs(line, parts,
-        2, ":");
-  }
-
-  private long dateMillis;
-  public long getDateMillis() {
-    return this.dateMillis;
-  }
-
-  private SortedMap<String, Integer> downloadedPackages;
-  public SortedMap<String, Integer> getDownloadedPackages() {
-    return new TreeMap<String, Integer>(this.downloadedPackages);
-  }
-}



More information about the tor-commits mailing list