Changeset 1624

Show
Ignore:
Timestamp:
11/12/08 15:21:19 (2 months ago)
Author:
peet
Message:

more sane timeout algorithm

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/0.4.7/shell/state/ddb.py

    r1621 r1624  
    642642                else: 
    643643                        ring = self.mdns.lookupPTR(domain) 
     644                        print ring 
    644645                        return filter(lambda x: x[0] != exclude, ring) 
    645646 
     
    679680                        self.log("debug","node: %s" % (node)) 
    680681                except: 
    681                         self.log("debug","Node sync watchdog for host `%s` terminated: no such node" % (hostname)) 
     682                        self.log("debug","Node async watchdog for host `%s` terminated: no such node" % (hostname)) 
    682683                        return 
    683684 
    684685                if node.async.has_key(hostname): 
    685686                        node.async[hostname] -= 1 
    686                         self.log("debug","Node sync request for host `%s`" % (hostname)) 
     687                        self.log("debug","Node async request for host `%s`" % (hostname)) 
    687688                        self.log("debug","Sent %s" % (primer.dump())) 
    688689 
    689                         if node.async[hostname] > 0: 
    690                                 self.log("debug","Node sync watchdog for host `%s` started with ttl `%s`" % (hostname,node.async[hostname])) 
    691                                 Timer(10,self._t_add,(host,primer)).start() 
    692                                 x = ACoreService(self.bus,"%s@%s" %(self.prefix, hostname),flags=CX_MSG_TRACK) 
     690                        if node.async[hostname] >= 0: 
     691                                self.log("debug","Node async watchdog for host `%s` started with ttl `%s`" % (hostname,node.async[hostname])) 
     692                                Timer(3,self._t_add,(host,primer)).start() 
    693693                        else: 
    694                                 self.log("critical","Node sync (add) watchdog: low watermark touch; mark node as stale") 
     694                                self.log("critical","Node async watchdog: low watermark touch; kick ourself in the ass") 
    695695                                del node.async[hostname] 
    696                                 x = ACoreService(self.bus, self.bus.address) 
    697                                 x.nop() 
    698                                return 
     696                                y = ACoreService(self.bus, self.bus.address) 
     697                                y.nop() 
     698                        x = ACoreService(self.bus,"%s@%s" %(self.prefix, hostname),flags=CX_MSG_TRACK) 
    699699                        x._add(primer) 
    700700                else: 
    701                         self.log("debug","Node sync watchdog for host `%s` terminated: confirmed" % (hostname)) 
     701                        self.log("debug","Node async watchdog for host `%s` terminated: confirmed" % (hostname)) 
    702702 
    703703        def _t_update(self,host,primer): 
     
    708708                        self.log("debug","node: %s" % (node)) 
    709709                except: 
    710                         self.log("debug","Node sync watchdog for host `%s` terminated: no such node" % (hostname)) 
     710                        self.log("debug","Node usync watchdog for host `%s` terminated: no such node" % (hostname)) 
    711711                        return 
    712712 
    713713                if node.usync.has_key(hostname): 
    714714                        node.usync[hostname] -= 1 
    715                         self.log("debug","Node sync request for host `%s`" % (hostname)) 
     715                        self.log("debug","Node usync request for host `%s`" % (hostname)) 
    716716                        self.log("debug","Sent %s" % (primer.dump())) 
    717717 
    718                         if node.usync[hostname] > 0: 
    719                                 self.log("debug","Node sync watchdog for host `%s` started with ttl `%s`" % (hostname,node.usync[hostname])) 
    720                                 Timer(10,self._t_update,(host,primer)).start() 
    721                                 x = ACoreService(self.bus,"%s@%s" %(self.prefix, hostname),flags=CX_MSG_TRACK) 
     718                        if node.usync[hostname] >= 0: 
     719                                self.log("debug","Node usync watchdog for host `%s` started with ttl `%s`" % (hostname,node.usync[hostname])) 
     720                                Timer(3,self._t_update,(host,primer)).start() 
    722721                        else: 
    723                                 self.log("critical","Node sync (update) watchdog: low watermark touch; mark node as stale") 
     722                                self.log("critical","Node usync watchdog: low watermark touch; kick ourself in the ass") 
    724723                                del node.usync[hostname] 
    725                                 x = ACoreService(self.bus, self.bus.address) 
    726                                 x.nop() 
    727                                return 
     724                                y = ACoreService(self.bus, self.bus.address) 
     725                                y.nop() 
     726                        x = ACoreService(self.bus,"%s@%s" %(self.prefix, hostname),flags=CX_MSG_TRACK) 
    728727                        x._update(primer) 
    729728                else: 
    730                         self.log("debug","Node sync watchdog for host `%s` terminated: confirmed" % (hostname)) 
     729                        self.log("debug","Node usync watchdog for host `%s` terminated: confirmed" % (hostname)) 
    731730 
    732731        def _t_del(self,host,index): 
     
    737736                        self.log("debug","node: %s" % (node)) 
    738737                except: 
    739                         self.log("debug","Node sync watchdog for host `%s` terminated: no such node" % (hostname)) 
     738                        self.log("debug","Node dsync watchdog for host `%s` terminated: no such node" % (hostname)) 
    740739                        return 
    741740 
    742741                if node.dsync.has_key(hostname): 
    743742                        node.dsync[hostname] -= 1 
    744                         self.log("debug","Node sync request for host `%s`" % (hostname)) 
    745  
    746                         if node.dsync[hostname] > 0: 
    747                                 self.log("debug","Node sync watchdog for host `%s` started with ttl `%s`" % (hostname,node.dsync[hostname])) 
    748                                 Timer(10,self._t_del,(host,index)).start() 
    749                                 x = ACoreService(self.bus,"%s@%s" %(self.prefix, hostname),flags=CX_MSG_TRACK) 
     743                        self.log("debug","Node dsync request for host `%s`" % (hostname)) 
     744 
     745                        if node.dsync[hostname] >= 0: 
     746                                self.log("debug","Node dsync watchdog for host `%s` started with ttl `%s`" % (hostname,node.dsync[hostname])) 
     747                                Timer(3,self._t_del,(host,index)).start() 
    750748                        else: 
    751                                 self.log("critical","Node sync (del) watchdog: low watermark touch; mark node as stale") 
     749                                self.log("critical","Node dsync watchdog: low watermark touch; kick ourself in the ass") 
    752750                                del node.dsync[hostname] 
    753                                 x = ACoreService(self.bus, self.bus.address) 
    754                                 x.nop() 
    755                                return 
     751                                y = ACoreService(self.bus, self.bus.address) 
     752                                y.nop() 
     753                        x = ACoreService(self.bus,"%s@%s" %(self.prefix, hostname),flags=CX_MSG_TRACK) 
    756754                        x._del(index) 
    757755                else: 
    758                         self.log("debug","Node sync watchdog for host `%s` terminated: confirmed" % (hostname)) 
     756                        self.log("debug","Node dsync watchdog for host `%s` terminated: confirmed" % (hostname)) 
    759757 
    760758 
     
    772770                self.log("debug","hosts list: `%s`" % (x)) 
    773771                for i in x: 
    774                         node.dsync[i[0]] = 5 
     772                        if i[1] == "reachable": 
     773                                node.dsync[i[0]] = 5 
    775774                        self._t_del(i,index) 
    776775                         
     
    817816                self.log("debug","hosts list: `%s`" % (x)) 
    818817                for i in x: 
    819                         node.usync[i[0]] = 5 
     818                        if i[1] == "reachable": 
     819                                node.dsync[i[0]] = 5 
    820820                        self._t_update(i,p) 
    821821                         
     
    894894                p.private_data = {} 
    895895                for i in x: 
    896                         node.async[i[0]] = 5 
     896                        if i[1] == "reachable": 
     897                                node.async[i[0]] = 5 
    897898                        self._t_add(i,p) 
    898899                #