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): ...@@ -786,11 +786,25 @@ class NEOCluster(object):
return Patch(master.tm, _nextTID=lambda orig, *args: return Patch(master.tm, _nextTID=lambda orig, *args:
orig(*args) if args else orig(partition, master.pt.getPartitions())) orig(*args) if args else orig(partition, master.pt.getPartitions()))
def getStorageList(self, *args, **kw): def sortStorageList(self):
pt = self.primary_master.pt """Sort storages so that storage_list[i] has partition i for all i"""
uuid_set = {cell.getUUID() for offset in args pt = [{x.getUUID() for x in x}
for cell in pt.getCellList(offset, **kw)} for x in self.primary_master.pt.partition_list]
return (s for s in self.storage_list if s.uuid in uuid_set) r = []
x = [iter(pt[0])]
try:
while 1:
try:
r.append(next(x[-1]))
except StopIteration:
del r[-1], x[-1]
else:
x.append(iter(pt[len(r)].difference(r)))
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): class NEOThreadedTest(NeoTestBase):
......
...@@ -407,8 +407,7 @@ class Test(NEOThreadedTest): ...@@ -407,8 +407,7 @@ class Test(NEOThreadedTest):
cluster = NEOCluster(partitions=2, storage_count=2) cluster = NEOCluster(partitions=2, storage_count=2)
try: try:
cluster.start() cluster.start()
s0, = cluster.getStorageList(0) s0, s1 = cluster.sortStorageList()
s1, = cluster.getStorageList(1)
t, c = cluster.getTransaction() t, c = cluster.getTransaction()
r = c.root() r = c.root()
r[0] = x = PCounter() 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