当前位置: 首页>>代码示例>>Python>>正文


Python ServerProxy.replicate_chunk方法代码示例

本文整理汇总了Python中xmlrpc.client.ServerProxy.replicate_chunk方法的典型用法代码示例。如果您正苦于以下问题:Python ServerProxy.replicate_chunk方法的具体用法?Python ServerProxy.replicate_chunk怎么用?Python ServerProxy.replicate_chunk使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在xmlrpc.client.ServerProxy的用法示例。


在下文中一共展示了ServerProxy.replicate_chunk方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: replicate

# 需要导入模块: from xmlrpc.client import ServerProxy [as 别名]
# 或者: from xmlrpc.client.ServerProxy import replicate_chunk [as 别名]
    def replicate(self, item):
        if item is None:
            return

        path = item[0]
        cs_list = item[1]

        alive = [x for x in cs_list if self.ns._is_alive_cs(x)]

        if len(alive) == 0:
            print('There no live cs for chunk', path)
            return

        if len(alive) >= 2:
            print('File', path, 'is already replicated to more than 2 nodes')
            return

        new_cs = self.ns._select_available_cs(alive)
        if new_cs is None:
            print("Can't find available cs for replication", path)
        else:
            try:
                cl = ServerProxy(alive[0])
                cl.replicate_chunk(path, new_cs)
                print("File", path, "replicated to", new_cs)

                file = self.ns.root.find_file_by_chunk(path)
                if file is not None and path in file.chunks:
                    file.chunks[path].append(new_cs)
                else:
                    print("Cant find file for chunk", path, "after replication")
            except Exception as e:
                print('Error during replicatiion', path, 'to', new_cs, ':', e)
开发者ID:osteotek,项目名称:yadfs,代码行数:35,代码来源:replicator.py


注:本文中的xmlrpc.client.ServerProxy.replicate_chunk方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。