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 ...@@ -15,6 +15,7 @@ from neo.connection import ListeningConnection, ClientConnection, ServerConnecti
from neo.exception import ElectionFailure, PrimaryFailure, VerificationFailure from neo.exception import ElectionFailure, PrimaryFailure, VerificationFailure
from neo.master.election import ElectionEventHandler from neo.master.election import ElectionEventHandler
from neo.master.recovery import RecoveryEventHandler from neo.master.recovery import RecoveryEventHandler
from neo.master.verification import VerificationEventHandler
from neo.pt import PartitionTable from neo.pt import PartitionTable
class Application(object): class Application(object):
...@@ -417,7 +418,7 @@ class Application(object): ...@@ -417,7 +418,7 @@ class Application(object):
in self.pt.getCellList(partition, True)] in self.pt.getCellList(partition, True)]
if len(transaction_uuid_list) == 0: if len(transaction_uuid_list) == 0:
raise VerificationFailure raise VerificationFailure
uuid_list.update(transaction_uuid_list) uuid_set.update(transaction_uuid_list)
# Gather OIDs. # Gather OIDs.
self.asking_uuid_dict = {} self.asking_uuid_dict = {}
...@@ -431,8 +432,7 @@ class Application(object): ...@@ -431,8 +432,7 @@ class Application(object):
p.askOIDsByTID(msg_id, tid) p.askOIDsByTID(msg_id, tid)
conn.addPacket(p) conn.addPacket(p)
conn.expectMessage(msg_id) conn.expectMessage(msg_id)
break if len(self.asking_uuid_dict) == 0:
else:
raise VerificationFailure raise VerificationFailure
while 1: while 1:
...@@ -442,7 +442,7 @@ class Application(object): ...@@ -442,7 +442,7 @@ class Application(object):
if False not in self.asking_uuid_dict.values(): if False not in self.asking_uuid_dict.values():
break break
if len(self.unfinished_oid_set) == 0: if self.unfinished_oid_set is None or len(self.unfinished_oid_set) == 0:
# Not commitable. # Not commitable.
return None return None
else: else:
...@@ -484,9 +484,14 @@ class Application(object): ...@@ -484,9 +484,14 @@ class Application(object):
"""Verify the data in storage nodes and clean them up, if necessary.""" """Verify the data in storage nodes and clean them up, if necessary."""
logging.info('start to verify data') logging.info('start to verify data')
handler = VerificationEventHandler()
em = self.em em = self.em
nm = self.nm 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 # 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 # be very huge. Thus it would be better to flush the buffers from time
# to time _without_ reading packets. # to time _without_ reading packets.
......
...@@ -223,7 +223,7 @@ class RecoveryEventHandler(MasterEventHandler): ...@@ -223,7 +223,7 @@ class RecoveryEventHandler(MasterEventHandler):
app = self.app app = self.app
for node_type, ip_address, port, uuid, state in node_list: for node_type, ip_address, port, uuid, state in node_list:
if node_type != CLIENT_NODE: if node_type == CLIENT_NODE:
# No interest. # No interest.
continue continue
...@@ -275,6 +275,8 @@ class RecoveryEventHandler(MasterEventHandler): ...@@ -275,6 +275,8 @@ class RecoveryEventHandler(MasterEventHandler):
self.handleUnexpectedPacket(conn, packet) self.handleUnexpectedPacket(conn, packet)
return return
app = self.app
node = app.nm.getNodeByUUID(uuid) node = app.nm.getNodeByUUID(uuid)
if not isinstance(node, StorageNode): if not isinstance(node, StorageNode):
self.handleUnexpectedPacket(conn, packet) self.handleUnexpectedPacket(conn, packet)
...@@ -325,3 +327,22 @@ class RecoveryEventHandler(MasterEventHandler): ...@@ -325,3 +327,22 @@ class RecoveryEventHandler(MasterEventHandler):
app.nm.add(n) app.nm.add(n)
app.pt.setCell(offset, n, state) 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