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

[tor-commits] [stem/master] Dropping measurement *_line attributes



commit 2ddffb3d961bcc01829ad58c96b8fa236a35cfff
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Sat May 12 12:42:25 2012 -0700

    Dropping measurement *_line attributes
    
    Removing attributes like read_history_line which contained the raw value for
    the read-history line. These are left over from when I made no effort to parse
    the line, and are useless since we have their parsed values.
    
    Minor changes to our pydocs so these related items are better labeled.
---
 stem/descriptor/extrainfo_descriptor.py       |   36 +++++++++----------------
 stem/descriptor/server_descriptor.py          |   21 +++++---------
 test/integ/descriptor/extrainfo_descriptor.py |   12 --------
 test/integ/descriptor/server_descriptor.py    |   10 +-----
 test/unit/descriptor/server_descriptor.py     |   14 +++------
 5 files changed, 28 insertions(+), 65 deletions(-)

diff --git a/stem/descriptor/extrainfo_descriptor.py b/stem/descriptor/extrainfo_descriptor.py
index a8f7961..a9bbfec 100644
--- a/stem/descriptor/extrainfo_descriptor.py
+++ b/stem/descriptor/extrainfo_descriptor.py
@@ -145,15 +145,14 @@ class ExtraInfoDescriptor(stem.descriptor.Descriptor):
     geoip_db_digest (str)    - sha1 of geoIP database file
     signature (str)          - signature for this extrainfo descriptor (*)
     
-    read_history_line (str)  - bytes read for relayed traffic
-    read_history_end (datetime.datetime) - end of the sampling interval
-    read_history_interval (int) - seconds per interval
-    read_history_values (list) - bytes read during each interval (*)
-    
-    write_history_line (str) - bytes written for relayed traffic
-    write_history_end (datetime.datetime) - end of the sampling interval
-    write_history_interval (int) - seconds per interval
-    write_history_values (list) - bytes written during each interval (*)
+    Bytes read/written for relayed traffic
+      read_history_end (datetime.datetime) - end of the sampling interval
+      read_history_interval (int) - seconds per interval
+      read_history_values (list) - bytes read during each interval (*)
+      
+      write_history_end (datetime.datetime) - end of the sampling interval
+      write_history_interval (int) - seconds per interval
+      write_history_values (list) - bytes written during each interval (*)
   
   Directory Mirror Attributes:
     dirreq_stats_end (datetime.datetime) - end of the period where directory
@@ -161,12 +160,11 @@ class ExtraInfoDescriptor(stem.descriptor.Descriptor):
     dirreq_stats_interval (int) - length in seconds of the interval where
         directory stats were gathered
     
-    dir_read_history_line (str) - bytes read for directory mirroring
-    dir_read_history_end (datetime.datetime) - end of the sampling interval
-    dir_read_history_interval (int) - seconds per interval
-    dir_read_history_values (list) - bytes read during each interval (*)
-    
-    dir_write_history_line (str) - bytes written for directory mirroring
+    Bytes read/written for directory mirroring
+      dir_read_history_end (datetime.datetime) - end of the sampling interval
+      dir_read_history_interval (int) - seconds per interval
+      dir_read_history_values (list) - bytes read during each interval (*)
+      
     dir_write_history_end (datetime.datetime) - end of the sampling interval
     dir_write_history_interval (int) - seconds per interval
     dir_write_history_values (list) - bytes read during each interval (*)
@@ -211,12 +209,10 @@ class ExtraInfoDescriptor(stem.descriptor.Descriptor):
     self.geoip_db_digest = None
     self.signature = None
     
-    self.read_history_line = None
     self.read_history_end = None
     self.read_history_interval = None
     self.read_history_values = []
     
-    self.write_history_line = None
     self.write_history_end = None
     self.write_history_interval = None
     self.write_history_values = []
@@ -224,12 +220,10 @@ class ExtraInfoDescriptor(stem.descriptor.Descriptor):
     self.dirreq_stats_end = None
     self.dirreq_stats_interval = None
     
-    self.dir_read_history_line = None
     self.dir_read_history_end = None
     self.dir_read_history_interval = None
     self.dir_read_history_values = []
     
-    self.dir_write_history_line = None
     self.dir_write_history_end = None
     self.dir_write_history_interval = None
     self.dir_write_history_values = []
@@ -376,22 +370,18 @@ class ExtraInfoDescriptor(stem.descriptor.Descriptor):
             raise ValueError("%s line has non-numeric values: %s" % (keyword, line))
           
           if keyword == "read-history":
