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


Python RestConnection.rebalance方法代码示例

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


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

示例1: CBASBaseTest

# 需要导入模块: from lib.membase.api.rest_client import RestConnection [as 别名]
# 或者: from lib.membase.api.rest_client.RestConnection import rebalance [as 别名]

#.........这里部分代码省略.........
            if "cbas" in self.master.services:
                self.cleanup_cbas()
            if add_defualt_cbas_node:
                if self.master.ip != self.cbas_node.ip:
                    self.otpNodes.append(self.add_node(self.cbas_node))
                else:
                    self.otpNodes = self.rest.node_statuses()
                ''' This cbas cleanup is actually not needed.
                    When a node is added to the cluster, it is automatically cleaned-up.'''
                self.cleanup_cbas()
                self.cbas_servers.remove(self.cbas_node)
        
        self.log.info("==============  CBAS_BASE setup was finished for test #{0} {1} ==============" \
                          .format(self.case_number, self._testMethodName))
    
    def create_default_bucket(self):
        node_info = self.rest.get_nodes_self()
        if node_info.memoryQuota and int(node_info.memoryQuota) > 0 :
            ram_available = node_info.memoryQuota
            
        self.bucket_size = ram_available - 1
        default_params=self._create_bucket_params(server=self.master, size=self.bucket_size,
                                                         replicas=self.num_replicas, bucket_type=self.bucket_type,
                                                         enable_replica_index=self.enable_replica_index,
                                                         eviction_policy=self.eviction_policy, lww=self.lww)
        self.cluster.create_default_bucket(default_params)
        self.buckets.append(Bucket(name="default", authType="sasl", saslPassword="",
                                   num_replicas=self.num_replicas, bucket_size=self.bucket_size,
                                   eviction_policy=self.eviction_policy, lww=self.lww,
                                   type=self.bucket_type))
        if self.enable_time_sync:
            self._set_time_sync_on_buckets( ['default'] )
    
    def add_all_cbas_node_then_rebalance(self):
        if len(self.cbas_servers)>=1:
            for server in self.cbas_servers:
                '''This is the case when master node is running cbas service as well'''
                if self.master.ip != server.ip:
                    self.otpNodes.append(self.rest.add_node(user=server.rest_username,
                                               password=server.rest_password,
                                               remoteIp=server.ip,
                                               port=8091,
                                               services=server.services.split(",")))
    
            self.rebalance()
        else:
            self.log.info("No CBAS server to add in cluster")

        return self.otpNodes
    
    def rebalance(self, wait_for_completion=True):
        nodes = self.rest.node_statuses()
        started = self.rest.rebalance(otpNodes=[node.id for node in nodes])
        if started and wait_for_completion:
            result = self.rest.monitorRebalance()
            self.assertTrue(result, "Rebalance operation failed after adding %s cbas nodes,"%self.cbas_servers)
            self.log.info("successfully rebalanced cluster {0}".format(result))
        else:
            self.assertTrue(started, "Rebalance operation started and in progress,"%self.cbas_servers)
        
    def remove_all_cbas_node_then_rebalance(self,cbas_otpnodes=None, rebalance=True ):
        return self.remove_node(cbas_otpnodes,rebalance) 
        
    def add_node(self, node=None, services=None, rebalance=True, wait_for_rebalance_completion=True):
        if not node:
            self.fail("There is no node to add to cluster.")
开发者ID:ritamcouchbase,项目名称:testrunner,代码行数:70,代码来源:cbas_base.py


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