本文整理汇总了Python中lib.membase.api.rest_client.RestConnection.active_tasks方法的典型用法代码示例。如果您正苦于以下问题:Python RestConnection.active_tasks方法的具体用法?Python RestConnection.active_tasks怎么用?Python RestConnection.active_tasks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lib.membase.api.rest_client.RestConnection
的用法示例。
在下文中一共展示了RestConnection.active_tasks方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: measure_indexing_throughput
# 需要导入模块: from lib.membase.api.rest_client import RestConnection [as 别名]
# 或者: from lib.membase.api.rest_client.RestConnection import active_tasks [as 别名]
def measure_indexing_throughput(self, nodes):
self._task['indexer_info'] = list()
indexers = defaultdict(dict)
while not self._aborted():
time.sleep(15) # 15 seconds by default
# Grab indexer tasks from all nodes
tasks = list()
for node in nodes:
rest = RestConnection(node)
tasks.extend(filter(lambda t: t['type'] == 'indexer',
rest.active_tasks()))
# Calculate throughput for every unique PID
thr = 0
for task in tasks:
uiid = task['pid'] + str(task['started_on'])
changes_delta = \
task['changes_done'] - indexers[uiid].get('changes_done', 0)
time_delta = \
task['updated_on'] - indexers[uiid].get('updated_on',
task['started_on'])
if time_delta:
thr += changes_delta / time_delta
indexers[uiid]['changes_done'] = task['changes_done']
indexers[uiid]['updated_on'] = task['updated_on']
# Average throughput
self._task['indexer_info'].append({
'indexing_throughput': thr,
'timestamp': time.time()
})