Skip to content

Commit

Permalink
Cherry pick oslo rpc HA fixes
Browse files Browse the repository at this point in the history
Get 2 commits from oslo-rpc fixing HA failover:
* Ia148baa6e1ec632789ac3621c85173c2c16f3918 (fixed HA failover, Qpid
 part)
* I67923cb024bbd143edc8edccf35b9b400df31eb3 (fixed HA failover, RabbitMQ
 part)
Closes-Bug: #1261631

Change-Id: I154a1e4230cf956e0d6a71a8e717866d0cd17a12
  • Loading branch information
e0ne committed Aug 19, 2014
1 parent 3417960 commit 776fcb5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 4 additions & 1 deletion cinder/openstack/common/rpc/impl_kombu.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,9 @@ def __init__(self, conf, server_params=None):

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.connection = None
Expand Down Expand Up @@ -510,7 +513,7 @@ def reconnect(self):

attempt = 0
while True:
params = self.params_list[attempt % len(self.params_list)]
params = self.params_list[next(self.next_broker_indices)]
attempt += 1
try:
self._connect(params)
Expand Down
8 changes: 5 additions & 3 deletions cinder/openstack/common/rpc/impl_qpid.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,10 @@ def __init__(self, conf, server_params=None):
self.brokers = params['qpid_hosts']
self.username = params['username']
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.reconnect()

Expand Down Expand Up @@ -434,7 +438,6 @@ def _lookup_consumer(self, receiver):

def reconnect(self):
"""Handles reconnecting and re-establishing sessions and queues"""
attempt = 0
delay = 1
while True:
# Close the session if necessary
Expand All @@ -444,8 +447,7 @@ def reconnect(self):
except qpid_exceptions.MessagingError:
pass

broker = self.brokers[attempt % len(self.brokers)]
attempt += 1
broker = self.brokers[next(self.next_broker_indices)]

try:
self.connection_create(broker)
Expand Down

0 comments on commit 776fcb5

Please sign in to comment.