Commit 21190ee7 authored by Julien Muchembled's avatar Julien Muchembled

Make 'neoctl print pt' report the number of replicas

parent ef5fc508
...@@ -122,11 +122,13 @@ class Application(BaseApplication): ...@@ -122,11 +122,13 @@ class Application(BaseApplication):
self.master_conn.ask(Packets.AskClusterState()) self.master_conn.ask(Packets.AskClusterState())
def sendPartitionTable(self, conn, min_offset, max_offset, uuid): def sendPartitionTable(self, conn, min_offset, max_offset, uuid):
pt = self.pt
if max_offset == 0: if max_offset == 0:
max_offset = self.pt.getPartitions() max_offset = pt.getPartitions()
try: try:
row_list = map(self.pt.getRow, xrange(min_offset, max_offset)) row_list = map(pt.getRow, xrange(min_offset, max_offset))
except IndexError: except IndexError:
conn.send(Errors.ProtocolError('invalid partition table offset')) conn.send(Errors.ProtocolError('invalid partition table offset'))
else: else:
conn.answer(Packets.AnswerPartitionList(self.pt.getID(), row_list)) conn.answer(Packets.AnswerPartitionList(
pt.getID(), pt.getReplicas(), row_list))
...@@ -1201,6 +1201,7 @@ class PartitionList(Packet): ...@@ -1201,6 +1201,7 @@ class PartitionList(Packet):
_answer = PStruct('answer_partition_list', _answer = PStruct('answer_partition_list',
PPTID('ptid'), PPTID('ptid'),
PNumber('num_replicas'),
PFRowList, PFRowList,
) )
......
...@@ -106,10 +106,10 @@ class TerminalNeoCTL(object): ...@@ -106,10 +106,10 @@ class TerminalNeoCTL(object):
max_offset = int(max_offset) max_offset = int(max_offset)
if node is not None: if node is not None:
node = self.asNode(node) node = self.asNode(node)
ptid, row_list = self.neoctl.getPartitionRowList( ptid, num_replicas, row_list = self.neoctl.getPartitionRowList(
min_offset=min_offset, max_offset=max_offset, node=node) min_offset=min_offset, max_offset=max_offset, node=node)
# TODO: return ptid return '# ptid: %s, replicas: %s\n%s' % (ptid, num_replicas,
return self.formatRowList(enumerate(row_list, min_offset)) self.formatRowList(enumerate(row_list, min_offset)))
def getNodeList(self, params): def getNodeList(self, params):
""" """
......
...@@ -169,7 +169,7 @@ class NeoCTL(BaseApplication): ...@@ -169,7 +169,7 @@ class NeoCTL(BaseApplication):
response = self.__ask(packet) response = self.__ask(packet)
if response[0] != Packets.AnswerPartitionList: if response[0] != Packets.AnswerPartitionList:
raise RuntimeError(response) raise RuntimeError(response)
return response[1:3] # ptid, row_list return response[1:]
def startCluster(self): def startCluster(self):
""" """
......
...@@ -649,7 +649,7 @@ class NEOCluster(object): ...@@ -649,7 +649,7 @@ class NEOCluster(object):
def expectOudatedCells(self, number, *args, **kw): def expectOudatedCells(self, number, *args, **kw):
def callback(last_try): def callback(last_try):
row_list = self.neoctl.getPartitionRowList()[1] row_list = self.neoctl.getPartitionRowList()[2]
number_of_outdated = 0 number_of_outdated = 0
for row in row_list: for row in row_list:
for cell in row: for cell in row:
...@@ -660,7 +660,7 @@ class NEOCluster(object): ...@@ -660,7 +660,7 @@ class NEOCluster(object):
def expectAssignedCells(self, process, number, *args, **kw): def expectAssignedCells(self, process, number, *args, **kw):
def callback(last_try): def callback(last_try):
row_list = self.neoctl.getPartitionRowList()[1] row_list = self.neoctl.getPartitionRowList()[2]
assigned_cells_number = 0 assigned_cells_number = 0
for row in row_list: for row in row_list:
for cell in row: for cell in row:
......
...@@ -979,7 +979,7 @@ class ReplicationTests(NEOThreadedTest): ...@@ -979,7 +979,7 @@ class ReplicationTests(NEOThreadedTest):
return s0.uuid return s0.uuid
def check(expected_state, expected_count): def check(expected_state, expected_count):
self.assertEqual(expected_count, len([None self.assertEqual(expected_count, len([None
for row in cluster.neoctl.getPartitionRowList()[1] for row in cluster.neoctl.getPartitionRowList()[2]
for cell in row for cell in row
if cell[1] == CellStates.CORRUPTED])) if cell[1] == CellStates.CORRUPTED]))
self.assertEqual(expected_state, cluster.neoctl.getClusterState()) self.assertEqual(expected_state, cluster.neoctl.getClusterState())
......
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