Commits

Adam Lindsay  committed 401e170

Simpler and much more effective notification passing around the ring

  • Participants
  • Parent commits a2fb8eb

Comments (0)

Files changed (2)

 
 def select_peers(in_set):
     lst = sorted(in_set)
-    ii = int(sqrt(len(lst)))+1
-    return [b for a, b in enumerate(lst) if (a % ii == 0)]
+    return lst
 
 def ping_until_found(location, maximum=10):
     loc = Location(location.address, location.port)
         self.port = port
         self.peer = peer
         self.ring = HashRing()
-        self.addnews = defaultdict(set)
-        self.removenews = defaultdict(set)
         try:
             remote_call(self.location, 'ping')
             print 'Uh-oh. Our location responded to a ping!'
         for destination in destinations:
             try:
                 remote_call(str2loc(destination), 'remove', location, authorities)
+                break
             except NodeNotFound, tx:
                 # enter all nodes as authorities to avoid race conditions
                 # lazy invalidation
         for destination in destinations:
             try:
                 remote_call(str2loc(destination), 'add', location, authorities)
+                break
             except NodeNotFound, tx:
                 # enter all nodes as authorities to avoid race conditions
                 # lazy invalidation
     def debug(self):
         a = "self.location: %r\n" % self.location
         a += "self.ring.nodes:\n%r\n" % self.ring.nodes
-        a += "self.addnews:\n%r\n" % self.addnews
-        a += "self.removenews:\n%r\n" % self.removenews
         print a
     
     def cleanup(self):
         for node in select_peers(self.ring.nodes):
             try:
                 remote_call(str2loc(node), 'remove', self.location, [self.location])
+                break
             except NodeNotFound, tx:
                 pass
     

File storeserver.py

         """
         key = location.loc2str(loc)
         store = dict()
-        self.addnews[key].add(self.here)
-        self.addnews[key].update(map(location.loc2str, authorities))
-        self.removenews[key] = set()
-        destinations = location.select_peers(self.ring.nodes.difference(self.addnews[key]))
-        self.addnews[key].update(destinations)        
+        authorities.append(self.location)
+        destinations = location.select_peers(self.ring.nodes.difference(map(location.loc2str,authorities)))
         for destination in destinations:
             try:
-                store.update(remote_call(location.str2loc(destination), 
-                    'add', loc, map(location.str2loc, self.addnews[key])))
+                store.update(remote_call(location.str2loc(destination), 'add', loc, authorities))
+                break
             except location.NodeNotFound, tx:
                 self.remove(tx.location, map(location.str2loc, self.ring.nodes))
         locstr = location.loc2str(loc)
         for dest in location.select_peers(self.ring.nodes):
             try:
                 remote_call(location.str2loc(dest), 'remove', self.location, [self.location])
+                break
             except location.NodeNotFound, tx:
                 self.ring.remove(location.loc2str(tx.location))            
         for key, value in ((a, b) for (a, b) in self.store.items() if b):