]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
CheckResults: pass IServer to servers_responding=, getter returns serverid
authorBrian Warner <warner@lothar.com>
Fri, 25 May 2012 19:56:20 +0000 (12:56 -0700)
committerBrian Warner <warner@lothar.com>
Sat, 2 Jun 2012 18:39:11 +0000 (11:39 -0700)
Add temporary get_new_servers_responding().

src/allmydata/check_results.py
src/allmydata/immutable/checker.py
src/allmydata/immutable/filenode.py
src/allmydata/mutable/checker.py
src/allmydata/test/common.py

index bedda40d0481a2f6fa60ffa6ee027066989f8079..bfda6bcd644b93c287aa76c617b9dfd3e4bdb9f1 100644 (file)
@@ -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,
index 386584f174836f17897ecfd9db370d96d3f0fbef..6e882b579edd605ba82a8397b773191808180362 100644 (file)
@@ -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]])
 
index d06b5a648014dd16edee318bdd3671ba8a47ab0d..b54d3ded710a433f80ba67491c7c4e149125f429 100644 (file)
@@ -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()))
index c84047464ff65a2e86898d04ac9df80af626dc02..978b6ac3377fdecbe41f54c36734e3956af18d7b 100644 (file)
@@ -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,
index 6f19df145e48403f7d593994fbe26ba180ae4e96..deb9d139cb659865dd179b8a1a102256fa83fdb7 100644 (file)
@@ -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=[],