summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Sergeyev <vsergeyev@mirantis.com>2015-08-04 15:13:14 +0300
committerVictor Sergeyev <vsergeyev@mirantis.com>2015-08-04 15:31:10 +0300
commit64831f29ee96ea5622e67fa51b1e26c09247fd18 (patch)
tree08bd862c50bf11ca78b0a277072a181ba4221d93
parent2aa35bb6d905f37665e1115894d21bd1611d4eed (diff)
downloadoslo-messaging-64831f29ee96ea5622e67fa51b1e26c09247fd18.tar.gz
ZMQ: Minor matchmaker improvement
Added more information to logs and prefix to key in matchmaker_redis Change-Id: I5d718c4a84dedc6654e13f9ca740a2deba5a7e43
-rw-r--r--oslo_messaging/_drivers/zmq_driver/matchmaker/base.py13
-rw-r--r--oslo_messaging/_drivers/zmq_driver/matchmaker/matchmaker_redis.py4
2 files changed, 11 insertions, 6 deletions
diff --git a/oslo_messaging/_drivers/zmq_driver/matchmaker/base.py b/oslo_messaging/_drivers/zmq_driver/matchmaker/base.py
index b422212..f4480f0 100644
--- a/oslo_messaging/_drivers/zmq_driver/matchmaker/base.py
+++ b/oslo_messaging/_drivers/zmq_driver/matchmaker/base.py
@@ -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):
diff --git a/oslo_messaging/_drivers/zmq_driver/matchmaker/matchmaker_redis.py b/oslo_messaging/_drivers/zmq_driver/matchmaker/matchmaker_redis.py
index a55e507..a2ee9bc 100644
--- a/oslo_messaging/_drivers/zmq_driver/matchmaker/matchmaker_redis.py
+++ b/oslo_messaging/_drivers/zmq_driver/matchmaker/matchmaker_redis.py
@@ -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)