]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
CheckResults corrupt/incompatible shares now return IServers 10/head
authorBrian Warner <warner@lothar.com>
Fri, 25 May 2012 19:58:28 +0000 (12:58 -0700)
committerBrian Warner <warner@lothar.com>
Sat, 2 Jun 2012 18:39:12 +0000 (11:39 -0700)
DeepResultsBase also has a get_corrupt_shares(), and it is populated
from CheckResults.get_corrupt_shares(). It has been updated too, along
with get_remaining_corrupt_shares().

Remove temporary get_new_corrupt_shares() and
get_new_incompatible_shares().

src/allmydata/check_results.py
src/allmydata/immutable/filenode.py
src/allmydata/interfaces.py
src/allmydata/test/test_checker.py
src/allmydata/web/check_results.py

index 636603e5105aaa377f72d4482bc6cc17e6cc35a8..a5601c15ad300fb2d604cb3a7273c71d43c708a8 100644 (file)
@@ -91,17 +91,11 @@ class CheckResults:
     def get_share_counter_wrong(self):
         return self._count_wrong_shares
 
-    def get_new_corrupt_shares(self):
-        return self._list_corrupt_shares
     def get_corrupt_shares(self):
-        return [(s.get_serverid(), SI, shnum)
-                for (s, SI, shnum) in self._list_corrupt_shares]
+        return self._list_corrupt_shares
 
-    def get_new_incompatible_shares(self):
-        return self._list_incompatible_shares
     def get_incompatible_shares(self):
-        return [(s.get_serverid(), SI, shnum)
-                for (s, SI, shnum) in self._list_incompatible_shares]
+        return self._list_incompatible_shares
 
     def get_servers_responding(self):
         return self._servers_responding
index a1a0c698849fd801bf0545351a01ee8ea7caa9fd..7def22c824186ebb1706bcfa65ea021dbe268dfb 100644 (file)
@@ -154,9 +154,9 @@ class CiphertextFileNode:
                            servers_responding=list(servers_responding),
                            sharemap=sm,
                            count_wrong_shares=0, # no such thing as wrong, for immutable
-                           list_corrupt_shares=cr.get_new_corrupt_shares(),
+                           list_corrupt_shares=cr.get_corrupt_shares(),
                            count_corrupt_shares=len(cr.get_corrupt_shares()),
-                           list_incompatible_shares=cr.get_new_incompatible_shares(),
+                           list_incompatible_shares=cr.get_incompatible_shares(),
                            count_incompatible_shares=len(cr.get_incompatible_shares()),
                            summary="",
                            report=[],
index 86c94cd8babdca825f6d20d19cf4062770944e16..14e52be51ce42bf3b2db70623820d3d041632df4 100644 (file)
@@ -2159,12 +2159,12 @@ class ICheckResults(Interface):
     def get_corrupt_shares():
         """Return a list of 'share locators', one for each share that was
         found to be corrupt (integrity failure). Each share locator is a list
-        of (serverid, storage_index, sharenum)."""
+        of (IServer, storage_index, sharenum)."""
 
     def get_incompatible_shares():
         """Return a list of 'share locators', one for each share that was
         found to be of an unknown format. Each share locator is a list of
-        (serverid, storage_index, sharenum)."""
+        (IServer, storage_index, sharenum)."""
 
     def get_servers_responding():
         """Return a list of IServer objects, one for each server which
@@ -2255,10 +2255,8 @@ class IDeepCheckResults(Interface):
         """
 
     def get_corrupt_shares():
-        """Return a set of (serverid, storage_index, sharenum) for all shares
-        that were found to be corrupt. Both serverid and storage_index are
-        binary.
-        """
+        """Return a set of (IServer, storage_index, sharenum) for all shares
+        that were found to be corrupt. storage_index is binary."""
     def get_all_results():
         """Return a dictionary mapping pathname (a tuple of strings, ready to
         be slash-joined) to an ICheckResults instance, one for each object
@@ -2323,15 +2321,15 @@ class IDeepCheckAndRepairResults(Interface):
         IDirectoryNode.deep_stats()."""
 
     def get_corrupt_shares():
