connection.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:importacsv 作者: rasertux 项目源码 文件源码
def get_fabric_servers(self, fabric_cnx=None):
        """Get all MySQL Fabric instances

        This method looks up the other MySQL Fabric instances which uses
        the same metadata. The returned list contains dictionaries with
        connection information such ass host and port. For example:

        [
            {'host': 'fabric_prod_1.example.com', 'port': 32274 },
            {'host': 'fabric_prod_2.example.com', 'port': 32274 },
        ]

        Returns a list of dictionaries
        """
        inst = fabric_cnx or self.get_instance()
        result = []
        err_msg = "Looking up Fabric servers failed using {host}:{port}: {err}"
        try:
            fset = inst.execute('dump', 'fabric_nodes',
                                "protocol." + self._protocol)

            for row in fset.rows():
                result.append({'host': row.host, 'port': row.port})
        except (Fault, socket.error) as exc:
            msg = err_msg.format(err=str(exc), host=inst.handler.host,
                                 port=inst.handler.port)
            raise InterfaceError(msg)
        except (TypeError, AttributeError) as exc:
            msg = err_msg.format(
                err="No Fabric server available ({0})".format(exc),
                host=inst.handler.host, port=inst.handler.port)
            raise InterfaceError(msg)

        try:
            fabric_uuid = uuid.UUID(fset.fabric_uuid_str)
        except TypeError:
            fabric_uuid = uuid.uuid4()

        fabric_version = 0

        return fabric_uuid, fabric_version, fset.ttl, result
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号