本文整理汇总了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)