Commit bb146239 authored by Julien Muchembled's avatar Julien Muchembled

replication: fix AttributeError when storage switches to another storage

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2733 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 4b6c1387
......@@ -82,7 +82,9 @@ class ReplicationHandler(EventHandler):
def connectionLost(self, conn, new_state):
neo.lib.logging.error(
'replication is stopped due to a connection lost')
self.app.replicator.storageLost()
replicator = self.app.replicator
if replicator.isCurrentConnection(conn):
replicator.storageLost()
def connectionFailed(self, conn):
neo.lib.logging.error(
......
......@@ -240,21 +240,19 @@ class Replicator(object):
neo.lib.logging.error("no address known for the selected node %s" %
(dump(node.getUUID()), ))
return
if self.current_connection is not None:
if self.current_connection.getAddress() != addr:
self.current_connection.close()
self.current_connection = None
if self.current_connection is None:
connection = self.current_connection
if connection is None or connection.getAddress() != addr:
handler = replication.ReplicationHandler(app)
self.current_connection = ClientConnection(app.em, handler,
addr=addr, connector=app.connector_handler())
p = Packets.RequestIdentification(NodeTypes.STORAGE,
app.uuid, app.server, app.name)
self.current_connection.ask(p)
if connection is not None:
connection.close()
else:
self.current_connection.getHandler().startReplication(
self.current_connection)
connection.getHandler().startReplication(connection)
self.replication_done = False
def _finishReplication(self):
......@@ -267,10 +265,10 @@ class Replicator(object):
conn.notify(Packets.NotifyReplicationDone(offset))
except KeyError:
pass
self.current_partition = None
if not self.pending():
if self.pending():
self.current_partition = None
else:
self.current_connection.close()
self.current_connection = None
def act(self):
......
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