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

Nodes use update() method of partition table to reduce duplicate code.


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@944 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent f106a20c
......@@ -209,25 +209,12 @@ class MasterMonitoringEventHandler(MasterBaseEventHandler):
def handleNotifyPartitionChanges(self, conn, packet, ptid, cell_list):
app = self.app
nm = app.nm
pt = app.pt
node = nm.getNodeByUUID(conn.getUUID())
if ptid < app.ptid:
# Ignore this packet.
# XXX: is it safe ?
return
app.ptid = ptid
for offset, uuid, state in cell_list:
node = nm.getNodeByUUID(uuid)
if node is None:
node = StorageNode(uuid = uuid)
if uuid != app.uuid:
node.setState(TEMPORARILY_DOWN_STATE)
nm.add(node)
pt.setCell(offset, node, state)
pt.log()
app.pt.update(cell_list, app.nm)
def handleSendPartitionTable(self, conn, packet, ptid, row_list):
uuid = conn.getUUID()
......@@ -235,10 +222,6 @@ class MasterMonitoringEventHandler(MasterBaseEventHandler):
nm = app.nm
pt = app.pt
node = app.nm.getNodeByUUID(uuid)
# This must be sent only by primary master node
if node.getNodeType() != MASTER_NODE_TYPE:
return
if app.ptid != ptid:
app.ptid = ptid
pt.clear()
......@@ -250,6 +233,5 @@ class MasterMonitoringEventHandler(MasterBaseEventHandler):
node.setState(TEMPORARILY_DOWN_STATE)
nm.add(node)
pt.setCell(offset, node, state)
pt.log()
......@@ -174,21 +174,11 @@ class PrimaryNotificationsHandler(BaseHandler):
def handleNotifyPartitionChanges(self, conn, packet, ptid, cell_list):
app = self.app
nm = app.nm
pt = app.pt
if app.ptid >= ptid:
# Ignore this packet.
return
app.ptid = ptid
for offset, uuid, state in cell_list:
node = nm.getNodeByUUID(uuid)
if node is None:
node = StorageNode(uuid = uuid)
if uuid != app.uuid:
node.setState(TEMPORARILY_DOWN_STATE)
nm.add(node)
pt.setCell(offset, node, state)
app.pt.update(cell_list, app.nm)
@decorators.identification_required
def handleSendPartitionTable(self, conn, packet, ptid, row_list):
......
......@@ -74,8 +74,6 @@ class HiddenHandler(BaseMasterHandler):
"""This is very similar to Send Partition Table, except that
the information is only about changes from the previous."""
app = self.app
nm = app.nm
pt = app.pt
if app.ptid >= ptid:
# Ignore this packet.
logging.debug('ignoring older partition changes')
......@@ -84,14 +82,6 @@ class HiddenHandler(BaseMasterHandler):
# First, change the table on memory.
app.ptid = ptid
for offset, uuid, state in cell_list:
node = nm.getNodeByUUID(uuid)
if node is None:
node = StorageNode(uuid = uuid)
if uuid != app.uuid:
node.setState(TEMPORARILY_DOWN_STATE)
nm.add(node)
pt.setCell(offset, node, state)
if uuid == app.uuid and app.replicator is not None:
# If this is for myself, this can affect replications.
if state == DISCARDED_STATE:
......@@ -99,9 +89,9 @@ class HiddenHandler(BaseMasterHandler):
elif state == OUT_OF_DATE_STATE:
app.replicator.addPartition(offset)
# Then, the database.
# update partition table in memory and the database
app.pt.update(cell_list, app.nm)
app.dm.changePartitionTable(ptid, cell_list)
app.pt.log()
@decorators.client_connection_required
def handleStartOperation(self, conn, packet):
......
......@@ -38,10 +38,8 @@ class MasterOperationHandler(BaseMasterHandler):
def handleNotifyPartitionChanges(self, conn, packet, ptid, cell_list):
"""This is very similar to Send Partition Table, except that
the information is only about changes from the previous."""
the information is only about changes from the previous."""
app = self.app
nm = app.nm
pt = app.pt
if app.ptid >= ptid:
# Ignore this packet.
logging.debug('ignoring older partition changes')
......@@ -50,25 +48,16 @@ class MasterOperationHandler(BaseMasterHandler):
# First, change the table on memory.
app.ptid = ptid
for offset, uuid, state in cell_list:
node = nm.getNodeByUUID(uuid)
if node is None:
node = StorageNode(uuid = uuid)
if uuid != app.uuid:
node.setState(TEMPORARILY_DOWN_STATE)
nm.add(node)
pt.setCell(offset, node, state)
if uuid == app.uuid:
if uuid == app.uuid and app.replicator is not None:
# If this is for myself, this can affect replications.
if state == DISCARDED_STATE:
app.replicator.removePartition(offset)
elif state == OUT_OF_DATE_STATE:
app.replicator.addPartition(offset)
# Then, the database.
# update partition table in memory and the database
app.pt.update(cell_list, app.nm)
app.dm.changePartitionTable(ptid, cell_list)
logging.debug('Partition table updated:')
self.app.pt.log()
def handleLockInformation(self, conn, packet, tid):
app = self.app
......
......@@ -61,26 +61,13 @@ class VerificationHandler(BaseMasterHandler):
"""This is very similar to Send Partition Table, except that
the information is only about changes from the previous."""
app = self.app
nm = app.nm
pt = app.pt
if app.ptid >= ptid:
# Ignore this packet.
logging.debug('ignoring older partition changes')
return
# First, change the table on memory.
app.ptid = ptid
for offset, uuid, state in cell_list:
node = nm.getNodeByUUID(uuid)
if node is None:
node = StorageNode(uuid = uuid)
if uuid != app.uuid:
node.setState(TEMPORARILY_DOWN_STATE)
nm.add(node)
pt.setCell(offset, node, state)
# Then, the database.
# update partition table in memory and the database
app.pt.update(cell_list, app.nm)
app.dm.changePartitionTable(ptid, cell_list)
def handleStartOperation(self, conn, packet):
......
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