ZMQ: Minor matchmaker improvement
Added more information to logs and prefix to key in matchmaker_redis Change-Id: I5d718c4a84dedc6654e13f9ca740a2deba5a7e43
This commit is contained in:
parent
2aa35bb6d9
commit
64831f29ee
|
@ -67,12 +67,15 @@ class MatchMakerBase(object):
|
|||
raise oslo_messaging.InvalidTarget(err_msg, target)
|
||||
|
||||
if len(hosts) == 1:
|
||||
LOG.info(_LI("A single host found for target %s.") % target)
|
||||
return hosts[0]
|
||||
host = hosts[0]
|
||||
LOG.info(_LI("A single host %(host)s found for target %(target)s.")
|
||||
% {"host": host, "target": target})
|
||||
else:
|
||||
LOG.warning(_LW("Multiple hosts were found for target %s. Using "
|
||||
"the random one.") % target)
|
||||
return random.choice(hosts)
|
||||
host = random.choice(hosts)
|
||||
LOG.warning(_LW("Multiple hosts %(hosts)s were found for target "
|
||||
" %(target)s. Using the random one - %(host)s.")
|
||||
% {"hosts": hosts, "target": target, "host": host})
|
||||
return host
|
||||
|
||||
|
||||
class DummyMatchMaker(MatchMakerBase):
|
||||
|
|
|
@ -50,7 +50,9 @@ class RedisMatchMaker(base.MatchMakerBase):
|
|||
|
||||
def _target_to_key(self, target):
|
||||
attributes = ['topic', 'exchange', 'server']
|
||||
return ':'.join((getattr(target, attr) or "*") for attr in attributes)
|
||||
prefix = "ZMQ-target"
|
||||
key = ":".join((getattr(target, attr) or "*") for attr in attributes)
|
||||
return "%s-%s" % (prefix, key)
|
||||
|
||||
def _get_keys_by_pattern(self, pattern):
|
||||
return self._redis.keys(pattern)
|
||||
|
|
Loading…
Reference in New Issue