Cherry pick oslo rpc HA fixes
Get 2 commits from oslo-rpc fixing HA failover: * Ia148baa6e1ec632789ac3621c85173c2c16f3918 (fixed HA failover, Qpid part) * I67923cb024bbd143edc8edccf35b9b400df31eb3 (fixed HA failover, RabbitMQ part) Change-Id: I45f679f3da720a0c28fb552d9f4cfb3d8bd21c20 Closes-Bug: #1261631
This commit is contained in:
parent
5b57317e98
commit
04e24eeb8a
heat/openstack/common/rpc
@ -458,6 +458,9 @@ class Connection(object):
|
|||||||
|
|
||||||
self.params_list = params_list
|
self.params_list = params_list
|
||||||
|
|
||||||
|
brokers_count = len(self.params_list)
|
||||||
|
self.next_broker_indices = itertools.cycle(range(brokers_count))
|
||||||
|
|
||||||
self.memory_transport = self.conf.fake_rabbit
|
self.memory_transport = self.conf.fake_rabbit
|
||||||
|
|
||||||
self.connection = None
|
self.connection = None
|
||||||
@ -528,7 +531,7 @@ class Connection(object):
|
|||||||
|
|
||||||
attempt = 0
|
attempt = 0
|
||||||
while True:
|
while True:
|
||||||
params = self.params_list[attempt % len(self.params_list)]
|
params = self.params_list[next(self.next_broker_indices)]
|
||||||
attempt += 1
|
attempt += 1
|
||||||
try:
|
try:
|
||||||
self._connect(params)
|
self._connect(params)
|
||||||
|
@ -467,6 +467,10 @@ class Connection(object):
|
|||||||
self.brokers = params['qpid_hosts']
|
self.brokers = params['qpid_hosts']
|
||||||
self.username = params['username']
|
self.username = params['username']
|
||||||
self.password = params['password']
|
self.password = params['password']
|
||||||
|
|
||||||
|
brokers_count = len(self.brokers)
|
||||||
|
self.next_broker_indices = itertools.cycle(range(brokers_count))
|
||||||
|
|
||||||
self.connection_create(self.brokers[0])
|
self.connection_create(self.brokers[0])
|
||||||
self.reconnect()
|
self.reconnect()
|
||||||
|
|
||||||
@ -494,7 +498,6 @@ class Connection(object):
|
|||||||
|
|
||||||
def reconnect(self):
|
def reconnect(self):
|
||||||
"""Handles reconnecting and re-establishing sessions and queues."""
|
"""Handles reconnecting and re-establishing sessions and queues."""
|
||||||
attempt = 0
|
|
||||||
delay = 1
|
delay = 1
|
||||||
while True:
|
while True:
|
||||||
# Close the session if necessary
|
# Close the session if necessary
|
||||||
@ -504,8 +507,7 @@ class Connection(object):
|
|||||||
except qpid_exceptions.ConnectionError:
|
except qpid_exceptions.ConnectionError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
broker = self.brokers[attempt % len(self.brokers)]
|
broker = self.brokers[next(self.next_broker_indices)]
|
||||||
attempt += 1
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.connection_create(broker)
|
self.connection_create(broker)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user