本文整理汇总了Python中membase.api.rest_client.RestConnection.monitorRebalance方法的典型用法代码示例。如果您正苦于以下问题:Python RestConnection.monitorRebalance方法的具体用法?Python RestConnection.monitorRebalance怎么用?Python RestConnection.monitorRebalance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类membase.api.rest_client.RestConnection
的用法示例。
在下文中一共展示了RestConnection.monitorRebalance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _common_test_body
# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import monitorRebalance [as 别名]
def _common_test_body(self, moxi=False):
master = self.servers[0]
rest = RestConnection(master)
creds = self.input.membase_settings
bucket_data = RebalanceBaseTest.bucket_data_init(rest)
for server in self.servers[1:]:
self.log.info("current nodes : {0}".format(RebalanceHelper.getOtpNodeIds(master)))
self.log.info("adding node {0}:{1} and rebalance afterwards".format(server.ip, server.port))
otpNode = rest.add_node(creds.rest_username, creds.rest_password, server.ip, server.port)
msg = "unable to add node {0} to the cluster {1}"
self.assertTrue(otpNode, msg.format(server.ip, master.ip))
for name in bucket_data:
inserted_keys, rejected_keys = \
MemcachedClientHelper.load_bucket_and_return_the_keys(servers=[self.servers[0]],
name=name,
ram_load_ratio= -1,
number_of_items=self.keys_count,
number_of_threads=1,
write_only=True)
rest.rebalance(otpNodes=[node.id for node in rest.node_statuses()], ejectedNodes=[])
self.assertTrue(rest.monitorRebalance(),
msg="rebalance operation failed after adding node {0}".format(server.ip))
self.log.info("completed rebalancing in server {0}".format(server))
IncrementalRebalanceWithParallelReadTests._reader_thread(self, inserted_keys, bucket_data, moxi=moxi)
self.assertTrue(rest.monitorRebalance(),
msg="rebalance operation failed after adding node {0}".format(server.ip))
break
示例2: undo_failover
# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import monitorRebalance [as 别名]
def undo_failover(self, failover_nodes):
self.log.info("Add nodes back to the cluster: {0}".format(failover_nodes))
rest = RestConnection(self.servers[0])
self._start_servers(failover_nodes)
rest.rebalance(otpNodes=set([node.id for node in rest.node_statuses()] +
[node.id for node in failover_nodes]),
ejectedNodes=[])
rest.monitorRebalance()
示例3: rebalance_in
# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import monitorRebalance [as 别名]
def rebalance_in(servers, how_many, do_shuffle=True, monitor=True):
servers_rebalanced = []
log = logger.Logger.get_logger()
rest = RestConnection(servers[0])
nodes = rest.node_statuses()
nodeIps = ["{0}:{1}".format(node.ip,node.port) for node in nodes]
log.info("current nodes : {0}".format(nodeIps))
toBeAdded = []
master = servers[0]
selection = servers[1:]
if do_shuffle:
shuffle(selection)
for server in selection:
if not "{0}:{1}".format(server.ip,server.port) in nodeIps:
toBeAdded.append(server)
servers_rebalanced.append(server)
if len(toBeAdded) == int(how_many):
break
for server in toBeAdded:
otpNode = rest.add_node(master.rest_username, master.rest_password,
server.ip, server.port)
otpNodes = [node.id for node in rest.node_statuses()]
started = rest.rebalance(otpNodes, [])
msg = "rebalance operation started ? {0}"
log.info(msg.format(started))
if monitor is not True:
return True, servers_rebalanced
if started:
result = rest.monitorRebalance()
msg = "successfully rebalanced in selected nodes from the cluster ? {0}"
log.info(msg.format(result))
return result, servers_rebalanced
return False, servers_rebalanced
示例4: common_setup
# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import monitorRebalance [as 别名]
def common_setup(self, replica):
self._input = TestInputSingleton.input
self._servers = self._input.servers
first = self._servers[0]
self.log = logger.Logger().get_logger()
self.log.info(self._input)
rest = RestConnection(first)
for server in self._servers:
RestHelper(RestConnection(server)).is_ns_server_running()
ClusterOperationHelper.cleanup_cluster(self._servers)
BucketOperationHelper.delete_all_buckets_or_assert(self._servers, self)
ClusterOperationHelper.add_all_nodes_or_assert(self._servers[0], self._servers, self._input.membase_settings, self)
nodes = rest.node_statuses()
otpNodeIds = []
for node in nodes:
otpNodeIds.append(node.id)
info = rest.get_nodes_self()
bucket_ram = info.mcdMemoryReserved * 3 / 4
rest.create_bucket(bucket="default",
ramQuotaMB=int(bucket_ram),
replicaNumber=replica,
proxyPort=rest.get_nodes_self().moxi)
msg = "wait_for_memcached fails"
ready = BucketOperationHelper.wait_for_memcached(first, "default"),
self.assertTrue(ready, msg)
rebalanceStarted = rest.rebalance(otpNodeIds, [])
self.assertTrue(rebalanceStarted,
"unable to start rebalance on master node {0}".format(first.ip))
self.log.info('started rebalance operation on master node {0}'.format(first.ip))
rebalanceSucceeded = rest.monitorRebalance()
# without a bucket this seems to fail
self.assertTrue(rebalanceSucceeded,
"rebalance operation for nodes: {0} was not successful".format(otpNodeIds))
self.awareness = VBucketAwareMemcached(rest, "default")
示例5: setUp
# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import monitorRebalance [as 别名]
def setUp(self):
self._cleanup_nodes = []
self._failed_nodes = []
super(FailoverBaseTest, self).setUp()
self.bidirectional = self.input.param("bidirectional", False)
self._value_size = self.input.param("value_size", 256)
self.dgm_run = self.input.param("dgm_run", True)
credentials = self.input.membase_settings
self.add_back_flag = False
self.during_ops = self.input.param("during_ops", None)
self.log.info(
"============== FailoverBaseTest setup was started for test #{0} {1}==============".format(
self.case_number, self._testMethodName
)
)
try:
rest = RestConnection(self.master)
ClusterOperationHelper.add_all_nodes_or_assert(self.master, self.servers, credentials, self)
nodes = rest.node_statuses()
rest.rebalance(otpNodes=[node.id for node in nodes], ejectedNodes=[])
msg = "rebalance failed after adding these nodes {0}".format(nodes)
self.assertTrue(rest.monitorRebalance(), msg=msg)
except Exception, e:
self.cluster.shutdown()
self.fail(e)
示例6: setUp
# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import monitorRebalance [as 别名]
def setUp(self):
self.log = logger.Logger.get_logger()
self.input = TestInputSingleton.input
self.assertTrue(self.input, msg="input parameters missing...")
self.servers = self.input.servers
self.master = self.servers[0]
rest = RestConnection(self.master)
rest.init_cluster(username=self.master.rest_username,
password=self.master.rest_password)
info = rest.get_nodes_self()
node_ram_ratio = BucketOperationHelper.base_bucket_ratio(self.servers)
rest.init_cluster_memoryQuota(memoryQuota=int(info.mcdMemoryReserved * node_ram_ratio))
BucketOperationHelper.delete_all_buckets_or_assert(servers=self.servers, test_case=self)
ClusterOperationHelper.cleanup_cluster(servers=self.servers)
credentials = self.input.membase_settings
ClusterOperationHelper.add_all_nodes_or_assert(master=self.master, all_servers=self.servers, rest_settings=credentials, test_case=self)
rest = RestConnection(self.master)
nodes = rest.node_statuses()
otpNodeIds = []
for node in nodes:
otpNodeIds.append(node.id)
rebalanceStarted = rest.rebalance(otpNodeIds, [])
self.assertTrue(rebalanceStarted,
"unable to start rebalance on master node {0}".format(self.master.ip))
self.log.info('started rebalance operation on master node {0}'.format(self.master.ip))
rebalanceSucceeded = rest.monitorRebalance()
示例7: _add_and_rebalance
# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import monitorRebalance [as 别名]
def _add_and_rebalance(self, servers, wait_for_rebalance=True):
log = logger.Logger.get_logger()
master = servers[0]
all_nodes_added = True
rebalanced = True
rest = RestConnection(master)
if len(servers) > 1:
for serverInfo in servers[1:]:
log.info('adding {0} node : {1}:{2} to the cluster'.format(
serverInfo.services, serverInfo.ip, serverInfo.port))
services = serverInfo.services.split()
if self.skip_services:
services = None
otpNode = rest.add_node(master.rest_username, master.rest_password, serverInfo.ip, port=serverInfo.port,
services=services)
if otpNode:
log.info('added node : {0} to the cluster'.format(otpNode.id))
else:
all_nodes_added = False
break
if all_nodes_added:
rest.rebalance(otpNodes=[node.id for node in rest.node_statuses()], ejectedNodes=[])
if wait_for_rebalance:
rebalanced &= rest.monitorRebalance()
else:
rebalanced = False
return all_nodes_added and rebalanced
示例8: rebalance_in
# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import monitorRebalance [as 别名]
def rebalance_in(self, how_many):
rest = RestConnection(self._servers[0])
nodes = rest.node_statuses()
#choose how_many nodes from self._servers which are not part of
# nodes
nodeIps = [node.ip for node in nodes]
self.log.info("current nodes : {0}".format(nodeIps))
toBeAdded = []
selection = self._servers[1:]
shuffle(selection)
for server in selection:
if not server.ip in nodeIps:
toBeAdded.append(server)
if len(toBeAdded) == how_many:
break
for server in toBeAdded:
rest.add_node('Administrator', 'password', server.ip)
#check if its added ?
nodes = rest.node_statuses()
otpNodes = [node.id for node in nodes]
started = rest.rebalance(otpNodes, [])
msg = "rebalance operation started ? {0}"
self.log.info(msg.format(started))
if started:
result = rest.monitorRebalance()
msg = "successfully rebalanced out selected nodes from the cluster ? {0}"
self.log.info(msg.format(result))
return result
return False
示例9: _setup_cluster
# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import monitorRebalance [as 别名]
def _setup_cluster(self):
rest = RestConnection(self.master)
credentials = self._input.membase_settings
ClusterOperationHelper.add_all_nodes_or_assert(self.master, self._servers, credentials, self)
nodes = rest.node_statuses()
rest.rebalance(otpNodes=[node.id for node in nodes], ejectedNodes=[])
msg = "rebalance failed after adding these nodes {0}".format(nodes)
self.assertTrue(rest.monitorRebalance(), msg=msg)
示例10: _failover_swap_rebalance
# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import monitorRebalance [as 别名]
def _failover_swap_rebalance(self):
master = self.servers[0]
rest = RestConnection(master)
creds = self.input.membase_settings
num_initial_servers = self.num_initial_servers
intial_severs = self.servers[:num_initial_servers]
self.log.info("CREATE BUCKET PHASE")
SwapRebalanceBase.create_buckets(self)
# Cluster all starting set of servers
self.log.info("INITIAL REBALANCE PHASE")
status, servers_rebalanced = RebalanceHelper.rebalance_in(intial_severs, len(intial_severs) - 1)
self.assertTrue(status, msg="Rebalance was failed")
self.log.info("DATA LOAD PHASE")
self.loaders = SwapRebalanceBase.start_load_phase(self, master)
# Wait till load phase is over
SwapRebalanceBase.stop_load(self.loaders, do_stop=False)
self.log.info("DONE LOAD PHASE")
# Start the swap rebalance
self.log.info("current nodes : {0}".format(RebalanceHelper.getOtpNodeIds(master)))
toBeEjectedNodes = RebalanceHelper.pick_nodes(master, howmany=self.failover_factor)
optNodesIds = [node.id for node in toBeEjectedNodes]
if self.fail_orchestrator:
status, content = ClusterOperationHelper.find_orchestrator(master)
self.assertTrue(status, msg="Unable to find orchestrator: {0}:{1}".\
format(status, content))
optNodesIds[0] = content
self.log.info("FAILOVER PHASE")
# Failover selected nodes
for node in optNodesIds:
self.log.info("failover node {0} and rebalance afterwards".format(node))
rest.fail_over(node)
new_swap_servers = self.servers[num_initial_servers:num_initial_servers + self.failover_factor]
for server in new_swap_servers:
otpNode = rest.add_node(creds.rest_username, creds.rest_password, server.ip)
msg = "unable to add node {0} to the cluster"
self.assertTrue(otpNode, msg.format(server.ip))
if self.fail_orchestrator:
rest = RestConnection(new_swap_servers[0])
master = new_swap_servers[0]
self.log.info("DATA ACCESS PHASE")
self.loaders = SwapRebalanceBase.start_access_phase(self, master)
rest.rebalance(otpNodes=[node.id for node in rest.node_statuses()], \
ejectedNodes=optNodesIds)
self.assertTrue(rest.monitorRebalance(),
msg="rebalance operation failed after adding node {0}".format(new_swap_servers))
SwapRebalanceBase.verification_phase(self, master)
示例11: rebalance_in
# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import monitorRebalance [as 别名]
def rebalance_in(servers, how_many, do_shuffle=True, monitor=True, do_check=True):
servers_rebalanced = []
log = logger.Logger.get_logger()
rest = RestConnection(servers[0])
nodes = rest.node_statuses()
#are all ips the same
nodes_on_same_ip = True
firstIp = nodes[0].ip
if len(nodes) == 1:
nodes_on_same_ip = False
else:
for node in nodes:
if node.ip != firstIp:
nodes_on_same_ip = False
break
nodeIps = ["{0}:{1}".format(node.ip,node.port) for node in nodes]
log.info("current nodes : {0}".format(nodeIps))
toBeAdded = []
master = servers[0]
selection = servers[1:]
if do_shuffle:
shuffle(selection)
for server in selection:
if nodes_on_same_ip:
if not "{0}:{1}".format(firstIp,server.port) in nodeIps:
toBeAdded.append(server)
servers_rebalanced.append(server)
log.info("choosing {0}:{1}".format(server.ip, server.port))
elif not "{0}:{1}".format(server.ip,server.port) in nodeIps:
toBeAdded.append(server)
servers_rebalanced.append(server)
log.info("choosing {0}:{1}".format(server.ip, server.port))
if len(toBeAdded) == int(how_many):
break
if do_check and len(toBeAdded) < how_many:
raise Exception("unable to find {0} nodes to rebalance_in".format(how_many))
for server in toBeAdded:
otpNode = rest.add_node(master.rest_username, master.rest_password,
server.ip, server.port)
otpNodes = [node.id for node in rest.node_statuses()]
started = rest.rebalance(otpNodes, [])
msg = "rebalance operation started ? {0}"
log.info(msg.format(started))
if monitor is not True:
return True, servers_rebalanced
if started:
try:
result = rest.monitorRebalance()
except RebalanceFailedException as e:
log.error("rebalance failed: {0}".format(e))
return False, servers_rebalanced
msg = "successfully rebalanced in selected nodes from the cluster ? {0}"
log.info(msg.format(result))
return result, servers_rebalanced
return False, servers_rebalanced
示例12: end_rebalance
# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import monitorRebalance [as 别名]
def end_rebalance(master):
log = logger.Logger.get_logger()
rest = RestConnection(master)
result = False
try:
result = rest.monitorRebalance()
except RebalanceFailedException as e:
log.error("rebalance failed: {0}".format(e))
assert result, "rebalance operation failed after adding nodes"
log.info("rebalance finished")
示例13: rebalance_servers_in
# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import monitorRebalance [as 别名]
def rebalance_servers_in(servers, rest_settings, testcase):
log = logger.Logger().get_logger()
master = servers[0]
rest = RestConnection(master)
ClusterOperationHelper.add_all_nodes_or_assert(master, servers, rest_settings, testcase)
otpNodeIds = []
for node in rest.node_statuses():
otpNodeIds.append(node.id)
rebalanceStarted = rest.rebalance(otpNodeIds, [])
testcase.assertTrue(rebalanceStarted,
"unable to start rebalance on master node {0}".format(master.ip))
log.info('started rebalance operation on master node {0}'.format(master.ip))
rebalanceSucceeded = rest.monitorRebalance()
testcase.assertTrue(rebalanceSucceeded,
"rebalance operation for nodes: {0} was not successful".format(otpNodeIds))
示例14: _cluster_setup
# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import monitorRebalance [as 别名]
def _cluster_setup(self):
log = logger.Logger.get_logger()
replicas = self._input.param("replicas", 1)
keys_count = self._input.param("keys-count", 0)
num_buckets = self._input.param("num-buckets", 1)
bucket_name = "default"
master = self._servers[0]
credentials = self._input.membase_settings
rest = RestConnection(master)
info = rest.get_nodes_self()
rest.init_cluster(username=master.rest_username,
password=master.rest_password)
rest.init_cluster_memoryQuota(memoryQuota=info.mcdMemoryReserved)
rest.reset_autofailover()
ClusterOperationHelper.add_all_nodes_or_assert(master, self._servers, credentials, self)
bucket_ram = info.memoryQuota * 2 / 3
if num_buckets == 1:
rest.create_bucket(bucket=bucket_name,
ramQuotaMB=bucket_ram,
replicaNumber=replicas,
proxyPort=info.moxi)
ready = BucketOperationHelper.wait_for_memcached(master, bucket_name)
nodes = rest.node_statuses()
rest.rebalance(otpNodes=[node.id for node in nodes], ejectedNodes=[])
buckets = rest.get_buckets()
else:
created = BucketOperationHelper.create_multiple_buckets(master, replicas, howmany=num_buckets)
self.assertTrue(created, "unable to create multiple buckets")
buckets = rest.get_buckets()
for bucket in buckets:
ready = BucketOperationHelper.wait_for_memcached(master, bucket.name)
self.assertTrue(ready, msg="wait_for_memcached failed")
nodes = rest.node_statuses()
rest.rebalance(otpNodes=[node.id for node in nodes], ejectedNodes=[])
# self.load_data(master, bucket_name, keys_count)
for bucket in buckets:
inserted_keys_cnt = self.load_data(master, bucket.name, keys_count)
log.info('inserted {0} keys'.format(inserted_keys_cnt))
msg = "rebalance failed after adding these nodes {0}".format(nodes)
self.assertTrue(rest.monitorRebalance(), msg=msg)
self.assertTrue(ready, "wait_for_memcached failed")
示例15: shuffle_nodes_between_zones_and_rebalance
# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import monitorRebalance [as 别名]
def shuffle_nodes_between_zones_and_rebalance(self, to_remove=None):
"""
Shuffle the nodes present in the cluster if zone > 1. Rebalance the nodes in the end.
Nodes are divided into groups iteratively i.e. 1st node in Group 1, 2nd in Group 2, 3rd in Group 1 and so on, when
zone=2.
:param to_remove: List of nodes to be removed.
"""
if not to_remove:
to_remove = []
serverinfo = self.servers[0]
rest = RestConnection(serverinfo)
zones = ["Group 1"]
nodes_in_zone = {"Group 1": [serverinfo.ip]}
# Create zones, if not existing, based on params zone in test.
# Shuffle the nodes between zones.
if int(self.zone) > 1:
for i in range(1, int(self.zone)):
a = "Group "
zones.append(a + str(i + 1))
if not rest.is_zone_exist(zones[i]):
rest.add_zone(zones[i])
nodes_in_zone[zones[i]] = []
# Divide the nodes between zones.
nodes_in_cluster = [node.ip for node in self.get_nodes_in_cluster()]
nodes_to_remove = [node.ip for node in to_remove]
for i in range(1, len(self.servers)):
if self.servers[i].ip in nodes_in_cluster and self.servers[i].ip not in nodes_to_remove:
server_group = i % int(self.zone)
nodes_in_zone[zones[server_group]].append(self.servers[i].ip)
# Shuffle the nodesS
for i in range(1, self.zone):
node_in_zone = list(set(nodes_in_zone[zones[i]]) -
set([node for node in rest.get_nodes_in_zone(zones[i])]))
rest.shuffle_nodes_in_zones(node_in_zone, zones[0], zones[i])
otpnodes = [node.id for node in rest.node_statuses()]
nodes_to_remove = [node.id for node in rest.node_statuses() if node.ip in [t.ip for t in to_remove]]
# Start rebalance and monitor it.
started = rest.rebalance(otpNodes=otpnodes, ejectedNodes=nodes_to_remove)
if started:
result = rest.monitorRebalance()
msg = "successfully rebalanced cluster {0}"
self.log.info(msg.format(result))
# Verify replicas of one node should not be in the same zone as active vbuckets of the node.
if self.zone > 1:
self._verify_replica_distribution_in_zones(nodes_in_zone)