当前位置: 首页>>代码示例>>Python>>正文


Python RemoteHelper.start_server方法代码示例

本文整理汇总了Python中perfrunner.helpers.remote.RemoteHelper.start_server方法的典型用法代码示例。如果您正苦于以下问题:Python RemoteHelper.start_server方法的具体用法?Python RemoteHelper.start_server怎么用?Python RemoteHelper.start_server使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在perfrunner.helpers.remote.RemoteHelper的用法示例。


在下文中一共展示了RemoteHelper.start_server方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: RestoreHelper

# 需要导入模块: from perfrunner.helpers.remote import RemoteHelper [as 别名]
# 或者: from perfrunner.helpers.remote.RemoteHelper import start_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()
开发者ID:mahesh152,项目名称:perfrunner,代码行数:70,代码来源:restore.py


注:本文中的perfrunner.helpers.remote.RemoteHelper.start_server方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。