Ejemplo n.º 1
0
 def purgeBackups(self):
     for key in self.backups.keys()[:]:
         if self.pred is not None and not self.pred.name == self.name:  #possible logic error location
             if not hashBetweenRightInclusive(long(key,16), Peer(self.predecessorList[0]).hashid, self.hashid):
                 try:
                     deletions.append((self.backups[key], str(Peer(self.predecessorList[0]).hashid)[:6], str(key)[:6], str(self.hashid)[:6]))
                     del self.backups[key]
                 except Exception, e:
                     print self.backups, e
             elif self.keyIsMine(key):
                 print self.name, "taking over key", key
                 self.makeBackupMine(key)
Ejemplo n.º 2
0
 def notify(self,poker):
     hasNewPred = super(DHTnode,self).notify(poker)
     self.updatePredecessorList()
     if hasNewPred:
         try:
             for key in self.data.keys()[:]:
                 if hashBetweenRightInclusive(long(key,16), Peer(self.predecessorList[-2]).hashid, self.pred.hashid):  #check here for weird behavioer
                     self.relinquishData(key)
         except Exception:
             print self.name, "couldn't relinquish data"
             traceback.print_exc(file=sys.stdout)
             self.predecessorList.pop()
             self.pred = Peer(self.predecessorList[-1])
             self.updatePredecessorList()
     return hasNewPred
Ejemplo n.º 3
0
 def keyIsMine(self, key):
     if self.pred is None or self.pred.name == self.name :
         return True
     return hashBetweenRightInclusive(long(key,16), self.pred.hashid, self.hashid)