Commit 5feef375 authored by Grégory Wisniewski's avatar Grégory Wisniewski

Handler init's app parameter moved to base handler, fix some imports and method

signature. In PartitionTable, return en empty list instead of a tuple to have
constistent types.


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@821 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 16423caa
......@@ -33,9 +33,8 @@ from neo import decorators
class BaseEventHandler(EventHandler):
""" Base handler for admin node """
def __init__(self, app):
self.app = app
EventHandler.__init__(self)
pass
class AdminEventHandler(BaseEventHandler):
"""This class deals with events for administrating cluster."""
......
......@@ -22,9 +22,8 @@ class BaseHandler(EventHandler):
"""Base class for client-side EventHandler implementations."""
def __init__(self, app, dispatcher):
self.app = app
super(BaseHandler, self).__init__(app)
self.dispatcher = dispatcher
super(BaseHandler, self).__init__()
def dispatch(self, conn, packet):
# Before calling superclass's dispatch method, lock the connection.
......
......@@ -47,7 +47,8 @@ from protocol import ERROR, REQUEST_NODE_IDENTIFICATION, ACCEPT_NODE_IDENTIFICAT
class EventHandler(object):
"""This class handles events."""
def __init__(self):
def __init__(self, app):
self.app = app
self.initPacketDispatchTable()
self.initErrorDispatchTable()
......
......@@ -24,10 +24,6 @@ from neo.protocol import INVALID_UUID, BROKEN_STATE
class MasterEventHandler(EventHandler):
"""This class implements a generic part of the event handlers."""
def __init__(self, app):
self.app = app
EventHandler.__init__(self)
def handleNotifyNodeInformation(self, conn, packet, node_list):
logging.error('ignoring Notify Node Information in %s', self.__class__.__name__)
......
......@@ -234,7 +234,7 @@ class PartitionTable(object):
def getRow(self, offset):
row = self.partition_list[offset]
if row is None:
return ()
return []
return [(cell.getUUID(), cell.getState()) for cell in row]
......
......@@ -30,9 +30,6 @@ from neo import decorators
class BaseStorageHandler(EventHandler):
"""This class implements a generic part of the event handlers."""
def __init__(self, app):
self.app = app
EventHandler.__init__(self)
def dealWithClientFailure(self, uuid):
pass
......
......@@ -28,10 +28,10 @@ class InitializationHandler(BaseMasterHandler):
assert not node_list
self.app.has_node_information = True
def handleNotifyNodeInformation(self, *args, **kw):
def handleNotifyNodeInformation(self, conn, packet, node_list):
# FIXME: This message could be replaced by a SendNodeInformation to be
# consistent with SendPartitionTable.
BaseMasterHandler.handleNotifyNodeInformation(self, *args, **kw)
BaseMasterHandler.handleNotifyNodeInformation(self, conn, packet, node_list)
def handleSendPartitionTable(self, conn, packet, ptid, row_list):
"""A primary master node sends this packet to synchronize a partition
......
......@@ -19,8 +19,6 @@ import logging
from neo import protocol
from neo.storage.handlers.handler import BaseClientAndStorageOperationHandler
from neo.protocol import INVALID_SERIAL, INVALID_TID, INVALID_PARTITION, \
TEMPORARILY_DOWN_STATE, DISCARDED_STATE, OUT_OF_DATE_STATE
class StorageOperationHandler(BaseClientAndStorageOperationHandler):
......@@ -30,8 +28,8 @@ class StorageOperationHandler(BaseClientAndStorageOperationHandler):
def handleAskLastIDs(self, conn, packet):
app = self.app
oid = app.dm.getLastOID() or INVALID_OID
tid = app.dm.getLastTID() or INVALID_TID
oid = app.dm.getLastOID() or protocol.INVALID_OID
tid = app.dm.getLastTID() or protocol.INVALID_TID
p = protocol.answerLastIDs(oid, tid, app.ptid)
conn.answer(p, packet)
......@@ -43,7 +41,7 @@ class StorageOperationHandler(BaseClientAndStorageOperationHandler):
app = self.app
if partition == INVALID_PARTITION:
if partition == protocol.INVALID_PARTITION:
# Collect all usable partitions for me.
getCellList = app.pt.getCellList
partition_list = []
......
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