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