Commit 1273ed2f authored by Vincent Pelletier's avatar Vincent Pelletier

Define a method to call when reference storage is down.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2437 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 9a7f8c7f
......@@ -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):
......
......@@ -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
......
......@@ -160,12 +160,12 @@ class StorageReplicationHandlerTests(NeoUnitTestBase):
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
......
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