remove get_serverid from DownloadStatus.add_block_request and customers
authorZooko O'Whielacronx <zooko@zooko.com>
Mon, 1 Aug 2011 18:53:44 +0000 (11:53 -0700)
committerZooko O'Whielacronx <zooko@zooko.com>
Mon, 1 Aug 2011 18:53:44 +0000 (11:53 -0700)
This is a rebase of a patch Brian originally wrote. I haven't changed the intent of that patch, just ported it to trunk.
refs #1363

src/allmydata/immutable/downloader/share.py
src/allmydata/immutable/downloader/status.py
src/allmydata/web/status.py

index 4fc59035c5c370d981b717a31464fcaee5afb0e3..1f828acee10bb1074b2970eb0bacc4380aab7695 100644 (file)
@@ -734,8 +734,7 @@ class Share:
                          share=repr(self),
                          start=start, length=length,
                          level=log.NOISY, parent=self._lp, umid="sgVAyA")
-            block_ev = ds.add_block_request(self._server.get_serverid(),
-                                            self._shnum,
+            block_ev = ds.add_block_request(self._server, self._shnum,
                                             start, length, now())
             d = self._send_request(start, length)
             d.addCallback(self._got_data, start, length, block_ev, lp)
index 738297ac60f85f97f1764da01ed0ab903609e460..977bf2e18f6a19700b2731031dec242b2568985a 100644 (file)
@@ -116,7 +116,7 @@ class DownloadStatus:
 
         # self.block_requests tracks share-data requests and responses. It is
         # a list of dicts:
-        #  serverid (binary),
+        #  server (instance of IServer)
         #  shnum,
         #  start,length,  (of data requested)
         #  start_time
@@ -168,8 +168,8 @@ class DownloadStatus:
         self.dyhb_requests.append(r)
         return DYHBEvent(r, self)
 
-    def add_block_request(self, serverid, shnum, start, length, when):
-        r = { "serverid": serverid,
+    def add_block_request(self, server, shnum, start, length, when):
+        r = { "server": server,
               "shnum": shnum,
               "start": start,
               "length": length,
index 1d783e52643c6961982e96202e4a313c1ff97832..3633b721dba0a20f5cc824369df8d64312f33976 100644 (file)
@@ -409,7 +409,7 @@ class DownloadStatusPage(DownloadResultsRendererMixin, rend.Page):
         for ev in events:
             # DownloadStatus promises to give us events in temporal order
             ev = ev.copy()
-            ev["serverid"] = base32.b2a(ev["serverid"])
+            ev["serverid"] = base32.b2a(ev["server"].get_serverid())
             if ev["serverid"] not in serverid_to_group:
                 groupnum = len(serverid_to_group)
                 serverid_to_group[ev["serverid"]] = groupnum
@@ -579,12 +579,13 @@ class DownloadStatusPage(DownloadResultsRendererMixin, rend.Page):
                T.th["txtime"], T.th["rxtime"],
                T.th["received"], T.th["RTT"]]]
         for r_ev in self.download_status.block_requests:
+            server = r_ev["server"]
             rtt = None
             if r_ev["finish_time"] is not None:
                 rtt = r_ev["finish_time"] - r_ev["start_time"]
-            serverid_s = idlib.shortnodeid_b2a(r_ev["serverid"])
-            t[T.tr(style="background: %s" % self.color(r_ev["serverid"]))[
-                T.td[serverid_s], T.td[r_ev["shnum"]],
+            color = self.color(server.get_serverid())
+            t[T.tr(style="background: %s" % color)[
+                T.td[server.get_name()], T.td[r_ev["shnum"]],
                 T.td["[%d:+%d]" % (r_ev["start"], r_ev["length"])],
                 T.td[srt(r_ev["start_time"])], T.td[srt(r_ev["finish_time"])],
                 T.td[r_ev["response_length"] or ""],