From: Brian Warner Date: Tue, 4 Mar 2008 03:30:35 +0000 (-0700) Subject: webish: download-results: add server_problems X-Git-Tag: allmydata-tahoe-0.9.0~82 X-Git-Url: https://git.rkrishnan.org/listings/readonly?a=commitdiff_plain;h=886ef2233518a0ebdf844147ec13c0f2feb997cf;p=tahoe-lafs%2Ftahoe-lafs.git webish: download-results: add server_problems --- diff --git a/src/allmydata/download.py b/src/allmydata/download.py index 91c163db..e96bc617 100644 --- a/src/allmydata/download.py +++ b/src/allmydata/download.py @@ -247,10 +247,11 @@ class BlockDownloader: I am a child of the SegmentDownloader. """ - def __init__(self, vbucket, blocknum, parent): + def __init__(self, vbucket, blocknum, parent, results): self.vbucket = vbucket self.blocknum = blocknum self.parent = parent + self.results = results self._log_number = self.parent.log("starting block %d" % blocknum) def log(self, msg, parent=None): @@ -272,6 +273,9 @@ class BlockDownloader: def _got_block_error(self, f, lognum): self.log("BlockDownloader[%d] got error: %s" % (self.blocknum, f), parent=lognum) + if self.results: + peerid = self.vbucket.bucket.get_peerid() + self.results.server_problems[peerid] = str(f) self.parent.bucket_failed(self.vbucket) class SegmentDownloader: @@ -281,11 +285,12 @@ class SegmentDownloader: I am a child of the FileDownloader. """ - def __init__(self, parent, segmentnumber, needed_shares): + def __init__(self, parent, segmentnumber, needed_shares, results): self.parent = parent self.segmentnumber = segmentnumber self.needed_blocks = needed_shares self.blocks = {} # k: blocknum, v: data + self.results = results self._log_number = self.parent.log("starting segment %d" % segmentnumber) @@ -324,7 +329,7 @@ class SegmentDownloader: # through it. downloaders = [] for blocknum, vbucket in active_buckets.iteritems(): - bd = BlockDownloader(vbucket, blocknum, self) + bd = BlockDownloader(vbucket, blocknum, self, self.results) downloaders.append(bd) l = [bd.start(self.segmentnumber) for bd in downloaders] return defer.DeferredList(l, fireOnOneErrback=True) @@ -791,7 +796,8 @@ class FileDownloader: 100.0 * segnum / self._total_segments)) # memory footprint: when the SegmentDownloader finishes pulling down # all shares, we have 1*segment_size of usage. - segmentdler = SegmentDownloader(self, segnum, self._num_needed_shares) + segmentdler = SegmentDownloader(self, segnum, self._num_needed_shares, + self._results) started = time.time() d = segmentdler.start() def _finished_fetching(res): @@ -845,7 +851,8 @@ class FileDownloader: self.log("downloading seg#%d of %d (%d%%)" % (segnum, self._total_segments, 100.0 * segnum / self._total_segments)) - segmentdler = SegmentDownloader(self, segnum, self._num_needed_shares) + segmentdler = SegmentDownloader(self, segnum, self._num_needed_shares, + self._results) started = time.time() d = segmentdler.start() def _finished_fetching(res): diff --git a/src/allmydata/interfaces.py b/src/allmydata/interfaces.py index 3bcb907d..37c0efd0 100644 --- a/src/allmydata/interfaces.py +++ b/src/allmydata/interfaces.py @@ -1309,9 +1309,9 @@ class IDownloadResults(Interface): .file_size : the size of the file, in bytes .servers_used : set of server peerids that were used during download - .server_problems : dict mapping server peerid to a problem string. Only - servers that had problems (bad hashes, disconnects) are - listed here. + .server_problems : dict mapping server peerid to a problem string. Only + servers that had problems (bad hashes, disconnects) are + listed here. .servermap : dict mapping server peerid to a set of share numbers. Only servers that had any shares are listed here. .timings : dict of timing information, mapping name to seconds (float) diff --git a/src/allmydata/storage.py b/src/allmydata/storage.py index f3705181..b63a441d 100644 --- a/src/allmydata/storage.py +++ b/src/allmydata/storage.py @@ -1207,6 +1207,9 @@ class ReadBucketProxy: self._si_s = storage_index_s self._started = False + def get_peerid(self): + return self._peerid + def __repr__(self): peerid_s = idlib.shortnodeid_b2a(self._peerid) return "" % (peerid_s, diff --git a/src/allmydata/test/test_encode.py b/src/allmydata/test/test_encode.py index eb3d50df..cfd3bbf7 100644 --- a/src/allmydata/test/test_encode.py +++ b/src/allmydata/test/test_encode.py @@ -31,6 +31,9 @@ class FakeBucketWriterProxy: self.share_hashes = None self.closed = False + def get_peerid(self): + return "peerid" + def startIfNecessary(self): return defer.succeed(self) def start(self): diff --git a/src/allmydata/web/download-status.xhtml b/src/allmydata/web/download-status.xhtml index d60e7efc..a38f54ff 100644 --- a/src/allmydata/web/download-status.xhtml +++ b/src/allmydata/web/download-status.xhtml @@ -24,6 +24,7 @@