From: Daira Hopwood Date: Thu, 5 Sep 2013 16:53:54 +0000 (+0100) Subject: Wed Apr 4 20:05:31 BST 2012 Brian Warner X-Git-Url: https://git.rkrishnan.org/simplejson/components/%22file:/frontends/webapi.rst?a=commitdiff_plain;h=d40dba9f567f068f445157bb83799ee3beb583c7;p=tahoe-lafs%2Ftahoe-lafs.git Wed Apr 4 20:05:31 BST 2012 Brian Warner * checker.py: minor simplifications --- diff --git a/src/allmydata/immutable/checker.py b/src/allmydata/immutable/checker.py index ad7931b9..73ebc1ec 100644 --- a/src/allmydata/immutable/checker.py +++ b/src/allmydata/immutable/checker.py @@ -737,25 +737,26 @@ class Checker(log.PrefixingLogMixin): return d def _format_results(self, results): - cr = CheckResults(self._verifycap, self._verifycap.get_storage_index()) + SI = self._verifycap.get_storage_index() + cr = CheckResults(self._verifycap, SI) d = {} d['count-shares-needed'] = self._verifycap.needed_shares d['count-shares-expected'] = self._verifycap.total_shares verifiedshares = dictutil.DictOfSets() # {sharenum: set(serverid)} servers = {} # {serverid: set(sharenums)} - corruptsharelocators = [] # (serverid, storageindex, sharenum) - incompatiblesharelocators = [] # (serverid, storageindex, sharenum) - - for theseverifiedshares, thisserver, thesecorruptshares, theseincompatibleshares, thisresponded in results: - thisserverid = thisserver.get_serverid() - servers.setdefault(thisserverid, set()).update(theseverifiedshares) - for sharenum in theseverifiedshares: - verifiedshares.setdefault(sharenum, set()).add(thisserverid) - for sharenum in thesecorruptshares: - corruptsharelocators.append((thisserverid, self._verifycap.get_storage_index(), sharenum)) - for sharenum in theseincompatibleshares: - incompatiblesharelocators.append((thisserverid, self._verifycap.get_storage_index(), sharenum)) + corruptshare_locators = [] # (serverid, storageindex, sharenum) + incompatibleshare_locators = [] # (serverid, storageindex, sharenum) + + for verified, server, corrupt, incompatible, responded in results: + server_id = server.get_serverid() + servers.setdefault(server_id, set()).update(verified) + for sharenum in verified: + verifiedshares.setdefault(sharenum, set()).add(server_id) + for sharenum in corrupt: + corruptshare_locators.append((server_id, SI, sharenum)) + for sharenum in incompatible: + incompatibleshare_locators.append((server_id, SI, sharenum)) d['count-shares-good'] = len(verifiedshares) d['count-good-share-hosts'] = len([s for s in servers.keys() if servers[s]]) @@ -783,10 +784,10 @@ class Checker(log.PrefixingLogMixin): d['sharemap'] = verifiedshares # no such thing as wrong shares of an immutable file d['count-wrong-shares'] = 0 - d['list-corrupt-shares'] = corruptsharelocators - d['count-corrupt-shares'] = len(corruptsharelocators) - d['list-incompatible-shares'] = incompatiblesharelocators - d['count-incompatible-shares'] = len(incompatiblesharelocators) + d['list-corrupt-shares'] = corruptshare_locators + d['count-corrupt-shares'] = len(corruptshare_locators) + d['list-incompatible-shares'] = incompatibleshare_locators + d['count-incompatible-shares'] = len(incompatibleshare_locators) # The file needs rebalancing if the set of servers that have at least