Commit 2c170443 authored by Julien Muchembled's avatar Julien Muchembled

client: fix undoLog() not asking storages with only FEEDING cells

parent a10c4183
......@@ -898,12 +898,10 @@ class Application(object):
# Each storage node will return TIDs only for UP_TO_DATE state and
# FEEDING state cells
pt = self.getPartitionTable()
storage_node_list = pt.getNodeList()
queue = self._getThreadQueue()
packet = Packets.AskTIDs(first, last, INVALID_PARTITION)
tid_set = set()
for storage_node in storage_node_list:
for storage_node in pt.getNodeSet(True):
conn = self.cp.getConnForNode(storage_node)
if conn is None:
continue
......
......@@ -136,11 +136,6 @@ class PartitionTable(object):
def getConnectedNodeList(self):
return [node for node in self.getNodeSet() if node.isConnected()]
def getNodeList(self):
"""Return all used nodes."""
return [node for node, count in self.count_dict.iteritems() \
if count > 0]
def getCellList(self, offset, readable=False):
if readable:
return filter(Cell.isReadable, self.partition_list[offset])
......@@ -344,7 +339,3 @@ class MTPartitionTable(PartitionTable):
@thread_safe
def operational(self, *args, **kwargs):
return PartitionTable.operational(self, *args, **kwargs)
@thread_safe
def getNodeList(self, *args, **kwargs):
return PartitionTable.getNodeList(self, *args, **kwargs)
......@@ -725,7 +725,7 @@ class ClientApplicationTests(NeoUnitTestBase):
return conn
app.dispatcher = Dispatcher()
app.pt = Mock({
'getNodeList': (Mock(), Mock()),
'getNodeSet': (Mock(), Mock()),
})
app.cp = Mock({
'getConnForNode': ReturnValues(answerTIDs(p1), answerTIDs(p2)),
......
......@@ -40,7 +40,7 @@ class MasterPartitionTableTests(NeoUnitTestBase):
self.assertEqual(len(part), 0)
self.assertEqual(len(pt.count_dict), 0)
# no nodes or cells for now
self.assertEqual(len(pt.getNodeList()), 0)
self.assertFalse(pt.getNodeSet())
for x in xrange(num_partitions):
self.assertEqual(len(pt.getCellList(x)), 0)
self.assertEqual(len(pt.getCellList(x, True)), 0)
......@@ -209,7 +209,8 @@ class MasterPartitionTableTests(NeoUnitTestBase):
def checkPT(self, pt, exclude_empty=False):
new_pt = PartitionTable(pt.np, pt.nr)
new_pt.make(pt.getNodeList() if exclude_empty else pt.count_dict)
new_pt.make(node for node, count in pt.count_dict.iteritems()
if count or not exclude_empty)
self.assertEqual(self._pt_states(pt), self._pt_states(new_pt))
def update(self, pt, change_list=None):
......
......@@ -47,14 +47,14 @@ class StorageAppTests(NeoUnitTestBase):
num_partitions = 3
num_replicas = 2
self.app.pt = PartitionTable(num_partitions, num_replicas)
self.assertEqual(self.app.pt.getNodeList(), [])
self.assertFalse(self.app.pt.getNodeSet())
self.assertFalse(self.app.pt.filled())
for x in xrange(num_partitions):
self.assertFalse(self.app.pt.hasOffset(x))
# load an empty table
self.app.loadPartitionTable()
self.assertEqual(self.app.pt.getNodeList(), [])
self.assertFalse(self.app.pt.getNodeSet())
self.assertFalse(self.app.pt.filled())
for x in xrange(num_partitions):
self.assertFalse(self.app.pt.hasOffset(x))
......@@ -68,7 +68,7 @@ class StorageAppTests(NeoUnitTestBase):
self.app.pt.setCell(0, master, CellStates.UP_TO_DATE)
self.app.pt.setCell(0, storage, CellStates.UP_TO_DATE)
self.assertEqual(len(self.app.pt.getNodeList()), 2)
self.assertEqual(len(self.app.pt.getNodeSet()), 2)
self.assertFalse(self.app.pt.filled())
for x in xrange(num_partitions):
if x == 0:
......@@ -77,7 +77,7 @@ class StorageAppTests(NeoUnitTestBase):
self.assertFalse(self.app.pt.hasOffset(x))
# load an empty table, everything removed
self.app.loadPartitionTable()
self.assertEqual(self.app.pt.getNodeList(), [])
self.assertFalse(self.app.pt.getNodeSet())
self.assertFalse(self.app.pt.filled())
for x in xrange(num_partitions):
self.assertFalse(self.app.pt.hasOffset(x))
......@@ -85,7 +85,7 @@ class StorageAppTests(NeoUnitTestBase):
# add some node
self.app.pt.setCell(0, master, CellStates.UP_TO_DATE)
self.app.pt.setCell(0, storage, CellStates.UP_TO_DATE)
self.assertEqual(len(self.app.pt.getNodeList()), 2)
self.assertEqual(len(self.app.pt.getNodeSet()), 2)
self.assertFalse(self.app.pt.filled())
for x in xrange(num_partitions):
if x == 0:
......
......@@ -240,7 +240,7 @@ class PartitionTableTests(NeoUnitTestBase):
self.assertEqual(len(part), 0)
self.assertEqual(len(pt.count_dict), 0)
def test_07_getNodeList(self):
def test_07_getNodeSet(self):
num_partitions = 5
num_replicas = 2
pt = PartitionTable(num_partitions, num_replicas)
......@@ -263,12 +263,8 @@ class PartitionTableTests(NeoUnitTestBase):
pt.setCell(0, sn4, CellStates.DISCARDED) # won't be added
# must get only two node as feeding and discarded not taken
# into account
self.assertEqual(len(pt.getNodeList()), 2)
nodes = pt.getNodeList()
self.assertTrue(sn1 in nodes)
self.assertTrue(sn2 in nodes)
self.assertTrue(sn3 not in nodes)
self.assertTrue(sn4 not in nodes)
self.assertEqual(pt.getNodeSet(True), set((sn1, sn3)))
self.assertEqual(len(pt.getNodeSet()), 3)
def test_08_filled(self):
num_partitions = 5
......
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