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):
self.pt = None
self.uuid = config.getUUID()
self.primary_master_node = None
self.ptid = None
self.request_handler = MasterRequestEventHandler(self)
self.master_event_handler = MasterEventHandler(self)
self.dispatcher = Dispatcher()
......@@ -162,5 +161,5 @@ class Application(object):
p = Errors.ProtocolError('invalid partition table offset')
conn.notify(p)
return
p = Packets.AnswerPartitionList(self.ptid, row_list)
p = Packets.AnswerPartitionList(self.pt.getID(), row_list)
conn.answer(p)
......@@ -152,29 +152,12 @@ class MasterEventHandler(EventHandler):
logging.debug("answerPartitionTable")
def notifyPartitionChanges(self, conn, ptid, cell_list):
app = self.app
if ptid < app.ptid:
# Ignore this packet.
return
app.ptid = ptid
app.pt.update(ptid, cell_list, app.nm)
self.app.pt.update(ptid, cell_list, self.app.nm)
def sendPartitionTable(self, conn, ptid, row_list):
uuid = conn.getUUID()
app = self.app
nm = app.nm
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()
self.app.pt.clear()
self.app.pt.load(ptid, row_list, self.app.nm)
self.app.pt.log()
def notifyClusterInformation(self, conn, 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