-        """Return a set of (serverid, storage_index, sharenum) for all shares
-        that were found to be corrupt before any repair was attempted. Both
-        serverid and storage_index are binary.
+        """Return a set of (IServer, storage_index, sharenum) for all shares
+        that were found to be corrupt before any repair was attempted.
+        storage_index is binary.
         """
     def get_remaining_corrupt_shares():
-        """Return a set of (serverid, storage_index, sharenum) for all shares
-        that were found to be corrupt after any repair was completed. Both
-        serverid and storage_index are binary. These are shares that need
-        manual inspection and probably deletion.
+        """Return a set of (IServer, storage_index, sharenum) for all shares
+        that were found to be corrupt after any repair was completed.
+        storage_index is binary. These are shares that need manual inspection
+        and probably deletion.
         """
     def get_all_results():
         """Return a dictionary mapping pathname (a tuple of strings, ready to
index d83025ad1506dac17f66c3c89876e8d0061becaf..65498e76ffce8a434972c269a0d79bbf9af709d8 100644 (file)
@@ -140,7 +140,7 @@ class WebResultsRendering(unittest.TestCase, WebRenderingMixin):
         s = self.remove_tags(html)
         self.failUnlessIn("File Check Results for SI=2k6avp", s) # abbreviated
         self.failUnlessIn("Not Recoverable! : rather dead", s)
-        self.failUnlessIn("Corrupt shares: Share ID Nickname Node ID sh#2 peer-0 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", s)
+        self.failUnlessIn("Corrupt shares: Share ID Nickname Node ID sh#2 peer-0 00000000", s)
 
         html = self.render2(w)
         s = self.remove_tags(html)
@@ -166,8 +166,7 @@ class WebResultsRendering(unittest.TestCase, WebRenderingMixin):
                                      ["v0-00000000-long", "v0-ffffffff-long"]},
                         'count-recoverable-versions': 1,
                         'list-corrupt-shares':
-                        [["aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
-                          "2k6avpjga3dho3zsjo6nnkt7n4", 2]],
+                        [["v0-00000000-long", "2k6avpjga3dho3zsjo6nnkt7n4", 2]],
                         'count-good-share-hosts': 11,
                         'count-wrong-shares': 0,
                         'count-shares-good': 10,
index 8c2946286bd861fdcf994c3a4fac1f10a59efc24..e3ddbc94571a428efcd67fd77764fa7c102dc8b3 100644 (file)
@@ -6,7 +6,7 @@ from twisted.web import http, html
 from allmydata.web.common import getxmlfile, get_arg, get_root, WebError
 from allmydata.web.operations import ReloadMixin
 from allmydata.interfaces import ICheckAndRepairResults, ICheckResults
-from allmydata.util import base32, idlib, dictutil
+from allmydata.util import base32, dictutil
 
 def json_check_counts(r):
     d = {"count-shares-good": r.get_share_counter_good(),
@@ -14,9 +14,8 @@ def json_check_counts(r):
          "count-shares-expected": r.get_encoding_expected(),
          "count-good-share-hosts": r.get_host_counter_good_shares(),
          "count-corrupt-shares": len(r.get_corrupt_shares()),
-         "list-corrupt-shares": [ (idlib.nodeid_b2a(serverid),
-                                   base32.b2a(si), shnum)
-                                  for (serverid, si, shnum)
+         "list-corrupt-shares": [ (s.get_longname(), base32.b2a(si), shnum)
+                                  for (s, si, shnum)
                                   in r.get_corrupt_shares() ],
          "servers-responding": [s.get_longname()
                                 for s in r.get_servers_responding()],
@@ -91,12 +90,12 @@ class ResultsBase:
 
         if cr.get_corrupt_shares():
             badsharemap = []
-            for (serverid, si, shnum) in cr.get_corrupt_shares():
-                nickname = sb.get_nickname_for_serverid(serverid)
-                badsharemap.append(T.tr[T.td["sh#%d" % shnum],
-                                        T.td[T.div(class_="nickname")[nickname],
-                                              T.div(class_="nodeid")[T.tt[base32.b2a(serverid)]]],
-                                        ])
+            for (s, si, shnum) in cr.get_corrupt_shares():
+                d = T.tr[T.td["sh#%d" % shnum],
+                         T.td[T.div(class_="nickname")[s.get_nickname()],
+                              T.div(class_="nodeid")[T.tt[s.get_name()]]],
+                         ]
+                badsharemap.append(d)
             add("Corrupt shares", T.table()[
                 T.tr[T.th["Share ID"],
                      T.th(class_="nickname-and-peerid")[T.div["Nickname"], T.div(class_="nodeid")["Node ID"]]],
@@ -348,10 +347,10 @@ class DeepCheckResultsRenderer(rend.Page, ResultsBase, ReloadMixin):
         data["count-objects-healthy"] = c["count-objects-healthy"]
         data["count-objects-unhealthy"] = c["count-objects-unhealthy"]
         data["count-corrupt-shares"] = c["count-corrupt-shares"]
-        data["list-corrupt-shares"] = [ (idlib.nodeid_b2a(serverid),
+        data["list-corrupt-shares"] = [ (s.get_longname(),
                                          base32.b2a(storage_index),
                                          shnum)
-                                        for (serverid, storage_index, shnum)
+                                        for (s, storage_index, shnum)
                                         in res.get_corrupt_shares() ]
         data["list-unhealthy-files"] = [ (path_t, json_check_results(r))
                                          for (path_t, r)
@@ -405,17 +404,15 @@ class DeepCheckResultsRenderer(rend.Page, ResultsBase, ReloadMixin):
         return ""
 
     def data_servers_with_corrupt_shares(self, ctx, data):
-        servers = [serverid
-                   for (serverid, storage_index, sharenum)
+        servers = [s
+                   for (s, storage_index, sharenum)
                    in self.monitor.get_status().get_corrupt_shares()]
-        servers.sort()
+        servers.sort(key=lambda s: s.get_longname())
         return servers
 
-    def render_server_problem(self, ctx, data):
-        serverid = data
-        data = [idlib.shortnodeid_b2a(serverid)]
-        sb = self.client.get_storage_broker()
-        nickname = sb.get_nickname_for_serverid(serverid)
+    def render_server_problem(self, ctx, server):
+        data = [server.get_name()]
+        nickname = server.get_nickname()
         if nickname:
             data.append(" (%s)" % self._html(nickname))
         return ctx.tag[data]
@@ -428,10 +425,9 @@ class DeepCheckResultsRenderer(rend.Page, ResultsBase, ReloadMixin):
     def data_corrupt_shares(self, ctx, data):
         return self.monitor.get_status().get_corrupt_shares()
     def render_share_problem(self, ctx, data):
-        serverid, storage_index, sharenum = data
-        sb = self.client.get_storage_broker()
-        nickname = sb.get_nickname_for_serverid(serverid)
-        ctx.fillSlots("serverid", idlib.shortnodeid_b2a(serverid))
+        server, storage_index, sharenum = data
+        nickname = server.get_nickname()
+        ctx.fillSlots("serverid", server.get_name())
         if nickname:
             ctx.fillSlots("nickname", self._html(nickname))
         ctx.fillSlots("si", self._render_si_link(ctx, storage_index))
@@ -512,16 +508,15 @@ class DeepCheckAndRepairResultsRenderer(rend.Page, ResultsBase, ReloadMixin):
         data["count-corrupt-shares-pre-repair"] = c["count-corrupt-shares-pre-repair"]
         data["count-corrupt-shares-post-repair"] = c["count-corrupt-shares-pre-repair"]
 
-        data["list-corrupt-shares"] = [ (idlib.nodeid_b2a(serverid),
+        data["list-corrupt-shares"] = [ (s.get_longname(),
                                          base32.b2a(storage_index),
                                          shnum)
-                                        for (serverid, storage_index, shnum)
+                                        for (s, storage_index, shnum)
                                         in res.get_corrupt_shares() ]
 
-        remaining_corrupt = [ (idlib.nodeid_b2a(serverid),
-                               base32.b2a(storage_index),
+        remaining_corrupt = [ (s.get_longname(), base32.b2a(storage_index),
                                shnum)
-                              for (serverid, storage_index, shnum)
+                              for (s, storage_index, shnum)
                               in res.get_remaining_corrupt_shares() ]
         data["list-remaining-corrupt-shares"] = remaining_corrupt