)]}'
{"networking_bagpipe/bagpipe_bgp/vpn/identifier_allocators.py":[{"author":{"_account_id":12021,"name":"Thomas Morin","email":"tmmorin.orange@gmail.com","username":"tmorin"},"change_message_id":"80f34b67e2bbb8eaadebe2f36904967b8c2c8ec5","unresolved":false,"context_lines":[{"line_number":52,"context_line":"                break"},{"line_number":53,"context_line":""},{"line_number":54,"context_line":"    @utils.synchronized"},{"line_number":55,"context_line":"    def get_new_id(self, description\u003dNone, requested_id\u003dNone):"},{"line_number":56,"context_line":""},{"line_number":57,"context_line":"        if self.current_id \u003e self.MAX:"},{"line_number":58,"context_line":"            if len(self.released_ids) \u003e 0:"}],"source_content_type":"text/x-python","patch_set":1,"id":"5f7c97a3_59eb67db","line":55,"range":{"start_line":55,"start_character":43,"end_line":55,"end_character":55},"updated":"2018-06-05 07:57:29.000000000","message":"could we call this \"hint_value\", so that the name reflects that it is only a hint and that another value may be given ?","commit_id":"9ee0ec9e097b432bd930a4a084d1730f8a6deb87"},{"author":{"_account_id":12021,"name":"Thomas Morin","email":"tmmorin.orange@gmail.com","username":"tmorin"},"change_message_id":"80f34b67e2bbb8eaadebe2f36904967b8c2c8ec5","unresolved":false,"context_lines":[{"line_number":53,"context_line":""},{"line_number":54,"context_line":"    @utils.synchronized"},{"line_number":55,"context_line":"    def get_new_id(self, description\u003dNone, requested_id\u003dNone):"},{"line_number":56,"context_line":""},{"line_number":57,"context_line":"        if self.current_id \u003e self.MAX:"},{"line_number":58,"context_line":"            if len(self.released_ids) \u003e 0:"},{"line_number":59,"context_line":"                # FIFO (pop the id that was released the earliest)"}],"source_content_type":"text/x-python","patch_set":1,"id":"5f7c97a3_7953c36d","line":56,"updated":"2018-06-05 07:57:29.000000000","message":"Checking that the hint is not above MAX can be an nice safeguard:\n\nif requested_id is not None and requested_id \u003e self.MAX:\n   LOG.warning(\"allocator hint value cannot be beyond MAX\")","commit_id":"9ee0ec9e097b432bd930a4a084d1730f8a6deb87"},{"author":{"_account_id":12021,"name":"Thomas Morin","email":"tmmorin.orange@gmail.com","username":"tmorin"},"change_message_id":"80f34b67e2bbb8eaadebe2f36904967b8c2c8ec5","unresolved":false,"context_lines":[{"line_number":54,"context_line":"    @utils.synchronized"},{"line_number":55,"context_line":"    def get_new_id(self, description\u003dNone, requested_id\u003dNone):"},{"line_number":56,"context_line":""},{"line_number":57,"context_line":"        if self.current_id \u003e self.MAX:"},{"line_number":58,"context_line":"            if len(self.released_ids) \u003e 0:"},{"line_number":59,"context_line":"                # FIFO (pop the id that was released the earliest)"},{"line_number":60,"context_line":"                new_id \u003d self.released_ids.pop(0)"},{"line_number":61,"context_line":"            else:"},{"line_number":62,"context_line":"                raise MaxIDReached(max\u003dself.MAX)"},{"line_number":63,"context_line":"        else:"},{"line_number":64,"context_line":"            if requested_id:"},{"line_number":65,"context_line":"                if requested_id in self.allocated_ids:"},{"line_number":66,"context_line":"                    new_id \u003d self.current_id"},{"line_number":67,"context_line":"                else:"},{"line_number":68,"context_line":"                    new_id \u003d requested_id"},{"line_number":69,"context_line":""},{"line_number":70,"context_line":"                    if requested_id in self.released_ids:"},{"line_number":71,"context_line":"                        self.released_ids.remove(requested_id)"},{"line_number":72,"context_line":""},{"line_number":73,"context_line":"                if (requested_id \u003d\u003d self.current_id or"},{"line_number":74,"context_line":"                        requested_id in self.allocated_ids):"},{"line_number":75,"context_line":"                    self._get_next_id()"},{"line_number":76,"context_line":"            else:"},{"line_number":77,"context_line":"                new_id \u003d self.current_id"},{"line_number":78,"context_line":"                self._get_next_id()"},{"line_number":79,"context_line":""},{"line_number":80,"context_line":"        self.allocated_ids[new_id] \u003d description"},{"line_number":81,"context_line":""}],"source_content_type":"text/x-python","patch_set":1,"id":"5f7c97a3_59c0472b","line":78,"range":{"start_line":57,"start_character":0,"end_line":78,"end_character":35},"updated":"2018-06-05 07:57:29.000000000","message":"I think we could make the code more readable and support the hint including after self.current_id has readhed MAX.\n\nSomething like this:\n\n\nif requested_id is not None and not requested_id in self.allocated_ids:\n    return self._allocate(requested_id, update_current\u003dTrue)\nelif self.current_id \u003e self.MAX:\n    if len(self.released_ids) \u003e 0:\n        # FIFO (pop the id that was released the earliest)\n        return self._allocate(self.released_ids.pop(0), description)\n    else:\n        raise MaxIDReached(max\u003dself.MAX)\nelse:\n    return self._allocate(self.current_id, desc, update_current\u003dTrue)\n\n\ndef _allocate(self, id, desc, update_current\u003dFalse)\n    self.allocated_ids[id] \u003d desc\n    # update current_id to the next free id\n    if update_current and id \u003d\u003d self.current_id:    \n       for next_id in itertools.count(self.current_id+1):\n          if next_id not in self.allocated_ids:\n             self.current_id \u003d next_id\n             break\n    return id","commit_id":"9ee0ec9e097b432bd930a4a084d1730f8a6deb87"}],"networking_bagpipe/tests/unit/bagpipe_bgp/test_identifier_allocators.py":[{"author":{"_account_id":12021,"name":"Thomas Morin","email":"tmmorin.orange@gmail.com","username":"tmorin"},"change_message_id":"f068e687b1cee708de9d5ca8d8f8a413e03f4c21","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":2,"id":"5f7c97a3_6ef8cf48","line":131,"updated":"2018-06-05 12:47:14.000000000","message":"I think it would be good to add a test to check that if we allocated the value requested by the hint, that current_id has been moved to a different value for the next allocation\n\neg.\n\nx \u003d get_new_id()  # current value is x+1 after this call\ny \u003d get_new_id(x+1) # we allocated something that collides with current_value\nz \u003d get_new_id() # is z equals to x+1 or x+2\n\nself.assertEqual(z !\u003d y)","commit_id":"87534e07b9063804ba9886cb346475647e86e598"}]}
