本文整理汇总了Python中lib.membase.api.rest_client.RestConnection.ns_server_tasks方法的典型用法代码示例。如果您正苦于以下问题:Python RestConnection.ns_server_tasks方法的具体用法?Python RestConnection.ns_server_tasks怎么用?Python RestConnection.ns_server_tasks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lib.membase.api.rest_client.RestConnection
的用法示例。
在下文中一共展示了RestConnection.ns_server_tasks方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: rebalance_progress
# 需要导入模块: from lib.membase.api.rest_client import RestConnection [as 别名]
# 或者: from lib.membase.api.rest_client.RestConnection import ns_server_tasks [as 别名]
def rebalance_progress(self, interval=15):
self._task["rebalance_progress"] = list()
nodes = cycle(self.nodes)
rest = RestConnection(nodes.next())
while not self._aborted():
try:
tasks = rest.ns_server_tasks()
except ServerUnavailableException, error:
log.error(error)
rest = RestConnection(nodes.next())
continue
for task in tasks:
if task["type"] == "rebalance":
self._task["rebalance_progress"].append({
"rebalance_progress": task.get("progress", 0),
"timestamp": time.time()
})
break
time.sleep(interval)
示例2: PerfBase
# 需要导入模块: from lib.membase.api.rest_client import RestConnection [as 别名]
# 或者: from lib.membase.api.rest_client.RestConnection import ns_server_tasks [as 别名]
#.........这里部分代码省略.........
"""
if not self.input.servers:
self.log.error("empty server list")
return
if collect_stats:
client_id = self.parami("prefix", 0)
test_params = {'test_time': time.time(),
'test_name': self.id(),
'json': 0}
sc = self.start_stats(self.spec_reference + ".warmup",
test_params=test_params,
client_id=client_id)
self.log.info("preparing to warmup cluster ...")
server = self.input.servers[0]
shell = RemoteMachineShellConnection(server)
start_time = time.time()
self.log.info("stopping couchbase ... ({0})".format(server.ip))
shell.stop_couchbase()
self.log.info("couchbase stopped ({0})".format(server.ip))
if flush_os_cache:
self.log.info("flushing os cache ...")
shell.flush_os_caches()
shell.start_couchbase()
self.log.info("couchbase restarted ({0})".format(server.ip))
self.wait_until_warmed_up()
self.log.info("warmup finished")
end_time = time.time()
ops = {'tot-sets': 0,
'tot-gets': 0,
'tot-items': 0,
'tot-creates': 0,
'tot-misses': 0,
"start-time": start_time,
"end-time": end_time}
if collect_stats:
self.end_stats(sc, ops, self.spec_reference + ".warmup")
def wait_until_warmed_up(self, master=None):
if not master:
master = self.input.servers[0]
bucket = self.param("bucket", "default")
fn = RebalanceHelper.wait_for_mc_stats_no_timeout
for bucket in self.buckets:
RebalanceHelper.wait_for_stats_on_all(master, bucket,
'ep_warmup_thread',
'complete', fn=fn)
def set_param(self, name, val):
input = getattr(self, "input", TestInputSingleton.input)
input.test_params[name] = str(val)
return True
def wait_for_task_completion(self, task='indexer'):
"""Wait for ns_server task to finish"""
t0 = time.time()
self.log.info("Waiting 30 seconds before {0} monitoring".format(task))
time.sleep(30)
while True:
tasks = self.rest.ns_server_tasks()
if tasks:
try:
progress = [t['progress'] for t in tasks if t['type'] == task]
except TypeError:
self.log.error(tasks)
else:
if progress:
self.log.info("{0} progress: {1}".format(task, progress))
time.sleep(10)
else:
break
t1 = time.time()
self.log.info("Time taken to perform task: {0} sec".format(t1 - t0))
def param(self, name, default_value):
input = getattr(self, "input", TestInputSingleton.input)
return input.test_params.get(name, default_value)
def parami(self, name, default_int):
return int(self.param(name, default_int))
def paramf(self, name, default_float):
return float(self.param(name, default_float))
def params(self, name, default_str):
return str(self.param(name, default_str))