本文整理汇总了Python中membase.helper.cluster_helper.ClusterOperationHelper.find_orchestrator_with_rest方法的典型用法代码示例。如果您正苦于以下问题:Python ClusterOperationHelper.find_orchestrator_with_rest方法的具体用法?Python ClusterOperationHelper.find_orchestrator_with_rest怎么用?Python ClusterOperationHelper.find_orchestrator_with_rest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类membase.helper.cluster_helper.ClusterOperationHelper
的用法示例。
在下文中一共展示了ClusterOperationHelper.find_orchestrator_with_rest方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update_orchestrator
# 需要导入模块: from membase.helper.cluster_helper import ClusterOperationHelper [as 别名]
# 或者: from membase.helper.cluster_helper.ClusterOperationHelper import find_orchestrator_with_rest [as 别名]
def update_orchestrator(self, ref_node = None, retry = 5):
if len(self.nodes) > 0:
if ref_node is None:
ref_node = self.nodes[0]
address = {'server_ip' : ref_node.ip, 'port' : ref_node.port}
rest = create_rest(**address)
status, content = ClusterOperationHelper.find_orchestrator_with_rest(rest)
if status == True:
content = re.sub(r".*@", "", content).strip("'").split(':')
orchestrator_ip, orchestrator_port = \
content[0], content[1] if len(content) > 1 else cfg.COUCHBASE_PORT
# look up matching node in self nodes
for node in self.nodes:
if node.ip == orchestrator_ip and \
int(node.port) == int(orchestrator_port):
self.orchestrator = node
break
elif retry > 0:
# wait
time.sleep(5)
# select random node and retry
ref_node = self.nodes[random.randint(0, len(self.nodes) - 1)]
retry = retry - 1
return self.update_orchestrator(ref_node, retry)