]> git.mxchange.org Git - quix0rs-apt-p2p.git/commitdiff
Remove the duplicate error logging from the knode module.
authorCameron Dale <camrdale@gmail.com>
Thu, 20 Mar 2008 22:26:41 +0000 (15:26 -0700)
committerCameron Dale <camrdale@gmail.com>
Thu, 20 Mar 2008 22:26:41 +0000 (15:26 -0700)
apt_p2p_Khashmir/khashmir.py
apt_p2p_Khashmir/knode.py

index 230de1fb3a18124b30a5b74291e1facb8948290e..b3b007d079ef3e6cc4f5048f1e1158b81b0b78a3 100644 (file)
@@ -208,11 +208,13 @@ class KhashmirBase(protocol.Factory):
             (datetime.now() - old.lastSeen) > 
              timedelta(seconds=self.config['MIN_PING_INTERVAL'])):
             
-            def _staleNodeHandler(failure, oldnode = old, newnode = node):
+            def _staleNodeHandler(err, oldnode = old, newnode = node, self = self):
                 """The pinged node never responded, so replace it."""
+                log.msg("ping failed (%s) %s/%s" % (self.config['PORT'], oldnode.host, oldnode.port))
+                log.err(err)
                 self.table.replaceStaleNode(oldnode, newnode)
             
-            def _notStaleNodeHandler(dict, old=old):
+            def _notStaleNodeHandler(dict, old=old, self=self):
                 """Got a pong from the old node, so update it."""
                 dict = dict['rsp']
                 if dict['id'] == old.id:
@@ -244,9 +246,11 @@ class KhashmirBase(protocol.Factory):
             if callback:
                 callback((dict['rsp']['ip_addr'], dict['rsp']['port']))
 
-        def _defaultPong(err, node=node, table=self.table, callback=callback, errback=errback):
+        def _defaultPong(err, node=node, self=self, callback=callback, errback=errback):
             """Error occurred, fail node and errback or callback with error."""
-            table.nodeFailed(node)
+            log.msg("join failed (%s) %s/%s" % (self.config['PORT'], node.host, node.port))
+            log.err(err)
+            self.table.nodeFailed(node)
             if errback:
                 errback()
             elif callback:
index 36d77bdc99ea9a872f09609cad81db2f6af73cf8..1fbdbc3302521f62efa406dc2daabd52fb7e8a3f 100644 (file)
@@ -25,29 +25,21 @@ class KNodeBase(Node):
                 
         return dict
 
-    def errBack(self, err):
-        """Log an error that has occurred."""
-        log.err(err)
-        return err
-        
     def ping(self, id):
         """Ping the node."""
         df = self.conn.sendRequest('ping', {"id":id})
-        df.addErrback(self.errBack)
         df.addCallback(self.checkSender)
         return df
     
     def join(self, id):
         """Use the node to bootstrap into the system."""
         df = self.conn.sendRequest('join', {"id":id})
-        df.addErrback(self.errBack)
         df.addCallback(self.checkSender)
         return df
     
     def find_node(self, id, target):
         """Request the nearest nodes to the target that the node knows about."""
         df = self.conn.sendRequest('find_node', {"target" : target, "id": id})
-        df.addErrback(self.errBack)
         df.addCallback(self.checkSender)
         return df
 
@@ -57,14 +49,12 @@ class KNodeRead(KNodeBase):
     def find_value(self, id, key):
         """Request the nearest nodes to the key that the node knows about."""
         df =  self.conn.sendRequest('find_value', {"key" : key, "id" : id})
-        df.addErrback(self.errBack)
         df.addCallback(self.checkSender)
         return df
 
     def get_value(self, id, key, num):
         """Request the values that the node has for the key."""
         df = self.conn.sendRequest('get_value', {"key" : key, "num": num, "id" : id})
-        df.addErrback(self.errBack)
         df.addCallback(self.checkSender)
         return df
 
@@ -74,6 +64,5 @@ class KNodeWrite(KNodeRead):
     def store_value(self, id, key, value, token):
         """Store a value in the node."""
         df = self.conn.sendRequest('store_value', {"key" : key, "value" : value, "token" : token, "id": id})
-        df.addErrback(self.errBack)
         df.addCallback(self.checkSender)
         return df