Commit 91ec53b9 authored by Grégory Wisniewski's avatar Grégory Wisniewski

ConnectionPool iterator raise if there is no storage available.

Remove 'else' sections of 'for' loops from app.
(and the one in checkCurrentSerialInTransaction was broken)

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2579 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent faf121b5
......@@ -647,8 +647,6 @@ class Application(object):
self.local_var.asked_object = -1
continue
break
else:
raise NEOStorageError('no storage available')
if self.local_var.asked_object == -1:
raise NEOStorageError('inconsistent data')
......@@ -1307,8 +1305,6 @@ class Application(object):
conn.ask(packet, queue=queue)
except ConnectionClosed:
continue
else:
raise NEOStorageError('no storage available')
self._waitAnyMessage(False)
......@@ -148,6 +148,7 @@ class ConnectionPool(object):
""" Iterate over nodes responsible of a object by it's ID """
pt = self.app.getPartitionTable()
cell_list = pt.getCellListForOID(object_id, readable, writable)
yielded = 0
if cell_list:
shuffle(cell_list)
cell_list.sort(key=self.getCellSortKey)
......@@ -156,7 +157,10 @@ class ConnectionPool(object):
node = cell.getNode()
conn = getConnForNode(node, wait_ready=wait_ready)
if conn is not None:
yielded += 1
yield (node, conn)
if not yielded:
raise NEOStorageError('no storage available')
@profiler_decorator
def getConnForNode(self, node, wait_ready=True):
......
......@@ -20,6 +20,7 @@ from mock import Mock
from neo.tests import NeoUnitTestBase
from neo.client.app import ConnectionPool
from neo.client.exception import NEOStorageError
class ConnectionPoolTests(NeoUnitTestBase):
......@@ -74,7 +75,7 @@ class ConnectionPoolTests(NeoUnitTestBase):
pt = Mock({'getCellListForOID': []})
app = Mock({'getPartitionTable': pt})
pool = ConnectionPool(app)
self.assertRaises(StopIteration, pool.iterateForObject(oid).next)
self.assertRaises(NEOStorageError, pool.iterateForObject(oid).next)
def test_iterateForObject_connectionRefused(self):
# connection refused
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment