本文整理汇总了Python中perfrunner.helpers.remote.RemoteHelper.stop_server方法的典型用法代码示例。如果您正苦于以下问题:Python RemoteHelper.stop_server方法的具体用法?Python RemoteHelper.stop_server怎么用?Python RemoteHelper.stop_server使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类perfrunner.helpers.remote.RemoteHelper
的用法示例。
在下文中一共展示了RemoteHelper.stop_server方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: RestoreHelper
# 需要导入模块: from perfrunner.helpers.remote import RemoteHelper [as 别名]
# 或者: from perfrunner.helpers.remote.RemoteHelper import stop_server [as 别名]
class RestoreHelper(object):
def __init__(self, cluster_spec, test_config, verbose):
self.cluster_spec = cluster_spec
self.test_config = test_config
self.verbose = verbose
self.snapshot = self.test_config.restore_settings.snapshot
self.remote = RemoteHelper(self.cluster_spec, self.test_config,
self.verbose)
def fetch_maps(self):
rest = RestHelper(self.cluster_spec)
master_node = self.cluster_spec.yield_masters().next()
maps = {}
for bucket in self.test_config.buckets:
vbmap = rest.get_vbmap(master_node, bucket)
server_list = rest.get_server_list(master_node, bucket)
maps[bucket] = (vbmap, server_list)
return maps
def cp(self, server, cmd):
logger.info('Restoring files on {}'.format(server))
with settings(host_string=server,
user=self.cluster_spec.ssh_credentials[0],
password=self.cluster_spec.ssh_credentials[1]):
run(cmd)
def restore(self):
maps = self.fetch_maps()
self.remote.stop_server()
threads = []
for bucket, (vbmap, server_list) in maps.items():
files = defaultdict(list)
for vb_idx, nodes in enumerate(vbmap):
for node_idx in nodes:
files[server_list[node_idx]].append(vb_idx)
for server, vbuckets in files.items():
cmd = 'cp '
for vbucket in vbuckets:
cmd += '{}/{}.couch.1 '.format(self.snapshot, vbucket)
cmd += '/data/{}'.format(bucket)
threads.append(Thread(target=self.cp, args=(server, cmd)))
for t in threads:
t.start()
time.sleep(1)
for t in threads:
t.join()
state.connections.clear()
self.remote.drop_caches()
self.remote.start_server()
def warmup(self):
cm = ClusterManager(self.cluster_spec, self.test_config, self.verbose)
cm.wait_until_warmed_up()
cm.wait_until_healthy()