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

On the contrary to comments in protocol.py, AskObject can be sent by storage

nodes to other storage nodes (during replications). Move The handler method in
the common handler class. Move AskTransactionInformation handler in the same
handler for the same reason and clean the same method in the verification
handler, where the message can only be sent by the primary master node. 
Fix a super construtor call.


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@804 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent ce41a66d
...@@ -79,32 +79,6 @@ class ClientOperationHandler(BaseClientAndStorageOperationHandler): ...@@ -79,32 +79,6 @@ class ClientOperationHandler(BaseClientAndStorageOperationHandler):
def connectionCompleted(self, conn): def connectionCompleted(self, conn):
BaseClientAndStorageOperationHandler.connectionCompleted(self, conn) BaseClientAndStorageOperationHandler.connectionCompleted(self, conn)
def handleAskObject(self, conn, packet, oid, serial, tid):
app = self.app
if oid in app.load_lock_dict:
# Delay the response.
app.queueEvent(self.handleAskObject, conn, packet, oid,
serial, tid)
return
if serial == INVALID_SERIAL:
serial = None
if tid == INVALID_TID:
tid = None
o = app.dm.getObject(oid, serial, tid)
if o is not None:
serial, next_serial, compression, checksum, data = o
if next_serial is None:
next_serial = INVALID_SERIAL
logging.debug('oid = %s, serial = %s, next_serial = %s',
dump(oid), dump(serial), dump(next_serial))
p = protocol.answerObject(oid, serial, next_serial,
compression, checksum, data)
else:
logging.debug('oid = %s not found', dump(oid))
p = protocol.oidNotFound('%s does not exist' % dump(oid))
conn.answer(p, packet)
def handleAbortTransaction(self, conn, packet, tid): def handleAbortTransaction(self, conn, packet, tid):
uuid = conn.getUUID() uuid = conn.getUUID()
app = self.app app = self.app
......
...@@ -218,3 +218,38 @@ class BaseClientAndStorageOperationHandler(BaseStorageHandler): ...@@ -218,3 +218,38 @@ class BaseClientAndStorageOperationHandler(BaseStorageHandler):
p = protocol.answerObjectHistory(oid, history_list) p = protocol.answerObjectHistory(oid, history_list)
conn.answer(p, packet) conn.answer(p, packet)
def handleAskTransactionInformation(self, conn, packet, tid):
app = self.app
t = app.dm.getTransaction(tid)
if t is None:
p = protocol.tidNotFound('%s does not exist' % dump(tid))
else:
p = protocol.answerTransactionInformation(tid, t[1], t[2], t[3], t[0])
conn.answer(p, packet)
def handleAskObject(self, conn, packet, oid, serial, tid):
app = self.app
if oid in app.load_lock_dict:
# Delay the response.
app.queueEvent(self.handleAskObject, conn, packet, oid,
serial, tid)
return
if serial == protocol.INVALID_SERIAL:
serial = None
if tid == protocol.INVALID_TID:
tid = None
o = app.dm.getObject(oid, serial, tid)
if o is not None:
serial, next_serial, compression, checksum, data = o
if next_serial is None:
next_serial = protocol.INVALID_SERIAL
logging.debug('oid = %s, serial = %s, next_serial = %s',
dump(oid), dump(serial), dump(next_serial))
p = protocol.answerObject(oid, serial, next_serial,
compression, checksum, data)
else:
logging.debug('oid = %s not found', dump(oid))
p = protocol.oidNotFound('%s does not exist' % dump(oid))
conn.answer(p, packet)
...@@ -35,7 +35,7 @@ class HiddenHandler(BaseStorageHandler): ...@@ -35,7 +35,7 @@ class HiddenHandler(BaseStorageHandler):
def __init__(self, app): def __init__(self, app):
self.app = app self.app = app
BaseStorageHandler.__init__(self) BaseStorageHandler.__init__(self, app)
def handleNotifyNodeInformation(self, conn, packet, node_list): def handleNotifyNodeInformation(self, conn, packet, node_list):
"""Store information on nodes, only if this is sent by a primary """Store information on nodes, only if this is sent by a primary
......
...@@ -39,16 +39,6 @@ class MasterOperationHandler(BaseMasterHandler): ...@@ -39,16 +39,6 @@ class MasterOperationHandler(BaseMasterHandler):
def handleAnswerUnfinishedTransactions(self, conn, packet, tid_list): def handleAnswerUnfinishedTransactions(self, conn, packet, tid_list):
self.app.replicator.setUnfinishedTIDList(tid_list) self.app.replicator.setUnfinishedTIDList(tid_list)
def handleAskTransactionInformation(self, conn, packet, tid):
app = self.app
t = app.dm.getTransaction(tid)
if t is None:
p = protocol.tidNotFound('%s does not exist' % dump(tid))
else:
p = protocol.answerTransactionInformation(tid, t[1], t[2], t[3], t[0])
conn.answer(p, packet)
def handleNotifyPartitionChanges(self, conn, packet, ptid, cell_list): def handleNotifyPartitionChanges(self, conn, packet, ptid, cell_list):
"""This is very similar to Send Partition Table, except that """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."""
......
...@@ -51,4 +51,3 @@ class StorageOperationHandler(BaseClientAndStorageOperationHandler): ...@@ -51,4 +51,3 @@ class StorageOperationHandler(BaseClientAndStorageOperationHandler):
app.num_partitions, partition_list) app.num_partitions, partition_list)
conn.answer(protocol.answerOIDs(oid_list), packet) conn.answer(protocol.answerOIDs(oid_list), packet)
...@@ -96,16 +96,7 @@ class VerificationHandler(BaseMasterHandler): ...@@ -96,16 +96,7 @@ class VerificationHandler(BaseMasterHandler):
def handleAskTransactionInformation(self, conn, packet, tid): def handleAskTransactionInformation(self, conn, packet, tid):
app = self.app app = self.app
if not conn.isServerConnection(): t = app.dm.getTransaction(tid, all=True)
# If this is from a primary master node, assume that it wants
# to obtain information about the transaction, even if it has
# not been finished.
t = app.dm.getTransaction(tid, all = True)
else:
# XXX: this should never be used since we don't accept incoming
# connections out of the operation state.
t = app.dm.getTransaction(tid)
if t is None: if t is None:
p = protocol.tidNotFound('%s does not exist' % dump(tid)) p = protocol.tidNotFound('%s does not exist' % dump(tid))
else: else:
......
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