]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
add better error reporting to NotEnoughPeersError
authorBrian Warner <warner@allmydata.com>
Wed, 17 Jan 2007 01:47:52 +0000 (18:47 -0700)
committerBrian Warner <warner@allmydata.com>
Wed, 17 Jan 2007 01:47:52 +0000 (18:47 -0700)
src/allmydata/upload.py
src/allmydata/util/idlib.py
src/allmydata/webish.py

index 653ada41c7c3d6bcd57d9175c4809214bb4c6e2c..29cef084babbb2502a0665ee24f34b65659ee892 100644 (file)
@@ -77,6 +77,9 @@ class FileUploader:
         max_peers = None
 
         self.permuted = self._peer.permute_peerids(self._verifierid, max_peers)
+        self.peers_who_said_yes = []
+        self.peers_who_said_no = []
+        self.peers_who_had_errors = []
 
         self._total_peers = len(self.permuted)
         for p in self.permuted:
@@ -103,12 +106,20 @@ class FileUploader:
                      self._total_peers))
         if len(self.permuted) == 0:
             # there are no more to check
-            raise NotEnoughPeersError("%s goodness, want %s, have %d "
-                                      "landlords, %d total peers" %
-                                      (self.goodness_points,
-                                       self.target_goodness,
-                                       len(self.landlords),
-                                       self._total_peers))
+            yes = ",".join([peerid_to_short_string(p)
+                            for p in self.peers_who_said_yes])
+            no = ",".join([peerid_to_short_string(p)
+                           for p in self.peers_who_said_no])
+            err = ",".join([peerid_to_short_string(p)
+                            for p in self.peers_who_had_errors])
+            msg = ("%s goodness, want %s, have %d "
+                   "landlords, %d total peers, "
+                   "peers:yes=%s;no=%s;err=%s" %
+                   (self.goodness_points, self.target_goodness,
+                    len(self.landlords), self._total_peers,
+                    yes, no, err))
+            log.msg("NotEnoughPeersError: %s" % msg)
+            raise NotEnoughPeersError(msg)
         if self.peer_index >= len(self.permuted):
             self.peer_index = 0
 
@@ -127,6 +138,7 @@ class FileUploader:
             def _allocate_response(bucket):
                 if self.debug:
                     print " peerid %s will grant us a lease" % idlib.b2a(peerid)
+                self.peers_who_said_yes.append(peerid)
                 self.landlords.append( (peerid, bucket_num, bucket) )
                 self.goodness_points += 1
                 if (self.goodness_points >= self.target_goodness and
@@ -146,10 +158,13 @@ class FileUploader:
                     return
                 if res.check(TooFullError):
                     if self.debug: print " too full"
+                    self.peers_who_said_no.append(peerid)
                 elif res.check(IndexError):
                     if self.debug: print " no connection"
+                    self.peers_who_had_errors.append(peerid)
                 else:
                     if self.debug: print " other error:", res
+                    self.peers_who_had_errors.append(peerid)
                 self.permuted.remove(peerid) # this peer was unusable
             else:
                 if self.debug: print " they gave us a lease"
index cd6882db674f2d34425ca06804cb33e257cf96cd..24ca37dafe236717a2c83005dee733b903ad0257 100644 (file)
@@ -12,3 +12,6 @@ def a2b(i):
         print "b32decode failed on a %s byte string '%s'" % (len(i), i)
         raise
 
+
+def peerid_to_short_string(peerid):
+    return b2a(peerid)[:4]
index 4de899db2c59759d2626020105bb449b4465717c..5b9448e47546172bd8d8479b681aa7ba323a24d6 100644 (file)
@@ -324,8 +324,3 @@ class WebishServer(service.MultiService):
         #print "REMEMBERING", self.site, dl, IDownloader
         #self.site.remember(dl, IDownloader)
 
-
-# TODO: figleaf gets confused when the last line of a file is a comment. I
-# suspect an off-by-one error in the code that decides which lines are code
-# and which are not.
-pass