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

As done for client application, move storage handlers into a dedicated

directory. Replicator's handler is moved into handlers/replication.py. 
Clean some imports.


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@776 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent bfc78394
...@@ -30,12 +30,8 @@ from neo.event import EventManager ...@@ -30,12 +30,8 @@ from neo.event import EventManager
from neo.storage.mysqldb import MySQLDatabaseManager from neo.storage.mysqldb import MySQLDatabaseManager
from neo.connection import ListeningConnection, ClientConnection from neo.connection import ListeningConnection, ClientConnection
from neo.exception import OperationFailure, PrimaryFailure from neo.exception import OperationFailure, PrimaryFailure
from neo.storage.bootstrap import BootstrapEventHandler from neo.storage import handlers
from neo.storage.verification import VerificationEventHandler
from neo.storage.operation import MasterOperationEventHandler
from neo.storage.hidden import HiddenEventHandler
from neo.storage.replicator import Replicator from neo.storage.replicator import Replicator
from neo.storage.identification import IdentificationEventHandler
from neo.connector import getConnectorHandler from neo.connector import getConnectorHandler
from neo.pt import PartitionTable from neo.pt import PartitionTable
from neo.util import dump from neo.util import dump
...@@ -138,7 +134,7 @@ class Application(object): ...@@ -138,7 +134,7 @@ class Application(object):
self.nm.add(MasterNode(server = server)) self.nm.add(MasterNode(server = server))
# Make a listening port # Make a listening port
handler = IdentificationEventHandler(self) handler = handlers.IdentificationEventHandler(self)
self.listening_conn = ListeningConnection(self.em, handler, self.listening_conn = ListeningConnection(self.em, handler,
addr=self.server, connector_handler=self.connector_handler) addr=self.server, connector_handler=self.connector_handler)
...@@ -188,7 +184,7 @@ class Application(object): ...@@ -188,7 +184,7 @@ class Application(object):
self.ptid = self.dm.getPTID() self.ptid = self.dm.getPTID()
# bootstrap handler, only for outgoing connections # bootstrap handler, only for outgoing connections
handler = BootstrapEventHandler(self) handler = handlers.BootstrapEventHandler(self)
em = self.em em = self.em
nm = self.nm nm = self.nm
...@@ -232,7 +228,7 @@ class Application(object): ...@@ -232,7 +228,7 @@ class Application(object):
node = nm.getNodeByUUID(uuid) node = nm.getNodeByUUID(uuid)
if node is self.primary_master_node: if node is self.primary_master_node:
# Yes, I have. # Yes, I have.
conn.setHandler(VerificationEventHandler(self)) conn.setHandler(handlers.VerificationEventHandler(self))
self.master_conn = conn self.master_conn = conn
return return
...@@ -241,7 +237,7 @@ class Application(object): ...@@ -241,7 +237,7 @@ class Application(object):
Connections from client nodes may not be accepted at this stage.""" Connections from client nodes may not be accepted at this stage."""
logging.info('verifying data') logging.info('verifying data')
handler = VerificationEventHandler(self) handler = handlers.VerificationEventHandler(self)
self.master_conn.setHandler(handler) self.master_conn.setHandler(handler)
em = self.em em = self.em
...@@ -263,7 +259,7 @@ class Application(object): ...@@ -263,7 +259,7 @@ class Application(object):
em = self.em em = self.em
nm = self.nm nm = self.nm
handler = MasterOperationEventHandler(self) handler = handlers.MasterOperationEventHandler(self)
self.master_conn.setHandler(handler) self.master_conn.setHandler(handler)
# Forget all unfinished data. # Forget all unfinished data.
...@@ -296,7 +292,7 @@ class Application(object): ...@@ -296,7 +292,7 @@ class Application(object):
def wait(self): def wait(self):
# change handler # change handler
logging.info("waiting in hidden state") logging.info("waiting in hidden state")
handler = HiddenEventHandler(self) handler = handlers.HiddenEventHandler(self)
for conn in self.em.getConnectionList(): for conn in self.em.getConnectionList():
conn.setHandler(handler) conn.setHandler(handler)
......
from neo.storage.handlers.hidden import HiddenEventHandler
from neo.storage.handlers.identification import IdentificationEventHandler
from neo.storage.handlers.bootstrap import BootstrapEventHandler
from neo.storage.handlers.verification import VerificationEventHandler
from neo.storage.handlers.operation import MasterOperationEventHandler, \
ClientOperationEventHandler, StorageOperationEventHandler
...@@ -17,15 +17,11 @@ ...@@ -17,15 +17,11 @@
import logging import logging
from neo.storage.handlers.handler import StorageEventHandler
from neo.protocol import INVALID_UUID, MASTER_NODE_TYPE, STORAGE_NODE_TYPE
from neo.node import MasterNode
from neo import protocol from neo import protocol
from neo.storage.handler import StorageEventHandler
from neo.protocol import INVALID_UUID, RUNNING_STATE, BROKEN_STATE, \
MASTER_NODE_TYPE, STORAGE_NODE_TYPE, CLIENT_NODE_TYPE
from neo.node import MasterNode, StorageNode, ClientNode
from neo.connection import ClientConnection
from neo.protocol import Packet, UnexpectedPacketError
from neo.pt import PartitionTable from neo.pt import PartitionTable
from neo.storage.verification import VerificationEventHandler
from neo.util import dump from neo.util import dump
class BootstrapEventHandler(StorageEventHandler): class BootstrapEventHandler(StorageEventHandler):
......
...@@ -22,7 +22,6 @@ from neo.protocol import Packet, UnexpectedPacketError, \ ...@@ -22,7 +22,6 @@ from neo.protocol import Packet, UnexpectedPacketError, \
INVALID_UUID, RUNNING_STATE, BROKEN_STATE, \ INVALID_UUID, RUNNING_STATE, BROKEN_STATE, \
MASTER_NODE_TYPE, STORAGE_NODE_TYPE, CLIENT_NODE_TYPE, \ MASTER_NODE_TYPE, STORAGE_NODE_TYPE, CLIENT_NODE_TYPE, \
DOWN_STATE, TEMPORARILY_DOWN_STATE, HIDDEN_STATE DOWN_STATE, TEMPORARILY_DOWN_STATE, HIDDEN_STATE
from neo.util import dump from neo.util import dump
from neo.node import MasterNode, StorageNode, ClientNode from neo.node import MasterNode, StorageNode, ClientNode
from neo.connection import ClientConnection from neo.connection import ClientConnection
......
...@@ -17,21 +17,20 @@ ...@@ -17,21 +17,20 @@
import logging import logging
from neo.storage.handler import EventHandler from neo.storage.handlers.handler import StorageEventHandler
from neo.protocol import Packet, \ from neo.protocol import Packet, \
INVALID_UUID, RUNNING_STATE, BROKEN_STATE, \ INVALID_UUID, RUNNING_STATE, BROKEN_STATE, \
MASTER_NODE_TYPE, STORAGE_NODE_TYPE, CLIENT_NODE_TYPE, \ MASTER_NODE_TYPE, STORAGE_NODE_TYPE, CLIENT_NODE_TYPE, \
DOWN_STATE, TEMPORARILY_DOWN_STATE, HIDDEN_STATE, \ DOWN_STATE, TEMPORARILY_DOWN_STATE, HIDDEN_STATE, \
DISCARDED_STATE, OUT_OF_DATE_STATE DISCARDED_STATE, OUT_OF_DATE_STATE
from neo.node import StorageNode
from neo.util import dump
from neo.node import MasterNode, StorageNode, ClientNode
from neo.connection import ClientConnection from neo.connection import ClientConnection
from neo.exception import PrimaryFailure
from neo import decorators from neo import decorators
class HiddenEventHandler(EventHandler): # FIXME: before move handlers, this one was inheriting from EventHandler
# instead of StorageEventHandler
class HiddenEventHandler(StorageEventHandler):
"""This class implements a generic part of the event handlers.""" """This class implements a generic part of the event handlers."""
def __init__(self, app): def __init__(self, app):
self.app = app self.app = app
......
...@@ -17,12 +17,9 @@ ...@@ -17,12 +17,9 @@
import logging import logging
from neo.storage.handlers.handler import StorageEventHandler
from neo.protocol import BROKEN_STATE, STORAGE_NODE_TYPE, CLIENT_NODE_TYPE
from neo import protocol from neo import protocol
from neo.storage.handler import StorageEventHandler
from neo.protocol import INVALID_SERIAL, INVALID_TID, \
INVALID_PARTITION, BROKEN_STATE, TEMPORARILY_DOWN_STATE, \
MASTER_NODE_TYPE, STORAGE_NODE_TYPE, CLIENT_NODE_TYPE, \
DISCARDED_STATE, OUT_OF_DATE_STATE
from neo.util import dump from neo.util import dump
class IdentificationEventHandler(StorageEventHandler): class IdentificationEventHandler(StorageEventHandler):
......
...@@ -18,15 +18,11 @@ ...@@ -18,15 +18,11 @@
import logging import logging
from neo import protocol from neo import protocol
from neo.storage.handler import StorageEventHandler from neo.storage.handlers.handler import StorageEventHandler
from neo.protocol import INVALID_SERIAL, INVALID_TID, \ from neo.protocol import INVALID_SERIAL, INVALID_TID, INVALID_PARTITION, \
INVALID_PARTITION, \ TEMPORARILY_DOWN_STATE, DISCARDED_STATE, OUT_OF_DATE_STATE
BROKEN_STATE, TEMPORARILY_DOWN_STATE, \
MASTER_NODE_TYPE, STORAGE_NODE_TYPE, CLIENT_NODE_TYPE, \
DISCARDED_STATE, OUT_OF_DATE_STATE
from neo.util import dump from neo.util import dump
from neo.node import StorageNode from neo.node import StorageNode
from neo.protocol import Packet, UnexpectedPacketError
from neo.exception import PrimaryFailure, OperationFailure from neo.exception import PrimaryFailure, OperationFailure
class TransactionInformation(object): class TransactionInformation(object):
......
...@@ -17,12 +17,9 @@ ...@@ -17,12 +17,9 @@
import logging import logging
from neo.storage.handlers.handler import StorageEventHandler
from neo.protocol import INVALID_OID, INVALID_TID, TEMPORARILY_DOWN_STATE
from neo import protocol from neo import protocol
from neo.storage.handler import StorageEventHandler
from neo.protocol import INVALID_OID, INVALID_TID, \
BROKEN_STATE, TEMPORARILY_DOWN_STATE, \
MASTER_NODE_TYPE, STORAGE_NODE_TYPE, \
Packet, UnexpectedPacketError
from neo.util import dump from neo.util import dump
from neo.node import StorageNode from neo.node import StorageNode
from neo.exception import PrimaryFailure, OperationFailure from neo.exception import PrimaryFailure, OperationFailure
......
...@@ -18,12 +18,13 @@ ...@@ -18,12 +18,13 @@
import logging import logging
from random import choice from random import choice
from neo.storage.handlers.handler import StorageEventHandler
from neo.storage.handlers.replication import ReplicationEventHandler
from neo import protocol from neo import protocol
from neo.protocol import Packet, STORAGE_NODE_TYPE, \ from neo.protocol import Packet, STORAGE_NODE_TYPE, \
UP_TO_DATE_STATE, OUT_OF_DATE_STATE, \ UP_TO_DATE_STATE, OUT_OF_DATE_STATE, \
INVALID_OID, INVALID_TID, RUNNING_STATE INVALID_OID, INVALID_TID, RUNNING_STATE
from neo.connection import ClientConnection from neo.connection import ClientConnection
from neo.storage.handler import StorageEventHandler
from neo.util import dump from neo.util import dump
from neo import protocol from neo import protocol
......
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