示例#1
0
    def fetch_routing_info(self, address):
        """ Fetch raw routing info from a given router address.

        :param address: router address
        :return: list of routing records or
                 None if no connection could be established
        :raise ServiceUnavailable: if the server does not support routing or
                                   if routing support is broken
        """
        metadata = {}
        records = []

        def fail(md):
            if md.get("code") == "Neo.ClientError.Procedure.ProcedureNotFound":
                raise RoutingProtocolError("Server {!r} does not support routing".format(address))
            else:
                raise RoutingProtocolError("Routing support broken on server {!r}".format(address))

        try:
            with self.acquire_direct(address) as cx:
                _, _, server_version = (cx.server.agent or "").partition("/")
                if server_version and Version.parse(server_version) >= Version((3, 2)):
                    cx.run("CALL dbms.cluster.routing.getRoutingTable({context})",
                           {"context": self.routing_context}, on_success=metadata.update, on_failure=fail)
                else:
                    cx.run("CALL dbms.cluster.routing.getServers", {}, on_success=metadata.update, on_failure=fail)
                cx.pull_all(on_success=metadata.update, on_records=records.extend)
                cx.sync()
        except RoutingProtocolError as error:
            raise ServiceUnavailable(*error.args)
        except ServiceUnavailable:
            self.deactivate(address)
            return None
        else:
            return [dict(zip(metadata.get("fields", ()), values)) for values in records]
示例#2
0
 def test_double_dot(self):
     v = Version.parse("1.2..3")
     self.assertEqual(v, ((1, 2, 0, 3), ))
示例#3
0
 def test_double_dash(self):
     v = Version.parse("1.2--3")
     self.assertEqual(v, ((1, 2), (0, ), (3, )))
示例#4
0
 def test_snapshot(self):
     v = Version.parse("1.2-snapshot")
     self.assertEqual(v, ((1, 2), ("snapshot", )))
示例#5
0
 def test_alpha(self):
     v = Version.parse("1.2.3-alpha01")
     self.assertEqual(v, ((1, 2, 3), ("alpha", ), (1, )))
示例#6
0
 def test_major_minor_patch(self):
     v = Version.parse("1.2.3")
     self.assertEqual(v, ((1, 2, 3), ))
示例#7
0
 def test_major_minor(self):
     v = Version.parse("1.2")
     self.assertEqual(v, ((1, 2), ))