def repair_level(node, neighbourhood, ring_level, neighbours): """Repair a ring at a certain level by inserting new neighbours. The new inserted nodes could be propagated to higher levels. """ LOGGER.debug("[DBG] Repair level: " + str(ring_level) + " with " + str(len(neighbours)) + " neighbours (" + str(neighbours) + ")") ring = neighbourhood.get_ring(ring_level) # wrap_left = neighbourhood.can_wrap(Direction.LEFT) # wrap_right= neighbourhood.can_wrap(Direction.RIGHT) left = ring.get_side(Direction.LEFT) right = ring.get_side(Direction.RIGHT) added_left, added_right = False, False for new_node in neighbours: added_left |= left.add_neighbour(new_node) added_right |= right.add_neighbour(new_node) neighbourhood.update(new_node) sides = ((Direction.LEFT, added_left, left), (Direction.RIGHT, added_right, right)) for direction, added, half_ring in sides: LOGGER.log( logging.INFO, "[DBG] Added " + Direction.get_name(direction) + " : " + str(added)) if (added): # Tell nodes that local node is one of their new neighbour. NeighbourhoodNet.ping_half_ring(node, half_ring, ring_level) # Fix the ring higher. route_msg = SNFixupHigher(node, ring_level, direction) node.route_internal(route_msg)
def repair_level(node, neighbourhood, ring_level, neighbours): """Repair a ring at a certain level by inserting new neighbours. The new inserted nodes could be propagated to higher levels. """ LOGGER.debug( "[DBG] Repair level: " + str(ring_level) + " with " + str(len(neighbours)) + " neighbours (" + str(neighbours) + ")") ring = neighbourhood.get_ring(ring_level) # wrap_left = neighbourhood.can_wrap(Direction.LEFT) # wrap_right= neighbourhood.can_wrap(Direction.RIGHT) left = ring.get_side(Direction.LEFT) right = ring.get_side(Direction.RIGHT) added_left, added_right = False, False for new_node in neighbours: added_left |= left.add_neighbour(new_node) added_right |= right.add_neighbour(new_node) neighbourhood.update(new_node) sides = ((Direction.LEFT, added_left, left), (Direction.RIGHT, added_right, right)) for direction, added, half_ring in sides: LOGGER.log(logging.INFO, "[DBG] Added " + Direction.get_name(direction) + " : " + str(added)) if(added): # Tell nodes that local node is one of their new neighbour. NeighbourhoodNet.ping_half_ring(node, half_ring, ring_level) # Fix the ring higher. route_msg = SNFixupHigher(node, ring_level, direction) node.route_internal(route_msg)
def _info(self): return "SNFixupHigher (%i, %s from %s) #%i - " % ( self.__ring_level, Direction.get_name( self.__direction), self.__src_node, self.__nb_hops)
def __repr__(self): return "<SNFixupHigher ((%i, %s from %s) #%i - RouteByPayload>" % ( self.__ring_level, Direction.get_name( self.__direction), self.__src_node, self.__nb_hops)
def _info(self): return "SNFixupHigher (%i, %s from %s) #%i - "%( self.__ring_level, Direction.get_name(self.__direction), self.__src_node, self.__nb_hops)
def __repr__(self): return "<SNFixupHigher ((%i, %s from %s) #%i - RouteByPayload>"%( self.__ring_level, Direction.get_name(self.__direction), self.__src_node, self.__nb_hops)