Commit 2245bf19 authored by Grégory Wisniewski's avatar Grégory Wisniewski

Rename handleConnectionLost to connectionLost for consistency. Add in the TODO

list to think about a global rename of handler's methods.


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@1148 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 6b121f40
...@@ -68,7 +68,8 @@ RC - Review output of pylint (CODE) ...@@ -68,7 +68,8 @@ RC - Review output of pylint (CODE)
types, group, consider using one class per paquet, extract patterns. types, group, consider using one class per paquet, extract patterns.
- Review handler split (CODE) - Review handler split (CODE)
The current handler split is the result of small incremental changes. A The current handler split is the result of small incremental changes. A
global review is required to make them square. global review is required to make them square. Consider rename handler
methods without the 'handle' prefix.
Storage Storage
- Implement incremental storage verification (BANDWITH) - Implement incremental storage verification (BANDWITH)
......
...@@ -50,7 +50,7 @@ class BootstrapManager(EventHandler): ...@@ -50,7 +50,7 @@ class BootstrapManager(EventHandler):
EventHandler.connectionFailed(self, conn) EventHandler.connectionFailed(self, conn)
self.current = None self.current = None
def handleConnectionLost(self, conn, new_state): def connectionLost(self, conn, new_state):
self.current = None self.current = None
def handleNotReady(self, conn, packet, message): def handleNotReady(self, conn, packet, message):
......
...@@ -46,7 +46,7 @@ class BaseHandler(EventHandler): ...@@ -46,7 +46,7 @@ class BaseHandler(EventHandler):
self.dispatch(conn, packet) self.dispatch(conn, packet)
def handleConnectionLost(self, conn, new_state): def connectionLost(self, conn, new_state):
self.app.dispatcher.unregister(conn) self.app.dispatcher.unregister(conn)
def connectionFailed(self, conn): def connectionFailed(self, conn):
......
...@@ -31,7 +31,7 @@ class StorageEventHandler(BaseHandler): ...@@ -31,7 +31,7 @@ class StorageEventHandler(BaseHandler):
app.cp.removeConnection(node) app.cp.removeConnection(node)
app.dispatcher.unregister(conn) app.dispatcher.unregister(conn)
def handleConnectionLost(self, conn, new_state): def connectionLost(self, conn, new_state):
self._dealWithStorageFailure(conn) self._dealWithStorageFailure(conn)
def connectionFailed(self, conn): def connectionFailed(self, conn):
......
...@@ -147,19 +147,19 @@ class EventHandler(object): ...@@ -147,19 +147,19 @@ class EventHandler(object):
def timeoutExpired(self, conn): def timeoutExpired(self, conn):
"""Called when a timeout event occurs.""" """Called when a timeout event occurs."""
logging.debug('timeout expired for %s:%d', *(conn.getAddress())) logging.debug('timeout expired for %s:%d', *(conn.getAddress()))
self.handleConnectionLost(conn, protocol.TEMPORARILY_DOWN_STATE) self.connectionLost(conn, protocol.TEMPORARILY_DOWN_STATE)
def connectionClosed(self, conn): def connectionClosed(self, conn):
"""Called when a connection is closed by the peer.""" """Called when a connection is closed by the peer."""
logging.debug('connection closed for %s:%d', *(conn.getAddress())) logging.debug('connection closed for %s:%d', *(conn.getAddress()))
self.handleConnectionLost(conn, protocol.TEMPORARILY_DOWN_STATE) self.connectionLost(conn, protocol.TEMPORARILY_DOWN_STATE)
def peerBroken(self, conn): def peerBroken(self, conn):
"""Called when a peer is broken.""" """Called when a peer is broken."""
logging.error('%s:%d is broken', *(conn.getAddress())) logging.error('%s:%d is broken', *(conn.getAddress()))
self.handleConnectionLost(conn, protocol.BROKEN_STATE) self.connectionLost(conn, protocol.BROKEN_STATE)
def handleConnectionLost(self, conn, new_state): def connectionLost(self, conn, new_state):
""" this is a method to override in sub-handlers when there is no need """ this is a method to override in sub-handlers when there is no need
to make distinction from the kind event that closed the connection """ to make distinction from the kind event that closed the connection """
pass pass
......
...@@ -80,7 +80,7 @@ class BaseServiceHandler(MasterHandler): ...@@ -80,7 +80,7 @@ class BaseServiceHandler(MasterHandler):
# It is triggered when a connection to a node gets lost. # It is triggered when a connection to a node gets lost.
pass pass
def handleConnectionLost(self, conn, new_state): def connectionLost(self, conn, new_state):
node = self.app.nm.getNodeByUUID(conn.getUUID()) node = self.app.nm.getNodeByUUID(conn.getUUID())
assert node is not None assert node is not None
if new_state != protocol.BROKEN_STATE: if new_state != protocol.BROKEN_STATE:
......
...@@ -26,7 +26,7 @@ from neo.util import dump ...@@ -26,7 +26,7 @@ from neo.util import dump
class AdministrationHandler(MasterHandler): class AdministrationHandler(MasterHandler):
"""This class deals with messages from the admin node only""" """This class deals with messages from the admin node only"""
def handleConnectionLost(self, conn, new_state): def connectionLost(self, conn, new_state):
node = self.app.nm.getNodeByUUID(conn.getUUID()) node = self.app.nm.getNodeByUUID(conn.getUUID())
self.app.nm.remove(node) self.app.nm.remove(node)
......
...@@ -27,7 +27,7 @@ from neo.node import MasterNode ...@@ -27,7 +27,7 @@ from neo.node import MasterNode
class SecondaryMasterHandler(MasterHandler): class SecondaryMasterHandler(MasterHandler):
""" Handler used by primary to handle secondary masters""" """ Handler used by primary to handle secondary masters"""
def handleConnectionLost(self, conn, new_state): def connectionLost(self, conn, new_state):
node = self.app.nm.getNodeByUUID(conn.getUUID()) node = self.app.nm.getNodeByUUID(conn.getUUID())
assert node is not None assert node is not None
node.setState(DOWN_STATE) node.setState(DOWN_STATE)
......
...@@ -32,7 +32,7 @@ class BaseStorageHandler(EventHandler): ...@@ -32,7 +32,7 @@ class BaseStorageHandler(EventHandler):
class BaseMasterHandler(BaseStorageHandler): class BaseMasterHandler(BaseStorageHandler):
def handleConnectionLost(self, conn, new_state): def connectionLost(self, conn, new_state):
raise PrimaryFailure('connection lost') raise PrimaryFailure('connection lost')
def handleReelectPrimaryMaster(self, conn, packet): def handleReelectPrimaryMaster(self, conn, packet):
......
...@@ -25,7 +25,7 @@ from neo.node import ClientNode ...@@ -25,7 +25,7 @@ from neo.node import ClientNode
class IdentificationHandler(BaseStorageHandler): class IdentificationHandler(BaseStorageHandler):
""" Handler used for incoming connections during operation state """ """ Handler used for incoming connections during operation state """
def handleConnectionLost(self, conn, new_state): def connectionLost(self, conn, new_state):
logging.warning('A connection was lost during identification') logging.warning('A connection was lost during identification')
def handleRequestNodeIdentification(self, conn, packet, node_type, def handleRequestNodeIdentification(self, conn, packet, node_type,
......
...@@ -28,7 +28,7 @@ class ReplicationHandler(BaseStorageHandler): ...@@ -28,7 +28,7 @@ class ReplicationHandler(BaseStorageHandler):
# Nothing to do. # Nothing to do.
pass pass
def handleConnectionLost(self, conn, new_state): def connectionLost(self, conn, new_state):
logging.error('replication is stopped due to a connection lost') logging.error('replication is stopped due to a connection lost')
self.app.replicator.reset() self.app.replicator.reset()
......
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