-            self.read_history_line = value
             self.read_history_end = timestamp
             self.read_history_interval = interval
             self.read_history_values = history_values
           elif keyword == "write-history":
-            self.write_history_line = value
             self.write_history_end = timestamp
             self.write_history_interval = interval
             self.write_history_values = history_values
           elif keyword == "dirreq-read-history":
-            self.dir_read_history_line = value
             self.dir_read_history_end = timestamp
             self.dir_read_history_interval = interval
             self.dir_read_history_values = history_values
           elif keyword == "dirreq-write-history":
-            self.dir_write_history_line = value
             self.dir_write_history_end = timestamp
             self.dir_write_history_interval = interval
             self.dir_write_history_values = history_values
diff --git a/stem/descriptor/server_descriptor.py b/stem/descriptor/server_descriptor.py
index 2963a53..7e16c77 100644
--- a/stem/descriptor/server_descriptor.py
+++ b/stem/descriptor/server_descriptor.py
@@ -167,15 +167,14 @@ class ServerDescriptor(stem.descriptor.Descriptor):
     observed_bandwidth (int) - estimated capacity of the relay based on usage in bytes/s (*)
     eventdns (bool)          - (deprecated) always unset (*)
     
-    read_history_line (str)  - (deprecated) bytes read for relayed traffic
-    read_history_end (datetime.datetime) - (deprecated) end of the sampling interval
-    read_history_interval (int) - (deprecated) seconds per interval
-    read_history_values (list) - (deprecated) bytes read during each interval (*)
-    
-    write_history_line (str) - (deprecated) bytes written for relayed traffic
-    write_history_end (datetime.datetime) - (deprecated) end of the sampling interval
-    write_history_interval (int) - (deprecated) seconds per interval
-    write_history_values (list) - (deprecated) bytes written during each interval (*)
+    Deprecated, moved to extra-info descriptor...
+      read_history_end (datetime.datetime) - end of the sampling interval
+      read_history_interval (int) - seconds per interval
+      read_history_values (list) - bytes read during each interval (*)
+      
+      write_history_end (datetime.datetime) - end of the sampling interval
+      write_history_interval (int) - seconds per interval
+      write_history_values (list) - bytes written during each interval (*)
     
     (*) required fields, others are left as None if undefined
   """
@@ -227,12 +226,10 @@ class ServerDescriptor(stem.descriptor.Descriptor):
     self.observed_bandwidth = None
     self.eventdns = True
     
-    self.read_history_line = None
     self.read_history_end = None
     self.read_history_interval = None
     self.read_history_values = []
     
-    self.write_history_line = None
     self.write_history_end = None
     self.write_history_interval = None
     self.write_history_values = []
@@ -481,12 +478,10 @@ class ServerDescriptor(stem.descriptor.Descriptor):
             raise ValueError("%s line has non-numeric values: %s" % (keyword, line))
           
           if keyword == "read-history":
-            self.read_history_line = value
             self.read_history_end = timestamp
             self.read_history_interval = interval
             self.read_history_values = history_values
           else:
-            self.write_history_line = value
             self.write_history_end = timestamp
             self.write_history_interval = interval
             self.write_history_values = history_values
diff --git a/test/integ/descriptor/extrainfo_descriptor.py b/test/integ/descriptor/extrainfo_descriptor.py
index 7a041d0..75b26e0 100644
--- a/test/integ/descriptor/extrainfo_descriptor.py
+++ b/test/integ/descriptor/extrainfo_descriptor.py
@@ -49,27 +49,15 @@ k0d2aofcVbHr4fPQOSST0LXDrhFl5Fqo5um296zpJGvRUeO6S44U/EfJAGShtqWw
     # dirreq-write-history lines are pretty long so just checking
     # the initial contents for the line and parsed values.
     
-    read_start = "2012-05-05 17:02:45 (900 s) 3309568,9216,41984"
-    self.assertTrue(desc.read_history_line.startswith(read_start))
-    
     read_values_start = [3309568, 9216, 41984, 27648, 123904]
     self.assertEquals(read_values_start, desc.read_history_values[:5])
     
-    write_start = "2012-05-05 17:02:45 (900 s) 1082368,19456,50176,272384"
-    self.assertTrue(desc.write_history_line.startswith(write_start))
-    
     write_values_start = [1082368, 19456, 50176, 272384, 485376]
     self.assertEquals(write_values_start, desc.write_history_values[:5])
     
-    dir_read_start = "2012-05-05 17:02:45 (900 s) 0,0,0,0,33792,27648,48128"
-    self.assertTrue(desc.dir_read_history_line.startswith(dir_read_start))
-    
     dir_read_values_start = [0, 0, 0, 0, 33792, 27648, 48128]
     self.assertEquals(dir_read_values_start, desc.dir_read_history_values[:7])
     
-    dir_write_start = "2012-05-05 17:02:45 (900 s) 0,0,0,227328,349184"
-    self.assertTrue(desc.dir_write_history_line.startswith(dir_write_start))
-    
     dir_write_values_start = [0, 0, 0, 227328, 349184, 382976, 738304]
     self.assertEquals(dir_write_values_start, desc.dir_write_history_values[:7])
   
diff --git a/test/integ/descriptor/server_descriptor.py b/test/integ/descriptor/server_descriptor.py
index 945d147..d7b5c14 100644
--- a/test/integ/descriptor/server_descriptor.py
+++ b/test/integ/descriptor/server_descriptor.py
@@ -133,15 +133,9 @@ Qlx9HNCqCY877ztFRC624ja2ql6A2hBcuoYMbkHjcQ4=
     # The read-history and write-history lines are pretty long so just checking
     # the initial contents for the line and parsed values.
     
-    read_start = "2005-12-16 18:00:48 (900 s) 20774,489973,510022"
-    self.assertTrue(desc.read_history_line.startswith(read_start))
-    
     read_values_start = [20774, 489973, 510022, 511163, 20949]
     self.assertEquals(read_values_start, desc.read_history_values[:5])
     
-    write_start = "2005-12-16 18:00:48 (900 s) 81,8848,8927,8927"
-    self.assertTrue(desc.write_history_line.startswith(write_start))
-    
     write_values_start = [81, 8848, 8927, 8927, 83, 8848, 8931, 8929, 81, 8846]
     self.assertEquals(write_values_start, desc.write_history_values[:10])
   
@@ -164,8 +158,8 @@ Qlx9HNCqCY877ztFRC624ja2ql6A2hBcuoYMbkHjcQ4=
     with open(descriptor_path) as descriptor_file:
       for desc in stem.descriptor.server_descriptor.parse_file(descriptor_file):
         # the following attributes should be deprecated, and not appear in the wild
-        self.assertEquals(None, desc.read_history_line)
-        self.assertEquals(None, desc.write_history_line)
+        self.assertEquals(None, desc.read_history_end)
+        self.assertEquals(None, desc.write_history_end)
         self.assertEquals(True, desc.eventdns)
         self.assertEquals(0, desc.socks_port)
         
diff --git a/test/unit/descriptor/server_descriptor.py b/test/unit/descriptor/server_descriptor.py
index 63fd89d..e381318 100644
--- a/test/unit/descriptor/server_descriptor.py
+++ b/test/unit/descriptor/server_descriptor.py
@@ -235,19 +235,16 @@ class TestServerDescriptor(unittest.TestCase):
       desc = RelayDescriptor(desc_text)
       
       if field == "read-history":
-        attr = (desc.read_history_line, desc.read_history_end,
-          desc.read_history_interval, desc.read_history_values)
+        attr = (desc.read_history_end, desc.read_history_interval, desc.read_history_values)
       else:
-        attr = (desc.write_history_line, desc.write_history_end,
-          desc.write_history_interval, desc.write_history_values)
+        attr = (desc.write_history_end, desc.write_history_interval, desc.write_history_values)
       
       expected_end = datetime.datetime(2005, 12, 16, 18, 0, 48)
       expected_values = [81, 8848, 8927, 8927, 83, 8848]
       
-      self.assertEquals(value, attr[0])
-      self.assertEquals(expected_end, attr[1])
-      self.assertEquals(900, attr[2])
-      self.assertEquals(expected_values, attr[3])
+      self.assertEquals(expected_end, attr[0])
+      self.assertEquals(900, attr[1])
+      self.assertEquals(expected_values, attr[2])
   
   def test_read_history_empty(self):
     """
@@ -257,7 +254,6 @@ class TestServerDescriptor(unittest.TestCase):
     value = "2005-12-17 01:23:11 (900 s) "
     desc_text = _make_descriptor({"opt read-history": value})
     desc = RelayDescriptor(desc_text)
-    self.assertEquals(value, desc.read_history_line)
     self.assertEquals(datetime.datetime(2005, 12, 17, 1, 23, 11), desc.read_history_end)
     self.assertEquals(900, desc.read_history_interval)
     self.assertEquals([], desc.read_history_values)



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