[Neo-report] r2198 gregory - in /trunk/neo: master/handlers/ storage/handlers/

nobody at svn.erp5.org nobody at svn.erp5.org
Wed Aug 4 10:54:09 CEST 2010


Author: gregory
Date: Wed Aug  4 10:54:08 2010
New Revision: 2198

Log:
Don't import the whole protocol module.

Modified:
    trunk/neo/master/handlers/election.py
    trunk/neo/master/handlers/identification.py
    trunk/neo/storage/handlers/identification.py

Modified: trunk/neo/master/handlers/election.py
==============================================================================
--- trunk/neo/master/handlers/election.py [iso-8859-1] (original)
+++ trunk/neo/master/handlers/election.py [iso-8859-1] Wed Aug  4 10:54:08 2010
@@ -17,8 +17,9 @@
 
 from neo import logging
 
-from neo import protocol
 from neo.protocol import NodeTypes, Packets
+from neo.protocol import NotReadyError, ProtocolError, UnexpectedPacketError
+from neo.protocol import BrokenNodeDisallowedError
 from neo.master.handlers import MasterHandler
 from neo.exception import ElectionFailure
 from neo.util import dump
@@ -28,7 +29,6 @@ class ClientElectionHandler(MasterHandle
     # FIXME: this packet is not allowed here, but handled in MasterHandler
     # a global handler review is required.
     def askPrimary(self, conn):
-        from neo.protocol import UnexpectedPacketError
         raise UnexpectedPacketError, "askPrimary on server connection"
 
     def packetReceived(self, conn, packet):
@@ -204,15 +204,15 @@ class ServerElectionHandler(MasterHandle
         app = self.app
         if node_type != NodeTypes.MASTER:
             logging.info('reject a connection from a non-master')
-            raise protocol.NotReadyError
+            raise NotReadyError
         node = app.nm.getByAddress(address)
         if node is None:
             logging.error('unknown master node: %s' % (address, ))
-            raise protocol.ProtocolError('unknown master node')
+            raise ProtocolError('unknown master node')
         # If this node is broken, reject it.
         if node.getUUID() == uuid:
             if node.isBroken():
-                raise protocol.BrokenNodeDisallowedError
+                raise BrokenNodeDisallowedError
 
         # supplied another uuid in case of conflict
         while not app.isValidUUID(uuid, address):
@@ -233,7 +233,7 @@ class ServerElectionHandler(MasterHandle
     def announcePrimary(self, conn):
         uuid = conn.getUUID()
         if uuid is None:
-            raise protocol.ProtocolError('Not identified')
+            raise ProtocolError('Not identified')
         app = self.app
         if app.primary:
             # I am also the primary... So restart the election.

Modified: trunk/neo/master/handlers/identification.py
==============================================================================
--- trunk/neo/master/handlers/identification.py [iso-8859-1] (original)
+++ trunk/neo/master/handlers/identification.py [iso-8859-1] Wed Aug  4 10:54:08 2010
@@ -17,8 +17,8 @@
 
 from neo import logging
 
-from neo import protocol
 from neo.protocol import NodeTypes, Packets
+from neo.protocol import BrokenNodeDisallowedError, ProtocolError
 from neo.master.handlers import MasterHandler
 
 class IdentificationHandler(MasterHandler):
@@ -40,20 +40,20 @@ class IdentificationHandler(MasterHandle
             if node.getAddress() == address:
                 # the node is still alive
                 if node.isBroken():
-                    raise protocol.BrokenNodeDisallowedError
+                    raise BrokenNodeDisallowedError
             if node.getAddress() != address:
                 # this node has changed its address
                 if node.isRunning():
                    # still running, reject this new node
-                    raise protocol.ProtocolError('invalid server address')
+                    raise ProtocolError('invalid server address')
         if node_by_uuid is None and node_by_addr is not None:
             if node.isRunning():
                 # still running, reject this new node
-                raise protocol.ProtocolError('invalid server address')
+                raise ProtocolError('invalid server address')
         if node is not None:
             if node.isConnected():
                 # more than one connection from this node
-                raise protocol.ProtocolError('already connected')
+                raise ProtocolError('already connected')
             node.setAddress(address)
             node.setRunning()
 

Modified: trunk/neo/storage/handlers/identification.py
==============================================================================
--- trunk/neo/storage/handlers/identification.py [iso-8859-1] (original)
+++ trunk/neo/storage/handlers/identification.py [iso-8859-1] Wed Aug  4 10:54:08 2010
@@ -18,8 +18,8 @@
 from neo import logging
 
 from neo.handler import EventHandler
-from neo.protocol import NodeTypes, Packets
-from neo import protocol
+from neo.protocol import NodeTypes, Packets, NotReadyError
+from neo.protocol import ProtocolError, BrokenNodeDisallowedError
 from neo.util import dump
 
 class IdentificationHandler(EventHandler):
@@ -33,12 +33,12 @@ class IdentificationHandler(EventHandler
         self.checkClusterName(name)
         # reject any incoming connections if not ready
         if not self.app.ready:
-            raise protocol.NotReadyError
+            raise NotReadyError
         app = self.app
         node = app.nm.getByUUID(uuid)
         # If this node is broken, reject it.
         if node is not None and node.isBroken():
-            raise protocol.BrokenNodeDisallowedError
+            raise BrokenNodeDisallowedError
         # choose the handler according to the node type
         if node_type == NodeTypes.CLIENT:
             from neo.storage.handlers.client import ClientOperationHandler
@@ -55,9 +55,9 @@ class IdentificationHandler(EventHandler
             handler = StorageOperationHandler
             if node is None:
                 logging.error('reject an unknown storage node %s', dump(uuid))
-                raise protocol.NotReadyError
+                raise NotReadyError
         else:
-            raise protocol.ProtocolError('reject non-client-or-storage node')
+            raise ProtocolError('reject non-client-or-storage node')
         # apply the handler and set up the connection
         handler = handler(self.app)
         conn.setUUID(uuid)





More information about the Neo-report mailing list