From: Zooko O'Whielacronx Date: Mon, 1 Aug 2011 18:53:44 +0000 (-0700) Subject: remove get_serverid from DownloadStatus.add_block_request and customers X-Git-Url: https://git.rkrishnan.org/%5B/frontends/flags/%22doc.html/something?a=commitdiff_plain;h=dc668754793087a9614795e57797e7a787a0c675;p=tahoe-lafs%2Ftahoe-lafs.git remove get_serverid from DownloadStatus.add_block_request and customers 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 --- diff --git a/src/allmydata/immutable/downloader/share.py b/src/allmydata/immutable/downloader/share.py index 4fc59035..1f828ace 100644 --- a/src/allmydata/immutable/downloader/share.py +++ b/src/allmydata/immutable/downloader/share.py @@ -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) diff --git a/src/allmydata/immutable/downloader/status.py b/src/allmydata/immutable/downloader/status.py index 738297ac..977bf2e1 100644 --- a/src/allmydata/immutable/downloader/status.py +++ b/src/allmydata/immutable/downloader/status.py @@ -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, diff --git a/src/allmydata/web/status.py b/src/allmydata/web/status.py index 1d783e52..3633b721 100644 --- a/src/allmydata/web/status.py +++ b/src/allmydata/web/status.py @@ -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 ""],