From: Brian Warner Date: Wed, 26 Sep 2007 19:21:15 +0000 (-0700) Subject: control: add measure_peer_response_time(), to estimate RTT for the mesh X-Git-Tag: allmydata-tahoe-0.6.1~77 X-Git-Url: https://git.rkrishnan.org/components/com_hotproperty/COPYING.TGPPL.html?a=commitdiff_plain;h=c301b41f508738152dc2a1b937fc3a7831015021;p=tahoe-lafs%2Ftahoe-lafs.git control: add measure_peer_response_time(), to estimate RTT for the mesh --- diff --git a/src/allmydata/control.py b/src/allmydata/control.py index 7aca472f..257da383 100644 --- a/src/allmydata/control.py +++ b/src/allmydata/control.py @@ -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 diff --git a/src/allmydata/interfaces.py b/src/allmydata/interfaces.py index efd6962f..e1ac9e95 100644 --- a/src/allmydata/interfaces.py +++ b/src/allmydata/interfaces.py @@ -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) diff --git a/src/allmydata/test/test_system.py b/src/allmydata/test/test_system.py index 38784cca..7a3d3701 100644 --- a/src/allmydata/test/test_system.py +++ b/src/allmydata/test/test_system.py @@ -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