[zmq] Fix cinder create volume hangs
Cinder create volume hangs in default deployment devstack+zmq. * Fix general topic resolution in matchmaker * Fix matchmaker redis to use set instead of list Change-Id: I25d623eb4bb0a827daa8a316a0ddcb4a473f8694 Closes-Bug: #1546106
This commit is contained in:
parent
82bfad9662
commit
8600f081e7
@ -114,11 +114,11 @@ class RedisMatchMaker(base.MatchMakerBase):
|
||||
def register_publisher(self, hostname):
|
||||
host_str = ",".join(hostname)
|
||||
if host_str not in self._get_hosts_by_key(_PUBLISHERS_KEY):
|
||||
self._redis.lpush(_PUBLISHERS_KEY, host_str)
|
||||
self._redis.sadd(_PUBLISHERS_KEY, host_str)
|
||||
|
||||
def unregister_publisher(self, hostname):
|
||||
host_str = ",".join(hostname)
|
||||
self._redis.lrem(_PUBLISHERS_KEY, 0, host_str)
|
||||
self._redis.srem(_PUBLISHERS_KEY, host_str)
|
||||
|
||||
def get_publishers(self):
|
||||
hosts = []
|
||||
@ -128,13 +128,12 @@ class RedisMatchMaker(base.MatchMakerBase):
|
||||
return hosts
|
||||
|
||||
def _get_hosts_by_key(self, key):
|
||||
return self._redis.lrange(key, 0, -1)
|
||||
return self._redis.smembers(key)
|
||||
|
||||
def register(self, target, hostname, listener_type, expire=-1):
|
||||
|
||||
def register_key(key):
|
||||
if hostname not in self._get_hosts_by_key(key):
|
||||
self._redis.lpush(key, hostname)
|
||||
self._redis.sadd(key, hostname)
|
||||
if expire > 0:
|
||||
self._redis.expire(key, expire)
|
||||
|
||||
@ -146,17 +145,18 @@ class RedisMatchMaker(base.MatchMakerBase):
|
||||
key = zmq_address.prefix_str(target.topic, listener_type)
|
||||
register_key(key)
|
||||
|
||||
if target.server:
|
||||
key = zmq_address.prefix_str(target.server, listener_type)
|
||||
register_key(key)
|
||||
|
||||
def unregister(self, target, hostname, listener_type):
|
||||
key = zmq_address.target_to_key(target, listener_type)
|
||||
self._redis.lrem(key, 0, hostname)
|
||||
self._redis.srem(key, hostname)
|
||||
|
||||
def get_hosts(self, target, listener_type):
|
||||
LOG.debug("[Redis] get_hosts for target %s", target)
|
||||
hosts = []
|
||||
key = zmq_address.target_to_key(target, listener_type)
|
||||
hosts.extend(self._get_hosts_by_key(key))
|
||||
|
||||
if not hosts and target.topic and target.server:
|
||||
key = zmq_address.prefix_str(target.topic, listener_type)
|
||||
hosts.extend(self._get_hosts_by_key(key))
|
||||
|
||||
return hosts
|
||||
|
@ -46,8 +46,6 @@ def target_to_key(target, listener_type):
|
||||
return prefix(key)
|
||||
if target.topic:
|
||||
return prefix(target.topic)
|
||||
if target.server:
|
||||
return prefix(target.server)
|
||||
|
||||
|
||||
def target_to_subscribe_filter(target):
|
||||
|
Loading…
Reference in New Issue
Block a user