Commit ef07cc94 authored by Yoshinori Okuji's avatar Yoshinori Okuji

Implement the verification handler.

git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@34 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent ab856708
......@@ -15,6 +15,7 @@ from neo.connection import ListeningConnection, ClientConnection, ServerConnecti
from neo.exception import ElectionFailure, PrimaryFailure, VerificationFailure
from neo.master.election import ElectionEventHandler
from neo.master.recovery import RecoveryEventHandler
from neo.master.verification import VerificationEventHandler
from neo.pt import PartitionTable
class Application(object):
......@@ -417,7 +418,7 @@ class Application(object):
in self.pt.getCellList(partition, True)]
if len(transaction_uuid_list) == 0:
raise VerificationFailure
uuid_list.update(transaction_uuid_list)
uuid_set.update(transaction_uuid_list)
# Gather OIDs.
self.asking_uuid_dict = {}
......@@ -431,8 +432,7 @@ class Application(object):
p.askOIDsByTID(msg_id, tid)
conn.addPacket(p)
conn.expectMessage(msg_id)
break
else:
if len(self.asking_uuid_dict) == 0:
raise VerificationFailure
while 1:
......@@ -442,7 +442,7 @@ class Application(object):
if False not in self.asking_uuid_dict.values():
break
if len(self.unfinished_oid_set) == 0:
if self.unfinished_oid_set is None or len(self.unfinished_oid_set) == 0:
# Not commitable.
return None
else:
......@@ -484,9 +484,14 @@ class Application(object):
"""Verify the data in storage nodes and clean them up, if necessary."""
logging.info('start to verify data')
handler = VerificationEventHandler()
em = self.em
nm = self.nm
# Make sure that every connection has the data verification event handler.
for conn in em.getConnectionList():
conn.setHandler(handler)
# FIXME this part has a potential problem that the write buffers can
# be very huge. Thus it would be better to flush the buffers from time
# to time _without_ reading packets.
......
......@@ -223,7 +223,7 @@ class RecoveryEventHandler(MasterEventHandler):
app = self.app
for node_type, ip_address, port, uuid, state in node_list:
if node_type != CLIENT_NODE:
if node_type == CLIENT_NODE:
# No interest.
continue
......@@ -275,6 +275,8 @@ class RecoveryEventHandler(MasterEventHandler):
self.handleUnexpectedPacket(conn, packet)
return
app = self.app
node = app.nm.getNodeByUUID(uuid)
if not isinstance(node, StorageNode):
self.handleUnexpectedPacket(conn, packet)
......@@ -325,3 +327,22 @@ class RecoveryEventHandler(MasterEventHandler):
app.nm.add(n)
app.pt.setCell(offset, n, state)
def handleAnswerUnfinishedTransactions(self, conn, packet, tid_list):
# This can be from previous verification stage.
pass
def handleAnswerOIDsByTID(self, conn, packet, oid_list, tid):
# This can be from previous verification stage.
pass
def handleTidNotFound(self, conn, packet, message):
# This can be from previous verification stage.
pass
def handleAnswerObjectPresent(self, conn, packet, oid, tid):
# This can be from previous verification stage.
pass
def handleOidNotFound(self, conn, packet, message):
# This can be from previous verification stage.
pass
This diff is collapsed.
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