Commit 9d24294a authored by Julien Muchembled's avatar Julien Muchembled

threaded: new method to sort storage nodes

If needed, sortStorageList can be extended in the
future to support a 'readable' parameter.
parent 93f5b0d8
......@@ -786,11 +786,25 @@ class NEOCluster(object):
return Patch(, _nextTID=lambda orig, *args:
orig(*args) if args else orig(partition,
def getStorageList(self, *args, **kw):
pt =
uuid_set = {cell.getUUID() for offset in args
for cell in pt.getCellList(offset, **kw)}
return (s for s in self.storage_list if s.uuid in uuid_set)
def sortStorageList(self):
"""Sort storages so that storage_list[i] has partition i for all i"""
pt = [{x.getUUID() for x in x}
for x in]
r = []
x = [iter(pt[0])]
while 1:
except StopIteration:
del r[-1], x[-1]
except IndexError:
assert len(r) == len(self.storage_list)
x = {x.uuid: x for x in self.storage_list}
self.storage_list[:] = (x[r] for r in r)
return self.storage_list
class NEOThreadedTest(NeoTestBase):
......@@ -407,8 +407,7 @@ class Test(NEOThreadedTest):
cluster = NEOCluster(partitions=2, storage_count=2)
s0, = cluster.getStorageList(0)
s1, = cluster.getStorageList(1)
s0, s1 = cluster.sortStorageList()
t, c = cluster.getTransaction()
r = c.root()
r[0] = x = PCounter()
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