From: Brian Warner Date: Fri, 25 May 2012 19:56:20 +0000 (-0700) Subject: CheckResults: pass IServer to servers_responding=, getter returns serverid X-Git-Url: https://git.rkrishnan.org/frontends/$top_link?a=commitdiff_plain;h=dd8178ee6d0bab1b4540804e39d3d567ab7bd3ea;p=tahoe-lafs%2Ftahoe-lafs.git CheckResults: pass IServer to servers_responding=, getter returns serverid Add temporary get_new_servers_responding(). --- diff --git a/src/allmydata/check_results.py b/src/allmydata/check_results.py index bedda40d..bfda6bcd 100644 --- a/src/allmydata/check_results.py +++ b/src/allmydata/check_results.py @@ -39,8 +39,8 @@ class CheckResults: self._count_good_share_hosts = count_good_share_hosts self._count_recoverable_versions = count_recoverable_versions self._count_unrecoverable_versions = count_unrecoverable_versions - for s in servers_responding: - assert isinstance(s, str), s + for server in servers_responding: + assert IDisplayableServer.providedBy(server), server self._servers_responding = servers_responding for shnum, servers in sharemap.items(): for server in servers: @@ -97,8 +97,10 @@ class CheckResults: def get_incompatible_shares(self): return self._list_incompatible_shares - def get_servers_responding(self): + def get_new_servers_responding(self): return self._servers_responding + def get_servers_responding(self): + return [s.get_serverid() for s in self._servers_responding] def get_host_counter_good_shares(self): return self._count_good_share_hosts @@ -122,13 +124,14 @@ class CheckResults: sharemap = {} for shnum, servers in self._sharemap.items(): sharemap[shnum] = sorted([s.get_serverid() for s in servers]) + responding = [s.get_serverid() for s in self._servers_responding] d = {"count-shares-needed": self._count_shares_needed, "count-shares-expected": self._count_shares_expected, "count-shares-good": self._count_shares_good, "count-good-share-hosts": self._count_good_share_hosts, "count-recoverable-versions": self._count_recoverable_versions, "count-unrecoverable-versions": self._count_unrecoverable_versions, - "servers-responding": self._servers_responding, + "servers-responding": responding, "sharemap": sharemap, "count-wrong-shares": self._count_wrong_shares, "list-corrupt-shares": self._list_corrupt_shares, diff --git a/src/allmydata/immutable/checker.py b/src/allmydata/immutable/checker.py index 386584f1..6e882b57 100644 --- a/src/allmydata/immutable/checker.py +++ b/src/allmydata/immutable/checker.py @@ -740,14 +740,14 @@ class Checker(log.PrefixingLogMixin): SI = self._verifycap.get_storage_index() verifiedshares = dictutil.DictOfSets() # {sharenum: set(server)} - servers = {} # {serverid: set(sharenums)} + servers = {} # {server: set(sharenums)} corruptshare_locators = [] # (serverid, storageindex, sharenum) incompatibleshare_locators = [] # (serverid, storageindex, sharenum) servers_responding = set() # serverid for verified, server, corrupt, incompatible, responded in results: server_id = server.get_serverid() - servers.setdefault(server_id, set()).update(verified) + servers.setdefault(server, set()).update(verified) for sharenum in verified: verifiedshares.setdefault(sharenum, set()).add(server) for sharenum in corrupt: @@ -755,7 +755,7 @@ class Checker(log.PrefixingLogMixin): for sharenum in incompatible: incompatibleshare_locators.append((server_id, SI, sharenum)) if responded: - servers_responding.add(server_id) + servers_responding.add(server) good_share_hosts = len([s for s in servers.keys() if servers[s]]) diff --git a/src/allmydata/immutable/filenode.py b/src/allmydata/immutable/filenode.py index d06b5a64..b54d3ded 100644 --- a/src/allmydata/immutable/filenode.py +++ b/src/allmydata/immutable/filenode.py @@ -126,7 +126,7 @@ class CiphertextFileNode: # prr (post-repair results) verifycap = self._verifycap - servers_responding = set(cr.get_servers_responding()) + servers_responding = set(cr.get_new_servers_responding()) sm = DictOfSets() assert isinstance(cr.get_sharemap(), DictOfSets) for shnum, servers in cr.get_new_sharemap().items(): @@ -135,7 +135,7 @@ class CiphertextFileNode: for shnum, servers in ur.get_sharemap().items(): for server in servers: sm.add(shnum, server) - servers_responding.add(server.get_serverid()) + servers_responding.add(server) servers_responding = sorted(servers_responding) good_hosts = len(reduce(set.union, sm.values(), set())) diff --git a/src/allmydata/mutable/checker.py b/src/allmydata/mutable/checker.py index c8404746..978b6ac3 100644 --- a/src/allmydata/mutable/checker.py +++ b/src/allmydata/mutable/checker.py @@ -218,8 +218,6 @@ class MutableChecker: for (shnum, server, timestamp) in vmap[verinfo]: shareid = "%s-sh%d" % (smap.summarize_version(verinfo), shnum) sharemap.add(shareid, server) - servers_responding = [s.get_serverid() for s in - list(smap.get_reachable_servers())] if healthy: summary = "Healthy" else: @@ -235,7 +233,7 @@ class MutableChecker: count_good_share_hosts=counters["count-good-share-hosts"], count_recoverable_versions=len(recoverable), count_unrecoverable_versions=len(unrecoverable), - servers_responding=servers_responding, + servers_responding=list(smap.get_reachable_servers()), sharemap=sharemap, count_wrong_shares=counters["count-wrong-shares"], list_corrupt_shares=corrupt_share_locators, diff --git a/src/allmydata/test/common.py b/src/allmydata/test/common.py index 6f19df14..deb9d139 100644 --- a/src/allmydata/test/common.py +++ b/src/allmydata/test/common.py @@ -67,8 +67,7 @@ class FakeCHKFileNode: return self.storage_index def check(self, monitor, verify=False, add_lease=False): - nodeid = "\x00"*20 - s = StubServer(nodeid) + s = StubServer("\x00"*20) r = CheckResults(self.my_uri, self.storage_index, healthy=True, recoverable=True, needs_rebalancing=False, @@ -78,7 +77,7 @@ class FakeCHKFileNode: count_good_share_hosts=10, count_recoverable_versions=1, count_unrecoverable_versions=0, - servers_responding=[nodeid], + servers_responding=[s], sharemap={1: [s]}, count_wrong_shares=0, list_corrupt_shares=[], @@ -280,8 +279,7 @@ class FakeMutableFileNode: return self.file_types[self.storage_index] def check(self, monitor, verify=False, add_lease=False): - nodeid = "\x00"*20 - s = StubServer(nodeid) + s = StubServer("\x00"*20) r = CheckResults(self.my_uri, self.storage_index, healthy=True, recoverable=True, needs_rebalancing=False, @@ -291,7 +289,7 @@ class FakeMutableFileNode: count_good_share_hosts=10, count_recoverable_versions=1, count_unrecoverable_versions=0, - servers_responding=[nodeid], + servers_responding=[s], sharemap={"seq1-abcd-sh0": [s]}, count_wrong_shares=0, list_corrupt_shares=[],