change UploadResults to return IServers, update users to match
This finally changes all callers of get_servermap()/get_sharemap() to accept IServers, and changes UploadResults to provide them.
This commit is contained in:
parent
843739486a
commit
3a1c02cfdf
|
@ -115,12 +115,13 @@ class CiphertextFileNode:
|
|||
prr = CheckResults(cr.uri, cr.storage_index)
|
||||
prr.data = copy.deepcopy(cr.data)
|
||||
|
||||
servers_responding = set(prr.data['servers-responding'])
|
||||
sm = prr.data['sharemap']
|
||||
assert isinstance(sm, DictOfSets), sm
|
||||
sm.update(ur.get_sharemap())
|
||||
servers_responding = set(prr.data['servers-responding'])
|
||||
for shnum, serverids in ur.get_sharemap().items():
|
||||
servers_responding.update(serverids)
|
||||
for shnum, servers in ur.get_sharemap().items():
|
||||
for s in servers:
|
||||
sm.add(shnum, s.get_serverid())
|
||||
servers_responding.add(s.get_serverid())
|
||||
servers_responding = sorted(servers_responding)
|
||||
prr.data['servers-responding'] = servers_responding
|
||||
prr.data['count-shares-good'] = len(sm)
|
||||
|
|
|
@ -216,8 +216,14 @@ class CHKUploadHelper(Referenceable, upload.CHKUploader):
|
|||
hur.uri_extension_hash = v.uri_extension_hash
|
||||
hur.ciphertext_fetched = self._fetcher.get_ciphertext_fetched()
|
||||
hur.preexisting_shares = ur.get_preexisting_shares()
|
||||
hur.sharemap = ur.get_sharemap()
|
||||
hur.servermap = ur.get_servermap()
|
||||
# hur.sharemap needs to be {shnum: set(serverid)}
|
||||
hur.sharemap = {}
|
||||
for shnum, servers in ur.get_sharemap().items():
|
||||
hur.sharemap[shnum] = set([s.get_serverid() for s in servers])
|
||||
# and hur.servermap needs to be {serverid: set(shnum)}
|
||||
hur.servermap = {}
|
||||
for server, shnums in ur.get_servermap().items():
|
||||
hur.servermap[server.get_serverid()] = set(shnums)
|
||||
hur.pushed_shares = ur.get_pushed_shares()
|
||||
hur.file_size = ur.get_file_size()
|
||||
hur.uri_extension_data = ur.get_uri_extension_data()
|
||||
|
|
|
@ -95,17 +95,9 @@ class UploadResults:
|
|||
def get_pushed_shares(self):
|
||||
return self._pushed_shares
|
||||
def get_sharemap(self):
|
||||
# returns {shnum: set(serverid)}
|
||||
sharemap = {}
|
||||
for shnum, servers in self._sharemap.items():
|
||||
sharemap[shnum] = set([s.get_serverid() for s in servers])
|
||||
return sharemap
|
||||
return self._sharemap
|
||||
def get_servermap(self):
|
||||
# returns {serverid: set(shnum)}
|
||||
servermap = {}
|
||||
for server, shnums in self._servermap.items():
|
||||
servermap[server.get_serverid()] = set(shnums)
|
||||
return servermap
|
||||
return self._servermap
|
||||
def get_timings(self):
|
||||
return self._timings
|
||||
def get_uri_extension_data(self):
|
||||
|
|
|
@ -1952,14 +1952,14 @@ class IUploadResults(Interface):
|
|||
def get_pushed_shares():
|
||||
"""Return the number of shares that were uploaded."""
|
||||
def get_sharemap():
|
||||
"""Return a dict mapping share identifier to set of serverids (binary
|
||||
strings). This indicates which servers were given which shares. For
|
||||
"""Return a dict mapping share identifier to set of IServer
|
||||
instances. 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."""
|
||||
def get_servermap():
|
||||
"""Return dict mapping server peerid to a set of share numbers."""
|
||||
"""Return dict mapping IServer instance to a set of share numbers."""
|
||||
def get_timings():
|
||||
"""Return dict of timing information, mapping name to seconds. All
|
||||
times are floats:
|
||||
|
|
|
@ -37,9 +37,9 @@ class UploadResultsRendererMixin(RateAndTimeMixin):
|
|||
if sharemap is None:
|
||||
return "None"
|
||||
l = T.ul()
|
||||
for shnum, peerids in sorted(sharemap.items()):
|
||||
peerids = ', '.join([idlib.shortnodeid_b2a(i) for i in peerids])
|
||||
l[T.li["%d -> placed on [%s]" % (shnum, peerids)]]
|
||||
for shnum, servers in sorted(sharemap.items()):
|
||||
server_names = ', '.join([s.get_name() for s in servers])
|
||||
l[T.li["%d -> placed on [%s]" % (shnum, server_names)]]
|
||||
return l
|
||||
d.addCallback(_render)
|
||||
return d
|
||||
|
@ -51,13 +51,10 @@ class UploadResultsRendererMixin(RateAndTimeMixin):
|
|||
if servermap is None:
|
||||
return "None"
|
||||
l = T.ul()
|
||||
for peerid in sorted(servermap.keys()):
|
||||
peerid_s = idlib.shortnodeid_b2a(peerid)
|
||||
shares_s = ",".join(["#%d" % shnum
|
||||
for shnum in servermap[peerid]])
|
||||
l[T.li["[%s] got share%s: %s" % (peerid_s,
|
||||
plural(servermap[peerid]),
|
||||
shares_s)]]
|
||||
for server, shnums in sorted(servermap.items()):
|
||||
shares_s = ",".join(["#%d" % shnum for shnum in shnums])
|
||||
l[T.li["[%s] got share%s: %s" % (server.get_name(),
|
||||
plural(shnums), shares_s)]]
|
||||
return l
|
||||
d.addCallback(_render)
|
||||
return d
|
||||
|
|
Loading…
Reference in New Issue