immutable: redefine the "sharemap" member of the upload results to be a map from shnum to set of serverids
It used to be a map from shnum to a string saying "placed this share on XYZ server". The new definition is more in keeping with the "sharemap" object that results from immutable file checking and repair, and it is more useful to the repairer, which is a consumer of immutable upload results.
This commit is contained in:
parent
ef60e85ec6
commit
6e3396fb88
|
@ -48,8 +48,8 @@ class UploadResults(Copyable, RemoteCopy):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.timings = {} # dict of name to number of seconds
|
self.timings = {} # dict of name to number of seconds
|
||||||
self.sharemap = {} # dict of shnum to placement string
|
self.sharemap = {} # k: shnum, v: set(serverid)
|
||||||
self.servermap = {} # dict of peerid to set(shnums)
|
self.servermap = {} # k: serverid, v: set(shnum)
|
||||||
self.file_size = None
|
self.file_size = None
|
||||||
self.ciphertext_fetched = None # how much the helper fetched
|
self.ciphertext_fetched = None # how much the helper fetched
|
||||||
self.uri = None
|
self.uri = None
|
||||||
|
@ -654,6 +654,9 @@ class CHKUploader:
|
||||||
self._upload_status.set_active(True)
|
self._upload_status.set_active(True)
|
||||||
self._upload_status.set_results(self._results)
|
self._upload_status.set_results(self._results)
|
||||||
|
|
||||||
|
# locate_all_shareholders() will create the following attribute:
|
||||||
|
# self._peer_trackers = {} # k: shnum, v: instance of PeerTracker
|
||||||
|
|
||||||
def log(self, *args, **kwargs):
|
def log(self, *args, **kwargs):
|
||||||
if "parent" not in kwargs:
|
if "parent" not in kwargs:
|
||||||
kwargs["parent"] = self._log_number
|
kwargs["parent"] = self._log_number
|
||||||
|
@ -735,22 +738,16 @@ class CHKUploader:
|
||||||
"""
|
"""
|
||||||
self.log("_send_shares, used_peers is %s" % (used_peers,))
|
self.log("_send_shares, used_peers is %s" % (used_peers,))
|
||||||
# record already-present shares in self._results
|
# record already-present shares in self._results
|
||||||
for (shnum, peerid) in already_peers.items():
|
|
||||||
peerid_s = idlib.shortnodeid_b2a(peerid)
|
|
||||||
self._results.sharemap[shnum] = "Found on [%s]" % peerid_s
|
|
||||||
if peerid not in self._results.servermap:
|
|
||||||
self._results.servermap[peerid] = set()
|
|
||||||
self._results.servermap[peerid].add(shnum)
|
|
||||||
self._results.preexisting_shares = len(already_peers)
|
self._results.preexisting_shares = len(already_peers)
|
||||||
|
|
||||||
self._sharemap = {}
|
self._peer_trackers = {} # k: shnum, v: instance of PeerTracker
|
||||||
for peer in used_peers:
|
for peer in used_peers:
|
||||||
assert isinstance(peer, PeerTracker)
|
assert isinstance(peer, PeerTracker)
|
||||||
buckets = {}
|
buckets = {}
|
||||||
for peer in used_peers:
|
for peer in used_peers:
|
||||||
buckets.update(peer.buckets)
|
buckets.update(peer.buckets)
|
||||||
for shnum in peer.buckets:
|
for shnum in peer.buckets:
|
||||||
self._sharemap[shnum] = peer
|
self._peer_trackers[shnum] = peer
|
||||||
assert len(buckets) == sum([len(peer.buckets) for peer in used_peers])
|
assert len(buckets) == sum([len(peer.buckets) for peer in used_peers])
|
||||||
encoder.set_shareholders(buckets)
|
encoder.set_shareholders(buckets)
|
||||||
|
|
||||||
|
@ -758,13 +755,11 @@ class CHKUploader:
|
||||||
""" Returns a Deferred that will fire with the UploadResults instance. """
|
""" Returns a Deferred that will fire with the UploadResults instance. """
|
||||||
r = self._results
|
r = self._results
|
||||||
for shnum in self._encoder.get_shares_placed():
|
for shnum in self._encoder.get_shares_placed():
|
||||||
peer_tracker = self._sharemap[shnum]
|
peer_tracker = self._peer_trackers[shnum]
|
||||||
peerid = peer_tracker.peerid
|
peerid = peer_tracker.peerid
|
||||||
peerid_s = idlib.shortnodeid_b2a(peerid)
|
peerid_s = idlib.shortnodeid_b2a(peerid)
|
||||||
r.sharemap[shnum] = "Placed on [%s]" % peerid_s
|
r.sharemap.setdefault(shnum, set()).add(peerid)
|
||||||
if peerid not in r.servermap:
|
r.servermap.setdefault(peerid, set()).add(shnum)
|
||||||
r.servermap[peerid] = set()
|
|
||||||
r.servermap[peerid].add(shnum)
|
|
||||||
r.pushed_shares = len(self._encoder.get_shares_placed())
|
r.pushed_shares = len(self._encoder.get_shares_placed())
|
||||||
now = time.time()
|
now = time.time()
|
||||||
r.file_size = self._encoder.file_size
|
r.file_size = self._encoder.file_size
|
||||||
|
|
|
@ -1460,7 +1460,13 @@ class IUploadResults(Interface):
|
||||||
.file_size : the size of the file, in bytes
|
.file_size : the size of the file, in bytes
|
||||||
.uri : the CHK read-cap for the file
|
.uri : the CHK read-cap for the file
|
||||||
.ciphertext_fetched : how many bytes were fetched by the helper
|
.ciphertext_fetched : how many bytes were fetched by the helper
|
||||||
.sharemap : dict mapping share number to placement string
|
.renamed_sharemap: dict mapping share identifier to set of serverids
|
||||||
|
(binary strings). This indicates which servers were given
|
||||||
|
which shares. For immutable files, the shareid is an
|
||||||
|
integer (the share number, from 0 to N-1). For mutable
|
||||||
|
files, it is a string of the form 'seq%d-%s-sh%d',
|
||||||
|
containing the sequence number, the roothash, and the
|
||||||
|
share number.
|
||||||
.servermap : dict mapping server peerid to a set of share numbers
|
.servermap : dict mapping server peerid to a set of share numbers
|
||||||
.timings : dict of timing information, mapping name to seconds (float)
|
.timings : dict of timing information, mapping name to seconds (float)
|
||||||
total : total upload time, start to finish
|
total : total upload time, start to finish
|
||||||
|
|
|
@ -46,8 +46,10 @@ class UploadResultsRendererMixin(RateAndTimeMixin):
|
||||||
if sharemap is None:
|
if sharemap is None:
|
||||||
return "None"
|
return "None"
|
||||||
l = T.ul()
|
l = T.ul()
|
||||||
for shnum in sorted(sharemap.keys()):
|
for shnum, peerids in sorted(sharemap.items()):
|
||||||
l[T.li["%d -> %s" % (shnum, sharemap[shnum])]]
|
for peerid in peerids:
|
||||||
|
peerid_s = idlib.shortnodeid_b2a(peerid)
|
||||||
|
l[T.li["%d -> %s" % (shnum, peerid_s)]]
|
||||||
return l
|
return l
|
||||||
d.addCallback(_render)
|
d.addCallback(_render)
|
||||||
return d
|
return d
|
||||||
|
|
Loading…
Reference in New Issue