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):
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:
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)
# 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)
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):
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):
.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)
d.addCallback(_render)
return d
+ def render_problems(self, ctx, data):
+ d = self.download_results()
+ d.addCallback(lambda res: res.server_problems)
+ def _got(server_problems):
+ if not server_problems:
+ return ""
+ l = T.ul()
+ for peerid in sorted(server_problems.keys()):
+ peerid_s = idlib.shortnodeid_b2a(peerid)
+ l[T.li["[%s]: %s" % (peerid_s, server_problems[peerid])]]
+ return T.li["Server Problems:", l]
+ d.addCallback(_got)
+ return d
+
def data_file_size(self, ctx, data):
d = self.download_results()
d.addCallback(lambda res: res.file_size)