本文整理汇总了Python中couchbase.cluster.Cluster.async_rebalance方法的典型用法代码示例。如果您正苦于以下问题:Python Cluster.async_rebalance方法的具体用法?Python Cluster.async_rebalance怎么用?Python Cluster.async_rebalance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类couchbase.cluster.Cluster
的用法示例。
在下文中一共展示了Cluster.async_rebalance方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: XDCRBaseTest
# 需要导入模块: from couchbase.cluster import Cluster [as 别名]
# 或者: from couchbase.cluster.Cluster import async_rebalance [as 别名]
#.........这里部分代码省略.........
self._sasl_buckets_int = self._input.param("sasl_buckets", 0)
self._total_buckets_int = self._sasl_buckets_int + self._default_bucket_bool + self._standard_buckets_int
#self.num_servers = self._input.param("servers", len(self.servers))
self._num_replicas_int = self._input.param("replicas", 1)
self._num_items_int = self._input.param("items", 1000)
self._dgm_run_bool = self._input.param("dgm_run", False)
self._mem_quota_int = 0 # will be set in subsequent methods
self.init_parameters_extended()
self._log.info("Initializing input parameters completed...")
def _init_clusters(self):
for key in self._clusters_keys_olst:
self._set_cluster_names(key)
self._setup_cluster(self._clusters_dic[key])
# This method shall be overridden in case there are parameters that need to be initialized.
def init_parameters_extended(self):
pass
# This method shall be overridden in case there are custom steps involved during setup.
def setup_extended(self):
pass
# This method shall be overridden in case there are custom steps involved during teardown.
def teardown_extended(self):
pass
def _do_cleanup(self):
for key in self._clusters_keys_olst:
nodes = self._clusters_dic[key]
BucketOperationHelper.delete_all_buckets_or_assert(nodes, self)
ClusterOperationHelper.cleanup_cluster(nodes)
ClusterOperationHelper.wait_for_ns_servers_or_assert(nodes, self)
def _cleanup_broken_setup(self):
try:
self.tearDown()
except:
self._log.info("Error while cleaning broken setup.")
def _set_cluster_names(self, key):
self._cluster_counter_temp_int += 1
self._cluster_names_dic[key] = "cluster-{0}".format(self._cluster_counter_temp_int)
def _setup_cluster(self, nodes):
self._init_nodes(nodes)
self._create_buckets(nodes)
self._config_cluster(nodes)
def _init_nodes(self, nodes):
_tasks = []
for node in nodes:
_tasks.append(self._cluster_helper.async_init_node(node))
for task in _tasks:
mem_quota_node = task.result()
if mem_quota_node < self._mem_quota_int or self._mem_quota_int == 0:
self._mem_quota_int = mem_quota_node
def _create_buckets(self, nodes):
master_node = nodes[0]
if self._dgm_run_bool:
self._mem_quota_int = 256
bucket_size = self._get_bucket_size(master_node, nodes, self._mem_quota_int, self._total_buckets_int)
if self._default_bucket_bool:
self._cluster_helper.create_default_bucket(master_node, bucket_size, self._num_replicas_int)
#self._buckets_arr['default'] = {1 : KVStore()} # - not sure abou this
self._create_sasl_buckets(master_node, bucket_size, self._sasl_buckets_int)
# TODO (Mike): Create Standard buckets
def _create_sasl_buckets(self, master_node, bucket_size, num_buckets):
bucket_tasks = []
for i in range(num_buckets):
name = 'bucket' + str(i)
bucket_tasks.append(self.self.cluster_helper.async_create_sasl_bucket(master_node, name,
'password', bucket_size,
self._num_replicas_int))
task.result()
def _config_cluster(self, nodes):
task = self._cluster_helper.async_rebalance(nodes, nodes[1:], [])
#self._buckets_arr[name] = {1 : KVStore()}
for task in bucket_tasks:
task.result()
def _config_cluster(self, nodes):
task = self._cluster_helper.async_rebalance(nodes, nodes[1:], [])
task.result()
def _get_bucket_size(self, master_node, nodes, mem_quota, num_buckets, ratio = 2.0 / 3.0):
for node in nodes:
if node.ip == master_node.ip:
return int(ratio / float(len(nodes)) / float(num_buckets) * float(mem_quota))
return int(ratio / float(num_buckets) * float(mem_quota))