From: Brian Warner Date: Wed, 17 Jan 2007 01:47:52 +0000 (-0700) Subject: add better error reporting to NotEnoughPeersError X-Git-Tag: tahoe_v0.1.0-0-UNSTABLE~370 X-Git-Url: https://git.rkrishnan.org/components/com_hotproperty/simplejson/about.html?a=commitdiff_plain;h=fed539a16d0e45c783dc118e8295680d4dbdacb4;p=tahoe-lafs%2Ftahoe-lafs.git add better error reporting to NotEnoughPeersError --- diff --git a/src/allmydata/upload.py b/src/allmydata/upload.py index 653ada41..29cef084 100644 --- a/src/allmydata/upload.py +++ b/src/allmydata/upload.py @@ -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" diff --git a/src/allmydata/util/idlib.py b/src/allmydata/util/idlib.py index cd6882db..24ca37da 100644 --- a/src/allmydata/util/idlib.py +++ b/src/allmydata/util/idlib.py @@ -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] diff --git a/src/allmydata/webish.py b/src/allmydata/webish.py index 4de899db..5b9448e4 100644 --- a/src/allmydata/webish.py +++ b/src/allmydata/webish.py @@ -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