Commit cae1f178 authored by Grégory Wisniewski's avatar Grégory Wisniewski

Use methods and properties of PartitionTable.

Remove admin's app.ptid attribute, use pt.load() and pt.update() instead
of copy/paste the code.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@1991 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 0d14fa9f
...@@ -69,7 +69,6 @@ class Application(object): ...@@ -69,7 +69,6 @@ class Application(object):
self.pt = None self.pt = None
self.uuid = config.getUUID() self.uuid = config.getUUID()
self.primary_master_node = None self.primary_master_node = None
self.ptid = None
self.request_handler = MasterRequestEventHandler(self) self.request_handler = MasterRequestEventHandler(self)
self.master_event_handler = MasterEventHandler(self) self.master_event_handler = MasterEventHandler(self)
self.dispatcher = Dispatcher() self.dispatcher = Dispatcher()
...@@ -162,5 +161,5 @@ class Application(object): ...@@ -162,5 +161,5 @@ class Application(object):
p = Errors.ProtocolError('invalid partition table offset') p = Errors.ProtocolError('invalid partition table offset')
conn.notify(p) conn.notify(p)
return return
p = Packets.AnswerPartitionList(self.ptid, row_list) p = Packets.AnswerPartitionList(self.pt.getID(), row_list)
conn.answer(p) conn.answer(p)
...@@ -152,29 +152,12 @@ class MasterEventHandler(EventHandler): ...@@ -152,29 +152,12 @@ class MasterEventHandler(EventHandler):
logging.debug("answerPartitionTable") logging.debug("answerPartitionTable")
def notifyPartitionChanges(self, conn, ptid, cell_list): def notifyPartitionChanges(self, conn, ptid, cell_list):
app = self.app self.app.pt.update(ptid, cell_list, self.app.nm)
if ptid < app.ptid:
# Ignore this packet.
return
app.ptid = ptid
app.pt.update(ptid, cell_list, app.nm)
def sendPartitionTable(self, conn, ptid, row_list): def sendPartitionTable(self, conn, ptid, row_list):
uuid = conn.getUUID() self.app.pt.clear()
app = self.app self.app.pt.load(ptid, row_list, self.app.nm)
nm = app.nm self.app.pt.log()
pt = app.pt
node = app.nm.getByUUID(uuid)
if app.ptid != ptid:
app.ptid = ptid
pt.clear()
for offset, row in row_list:
for uuid, state in row:
node = nm.getByUUID(uuid)
if node is None:
node = nm.createStorage(uuid=uuid)
pt.setCell(offset, node, state)
pt.log()
def notifyClusterInformation(self, conn, cluster_state): def notifyClusterInformation(self, conn, cluster_state):
self.app.cluster_state = cluster_state self.app.cluster_state = cluster_state
......
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