]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
control: add measure_peer_response_time(), to estimate RTT for the mesh
authorBrian Warner <warner@allmydata.com>
Wed, 26 Sep 2007 19:21:15 +0000 (12:21 -0700)
committerBrian Warner <warner@allmydata.com>
Wed, 26 Sep 2007 19:21:15 +0000 (12:21 -0700)
src/allmydata/control.py
src/allmydata/interfaces.py
src/allmydata/test/test_system.py

index 7aca472fe422425ac3f2641cd0b6c36bc04fe2c1..257da38314a5098cec3654b357af0bc89f9c3ddb 100644 (file)
@@ -56,6 +56,24 @@ class ControlServer(Referenceable, service.Service, testutil.PollMixin):
     def remote_get_memory_usage(self):
         return get_memory_usage()
 
+    def remote_measure_peer_response_time(self):
+        results = {}
+        everyone = list(self.parent.introducer_client.get_all_peers())
+        d = self._do_one_ping(None, everyone, results)
+        return d
+    def _do_one_ping(self, res, everyone_left, results):
+        if not everyone_left:
+            return results
+        peerid, connection = everyone_left.pop(0)
+        start = time.time()
+        d = connection.callRemote("get_nodeid")
+        def _done(ignored):
+            stop = time.time()
+            results[peerid] = stop - start
+        d.addCallback(_done)
+        d.addCallback(self._do_one_ping, everyone_left, results)
+        return d
+
 class SpeedTest:
     def __init__(self, parent, count, size):
         self.parent = parent
index efd6962f36902788d56032b8e2c353fc77e5d7e6..e1ac9e95660be3f5d193098357037a2937f6d74e 100644 (file)
@@ -1062,3 +1062,13 @@ class RIControlClient(RemoteInterface):
         Returns a tuple of (upload_time, download_time).
         """
         return (float, float)
+
+    def measure_peer_response_time():
+        """Send a short message to each connected peer, and measure the time
+        it takes for them to respond to it. This is a rough measure of the
+        application-level round trip time.
+
+        @return: a dictionary mapping peerid to a float (RTT time in seconds)
+        """
+
+        return DictOf(Nodeid, float)
index 38784cca1207ae64558850388c8d52f8c916a087..7a3d37019b8bef4fd090766e5beaec42aaf51968 100644 (file)
@@ -687,5 +687,6 @@ class SystemTest(testutil.SignalMixin, unittest.TestCase):
         d.addCallback(lambda res: rref.callRemote("speed_test", 1, 200))
         if sys.platform == "linux2":
             d.addCallback(lambda res: rref.callRemote("get_memory_usage"))
+        d.addCallback(lambda res: rref.callRemote("measure_peer_response_time"))
         return d