Updated use of iter_nodes for handoff logging

Change-Id: I95a750613b01bdc4d64444d7e7fae8190760d697
This commit is contained in:
gholt 2012-08-01 21:07:32 +00:00
parent 7923c56afa
commit d2b51dd2b6

View File

@ -397,7 +397,13 @@ class Controller(object):
attempts_left = len(nodes) attempts_left = len(nodes)
path = '/%s' % account path = '/%s' % account
headers = {'x-trans-id': self.trans_id, 'Connection': 'close'} headers = {'x-trans-id': self.trans_id, 'Connection': 'close'}
for node in self.iter_nodes(partition, nodes, self.app.account_ring): iternodes = self.iter_nodes(partition, nodes, self.app.account_ring)
while attempts_left > 0:
try:
node = iternodes.next()
except StopIteration:
break
attempts_left -= 1
try: try:
with ConnectionTimeout(self.app.conn_timeout): with ConnectionTimeout(self.app.conn_timeout):
conn = http_connect(node['ip'], node['port'], conn = http_connect(node['ip'], node['port'],
@ -420,9 +426,6 @@ class Controller(object):
continue continue
else: else:
result_code = -1 result_code = -1
attempts_left -= 1
if attempts_left <= 0:
break
except (Exception, Timeout): except (Exception, Timeout):
self.exception_occurred(node, _('Account'), self.exception_occurred(node, _('Account'),
_('Trying to get account info for %s') % path) _('Trying to get account info for %s') % path)
@ -489,7 +492,13 @@ class Controller(object):
versions = None versions = None
attempts_left = len(nodes) attempts_left = len(nodes)
headers = {'x-trans-id': self.trans_id, 'Connection': 'close'} headers = {'x-trans-id': self.trans_id, 'Connection': 'close'}
for node in self.iter_nodes(partition, nodes, self.app.container_ring): iternodes = self.iter_nodes(partition, nodes, self.app.container_ring)
while attempts_left > 0:
try:
node = iternodes.next()
except StopIteration:
break
attempts_left -= 1
try: try:
with ConnectionTimeout(self.app.conn_timeout): with ConnectionTimeout(self.app.conn_timeout):
conn = http_connect(node['ip'], node['port'], conn = http_connect(node['ip'], node['port'],
@ -516,9 +525,6 @@ class Controller(object):
continue continue
else: else:
result_code = -1 result_code = -1
attempts_left -= 1
if attempts_left <= 0:
break
except (Exception, Timeout): except (Exception, Timeout):
self.exception_occurred(node, _('Container'), self.exception_occurred(node, _('Container'),
_('Trying to get container info for %s') % path) _('Trying to get container info for %s') % path)
@ -758,8 +764,11 @@ class Controller(object):
bodies = [] bodies = []
source = None source = None
newest = req.headers.get('x-newest', 'f').lower() in TRUE_VALUES newest = req.headers.get('x-newest', 'f').lower() in TRUE_VALUES
for node in nodes: nodes = iter(nodes)
if len(statuses) >= attempts: while len(statuses) < attempts:
try:
node = nodes.next()
except StopIteration:
break break
if self.error_limited(node): if self.error_limited(node):
continue continue
@ -803,6 +812,9 @@ class Controller(object):
source = possible_source source = possible_source
else: else:
source = possible_source source = possible_source
statuses.append(source.status)
reasons.append(source.reason)
bodies.append('')
continue continue
else: else:
source = possible_source source = possible_source