本文整理汇总了Python中mc_bin_client.MemcachedClient.bucket_select方法的典型用法代码示例。如果您正苦于以下问题:Python MemcachedClient.bucket_select方法的具体用法?Python MemcachedClient.bucket_select怎么用?Python MemcachedClient.bucket_select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mc_bin_client.MemcachedClient
的用法示例。
在下文中一共展示了MemcachedClient.bucket_select方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: verify_revid
# 需要导入模块: from mc_bin_client import MemcachedClient [as 别名]
# 或者: from mc_bin_client.MemcachedClient import bucket_select [as 别名]
def verify_revid(self):
missing_keys = False
src_node = self.get_active_vb0_node(self.src_master)
dest_node = self.get_active_vb0_node(self.dest_master)
src_client = MemcachedClient(src_node.ip, 11210)
dest_client = MemcachedClient(dest_node.ip, 11210)
src_client.sasl_auth_plain("cbadminbucket","password")
src_client.bucket_select("default")
dest_client.sasl_auth_plain("cbadminbucket","password")
dest_client.bucket_select("default")
for key in self.keys_loaded:
try:
src_meta = src_client.getMeta(key)
dest_meta = dest_client.getMeta(key)
self.log.info("deleted, flags, exp, rev_id, cas for key from Source({0}) {1} = {2}"
.format(src_node.ip, key, src_meta))
self.log.info("deleted, flags, exp, rev_id, cas for key from Destination({0}) {1} = {2}"
.format(dest_node.ip, key, dest_meta))
if src_meta == dest_meta:
self.log.info("RevID verification successful for key {0}".format(key))
else:
self.fail("RevID verification failed for key {0}".format(key))
except MemcachedError as e:
self.log.error("Key {0} threw {1} on getMeta()".format(key, e))
missing_keys = True
if missing_keys:
self.fail("Some keys are missing at destination")
示例2: connection
# 需要导入模块: from mc_bin_client import MemcachedClient [as 别名]
# 或者: from mc_bin_client.MemcachedClient import bucket_select [as 别名]
def connection(self, client_ip, bucket_name, user,password, port=11210):
log.info("Bucket name for connection is ---- {0}, username -- {1}, ----- password -- {2}".format(bucket_name,user, \
password))
try:
mc = MemcachedClient(host=client_ip, port=port)
mc.sasl_auth_plain(user,password)
mc.bucket_select(bucket_name)
return mc, True
except Exception as e:
log.info( "Exception is from connection function {0}".format(e))
return False, False
示例3: load_one_mutation_into_source_vb0
# 需要导入模块: from mc_bin_client import MemcachedClient [as 别名]
# 或者: from mc_bin_client.MemcachedClient import bucket_select [as 别名]
def load_one_mutation_into_source_vb0(self, vb0_active_src_node):
key = self.vb0_keys[self.key_counter]
memc_client = MemcachedClient(vb0_active_src_node.ip, 11210)
memc_client.sasl_auth_plain("cbadminbucket","password")
memc_client.bucket_select("default")
try:
memc_client.set(key, exp=0, flags=0, val="dummy val")
self.key_counter += 1
self.keys_loaded.append(key)
self.log.info("Loaded key {0} onto vb0 in {1}".format(key, vb0_active_src_node.ip))
self.log.info ("deleted, flags, exp, rev_id, cas for key {0} = {1}".format(key, memc_client.getMeta(key)))
except MemcachedError as e:
self.log.error(e)
示例4: wait_for_vbuckets_ready_state
# 需要导入模块: from mc_bin_client import MemcachedClient [as 别名]
# 或者: from mc_bin_client.MemcachedClient import bucket_select [as 别名]
def wait_for_vbuckets_ready_state(node, bucket, timeout_in_seconds=300, log_msg='', admin_user='cbadminbucket',
admin_pass='password'):
log = logger.Logger.get_logger()
start_time = time.time()
end_time = start_time + timeout_in_seconds
ready_vbuckets = {}
rest = RestConnection(node)
servers = rest.get_nodes()
RestHelper(rest).vbucket_map_ready(bucket, 60)
vbucket_count = len(rest.get_vbuckets(bucket))
vbuckets = rest.get_vbuckets(bucket)
obj = VBucketAwareMemcached(rest, bucket)
memcacheds, vbucket_map, vbucket_map_replica = obj.request_map(rest, bucket)
#Create dictionary with key:"ip:port" and value: a list of vbuckets
server_dict = defaultdict(list)
for everyID in range(0, vbucket_count):
memcached_ip_port = str(vbucket_map[everyID])
server_dict[memcached_ip_port].append(everyID)
while time.time() < end_time and len(ready_vbuckets) < vbucket_count:
for every_ip_port in server_dict:
#Retrieve memcached ip and port
ip = every_ip_port.rsplit(":", 1)[0]
port = every_ip_port.rsplit(":", 1)[1]
client = MemcachedClient(ip, int(port), timeout=30)
client.vbucket_count = len(vbuckets)
bucket_info = rest.get_bucket(bucket)
cluster_compatibility = rest.check_cluster_compatibility("5.0")
if cluster_compatibility is None:
pre_spock = True
else:
pre_spock = not cluster_compatibility
if pre_spock:
log.info("Atleast 1 of the server is on pre-spock "
"version. Using the old ssl auth to connect to "
"bucket.")
client.sasl_auth_plain(
bucket_info.name.encode('ascii'),
bucket_info.saslPassword.encode('ascii'))
else:
client.sasl_auth_plain(admin_user, admin_pass)
bucket = bucket.encode('ascii')
client.bucket_select(bucket)
for i in server_dict[every_ip_port]:
try:
(a, b, c) = client.get_vbucket_state(i)
except mc_bin_client.MemcachedError as e:
ex_msg = str(e)
if "Not my vbucket" in log_msg:
log_msg = log_msg[:log_msg.find("vBucketMap") + 12] + "..."
if e.status == memcacheConstants.ERR_NOT_MY_VBUCKET:
# May receive this while waiting for vbuckets, continue and retry...S
continue
log.error("%s: %s" % (log_msg, ex_msg))
continue
except exceptions.EOFError:
# The client was disconnected for some reason. This can
# happen just after the bucket REST API is returned (before
# the buckets are created in each of the memcached processes.)
# See here for some details: http://review.couchbase.org/#/c/49781/
# Longer term when we don't disconnect clients in this state we
# should probably remove this code.
log.error("got disconnected from the server, reconnecting")
client.reconnect()
client.sasl_auth_plain(bucket_info.name.encode('ascii'),
bucket_info.saslPassword.encode('ascii'))
continue
if c.find("\x01") > 0 or c.find("\x02") > 0:
ready_vbuckets[i] = True
elif i in ready_vbuckets:
log.warning("vbucket state changed from active to {0}".format(c))
del ready_vbuckets[i]
client.close()
return len(ready_vbuckets) == vbucket_count