本文整理汇总了Python中mc_bin_client.MemcachedClient.stats方法的典型用法代码示例。如果您正苦于以下问题:Python MemcachedClient.stats方法的具体用法?Python MemcachedClient.stats怎么用?Python MemcachedClient.stats使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mc_bin_client.MemcachedClient
的用法示例。
在下文中一共展示了MemcachedClient.stats方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: wait_for_mc_stats_no_timeout
# 需要导入模块: from mc_bin_client import MemcachedClient [as 别名]
# 或者: from mc_bin_client.MemcachedClient import stats [as 别名]
def wait_for_mc_stats_no_timeout(master, bucket, stat_key, stat_value, timeout_in_seconds=-1, verbose=True):
log.info(
"waiting for bucket {0} stat : {1} to match {2} on {3}".format(bucket, stat_key, stat_value, master.ip)
)
# keep retrying until reaches the server
stats = {}
while not stats:
try:
c = MemcachedClient(master.ip, 11210)
c.sasl_auth_plain(bucket, "")
stats = c.stats()
except Exception as e:
log.info("Exception: {0}, retry in 2 seconds ...".format(str(e)))
stats = {}
time.sleep(2)
finally:
c.close()
while str(stats[stat_key]) != str(stat_value):
c = MemcachedClient(master.ip, 11210)
c.sasl_auth_plain(bucket, "")
stats = c.stats()
c.close()
if verbose:
log.info("{0} : {1}".format(stat_key, stats[stat_key]))
time.sleep(5)
return True
示例2: wait_for_mc_stats_no_timeout
# 需要导入模块: from mc_bin_client import MemcachedClient [as 别名]
# 或者: from mc_bin_client.MemcachedClient import stats [as 别名]
def wait_for_mc_stats_no_timeout(master, bucket, stat_key, stat_value, timeout_in_seconds=-1, verbose=True):
log.info("waiting for bucket {0} stat : {1} to match {2} on {3}".format(bucket, stat_key, \
stat_value, master.ip))
c = MemcachedClient(master.ip, 11210)
stats = c.stats()
c.close()
while str(stats[stat_key]) != str(stat_value):
c = MemcachedClient(master.ip, 11210)
stats = c.stats()
c.close()
if verbose:
log.info("{0} : {1}".format(stat_key, stats[stat_key]))
time.sleep(5)
return True
示例3: get_vBuckets_info
# 需要导入模块: from mc_bin_client import MemcachedClient [as 别名]
# 或者: from mc_bin_client.MemcachedClient import stats [as 别名]
def get_vBuckets_info(master):
"""
return state and count items for all vbuckets for each node
format: dict: {u'1node_ip1': {'vb_79': ['replica', '0'], 'vb_78': ['active', '0']..}, u'1node_ip1':....}
"""
rest = RestConnection(master)
port = rest.get_nodes_self().memcached
nodes = rest.node_statuses()
_nodes_stats= {}
for node in nodes:
stat={}
buckets = []
_server = {"ip": node.ip, "port": node.port, "username": master.rest_username,
"password": master.rest_password}
try:
buckets = rest.get_buckets()
mc = MemcachedClient(node.ip, port)
stat_hash = mc.stats("hash")
except Exception:
if not buckets:
log.error("There are not any buckets in {0}:{1} node".format(node.ip, node.port))
else:
log.error("Impossible to get vBucket's information for {0}:{1} node".format(node.ip, node.port))
_nodes_stats[node.ip+":"+str(node.port)]
continue
mc.close()
vb_names=[key[:key.index(":")] for key in stat_hash.keys()]
for name in vb_names:
stat[name]=[stat_hash[name + ":state"], stat_hash[name+":counted"]]
_nodes_stats[node.ip+":"+str(port)] = stat
log.info(_nodes_stats)
return _nodes_stats
示例4: get_mb_stats
# 需要导入模块: from mc_bin_client import MemcachedClient [as 别名]
# 或者: from mc_bin_client.MemcachedClient import stats [as 别名]
def get_mb_stats(servers, key):
log = logger.Logger.get_logger()
for server in servers:
c = MemcachedClient(server.ip, 11210)
log.info("Get flush param on server {0}, {1}".format(server, key))
value = c.stats().get(key, None)
log.info("Get flush param on server {0}, {1}".format(server, value))
c.close()
示例5: wait_for_mc_stats
# 需要导入模块: from mc_bin_client import MemcachedClient [as 别名]
# 或者: from mc_bin_client.MemcachedClient import stats [as 别名]
def wait_for_mc_stats(master, bucket, stat_key, stat_value, timeout_in_seconds=120, verbose=True):
log.info("waiting for bucket {0} stat : {1} to match {2} on {3}".format(bucket, stat_key, \
stat_value, master.ip))
start = time.time()
verified = False
while (time.time() - start) <= timeout_in_seconds:
c = MemcachedClient(master.ip, 11210)
stats = c.stats()
c.close()
if stats and stat_key in stats and str(stats[stat_key]) == str(stat_value):
log.info("{0} : {1}".format(stat_key, stats[stat_key]))
verified = True
break
else:
if stats and stat_key in stats:
if verbose:
log.info("{0} : {1}".format(stat_key, stats[stat_key]))
if not verbose:
time.sleep(0.1)
else:
time.sleep(2)
return verified
示例6: EPStatChecker
# 需要导入模块: from mc_bin_client import MemcachedClient [as 别名]
# 或者: from mc_bin_client.MemcachedClient import stats [as 别名]
class EPStatChecker(StatChecker):
def __init__(self,
host = cfg.COUCHBASE_IP,
port = 11210):
self.host = host
self.port = port
self.client = None
try:
self.client = MemcachedClient(self.host, self.port)
except MemcachedError as ex:
msg = "error connecting to host %s for gathering postconditions"\
% self.host
logger.error(msg)
pass
@property
def stat_keys(self):
keys = []
stats = self.get_stats()
if stats:
keys = stats.keys()
return keys
def get_stats(self):
stats = None
if self.client:
try:
stats = self.client.stats()
except Exception:
logger.info("unable to get stats from host: %s:%s" %\
(self.host, self.port))
return stats