def add(self, loc, authorities): """ Parameters: - location - authorities """ key = location.loc2str(loc) authorities.append(self.location) destinations = location.select_peers(self.ring.nodes.difference(map(location.loc2str,authorities))) for destination in destinations: try: remote_call('add', location.str2loc(destination), loc, authorities) break except location.NodeNotFound, tx: self.remove(tx.location, map(location.str2loc, self.ring.nodes))
def cleanup(self): self.ring.remove(self.here) informed = set() if self.ring.nodes: for key, value in ((a, b) for (a, b) in self.store.items() if b): dest = self.get_node(key) try: if location.loc2str(dest) not in informed: remote_call('remove', dest, self.location, [self.location]) remote_call('ping', dest) informed.add(location.loc2str(dest)) remote_call('put', dest, key, value) except location.NodeNotFound, tx: print "not found" pass if not informed: for dest in location.select_peers(self.ring.nodes): try: remote_call('remove', location.str2loc(dest), self.location, [self.location]) informed.add(dest) break except location.NodeNotFound, tx: self.ring.remove(location.loc2str(tx.location))