[Neo-report] r2437 vincent - in /trunk/neo: storage/ storage/handlers/ tests/storage/

nobody at svn.erp5.org nobody at svn.erp5.org
Mon Nov 8 16:09:30 CET 2010


Author: vincent
Date: Mon Nov  8 16:09:28 2010
New Revision: 2437

Log:
Define a method to call when reference storage is down.

Modified:
    trunk/neo/storage/handlers/replication.py
    trunk/neo/storage/replicator.py
    trunk/neo/tests/storage/testReplicationHandler.py

Modified: trunk/neo/storage/handlers/replication.py
==============================================================================
--- trunk/neo/storage/handlers/replication.py [iso-8859-1] (original)
+++ trunk/neo/storage/handlers/replication.py [iso-8859-1] Mon Nov  8 16:09:28 2010
@@ -87,11 +87,11 @@ class ReplicationHandler(EventHandler):
 
     def connectionLost(self, conn, new_state):
         neo.logging.error('replication is stopped due to a connection lost')
-        self.app.replicator.reset()
+        self.app.replicator.storageLost()
 
     def connectionFailed(self, conn):
         neo.logging.error('replication is stopped due to connection failure')
-        self.app.replicator.reset()
+        self.app.replicator.storageLost()
 
     def acceptIdentification(self, conn, node_type,
                        uuid, num_partitions, num_replicas, your_uuid):

Modified: trunk/neo/storage/replicator.py
==============================================================================
--- trunk/neo/storage/replicator.py [iso-8859-1] (original)
+++ trunk/neo/storage/replicator.py [iso-8859-1] Mon Nov  8 16:09:28 2010
@@ -162,6 +162,12 @@ class Replicator(object):
         self.critical_tid_list = []
         self.waiting_for_unfinished_tids = False
 
+    def storageLost(self):
+        """
+        Restart replicating.
+        """
+        self.reset()
+
     def populate(self):
         """
         Populate partitions to replicate. Must be called when partition

Modified: trunk/neo/tests/storage/testReplicationHandler.py
==============================================================================
--- trunk/neo/tests/storage/testReplicationHandler.py [iso-8859-1] (original)
+++ trunk/neo/tests/storage/testReplicationHandler.py [iso-8859-1] Mon Nov  8 16:09:28 2010
@@ -160,12 +160,12 @@ class StorageReplicationHandlerTests(Neo
     def test_connectionLost(self):
         app = self.getApp()
         ReplicationHandler(app).connectionLost(None, None)
-        self.assertEqual(len(app.replicator.mockGetNamedCalls('reset')), 1)
+        self.assertEqual(len(app.replicator.mockGetNamedCalls('storageLost')), 1)
 
     def test_connectionFailed(self):
         app = self.getApp()
         ReplicationHandler(app).connectionFailed(None)
-        self.assertEqual(len(app.replicator.mockGetNamedCalls('reset')), 1)
+        self.assertEqual(len(app.replicator.mockGetNamedCalls('storageLost')), 1)
 
     def test_acceptIdentification(self):
         rid = 24





More information about the Neo-report mailing list