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): ...@@ -82,7 +82,9 @@ class ReplicationHandler(EventHandler):
def connectionLost(self, conn, new_state): def connectionLost(self, conn, new_state):
neo.lib.logging.error( neo.lib.logging.error(
'replication is stopped due to a connection lost') '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): def connectionFailed(self, conn):
neo.lib.logging.error( neo.lib.logging.error(
......
...@@ -240,21 +240,19 @@ class Replicator(object): ...@@ -240,21 +240,19 @@ class Replicator(object):
neo.lib.logging.error("no address known for the selected node %s" % neo.lib.logging.error("no address known for the selected node %s" %
(dump(node.getUUID()), )) (dump(node.getUUID()), ))
return 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) handler = replication.ReplicationHandler(app)
self.current_connection = ClientConnection(app.em, handler, self.current_connection = ClientConnection(app.em, handler,
addr=addr, connector=app.connector_handler()) addr=addr, connector=app.connector_handler())
p = Packets.RequestIdentification(NodeTypes.STORAGE, p = Packets.RequestIdentification(NodeTypes.STORAGE,
app.uuid, app.server, app.name) app.uuid, app.server, app.name)
self.current_connection.ask(p) self.current_connection.ask(p)
if connection is not None:
connection.close()
else: else:
self.current_connection.getHandler().startReplication( connection.getHandler().startReplication(connection)
self.current_connection)
self.replication_done = False self.replication_done = False
def _finishReplication(self): def _finishReplication(self):
...@@ -267,10 +265,10 @@ class Replicator(object): ...@@ -267,10 +265,10 @@ class Replicator(object):
conn.notify(Packets.NotifyReplicationDone(offset)) conn.notify(Packets.NotifyReplicationDone(offset))
except KeyError: except KeyError:
pass pass
if self.pending():
self.current_partition = None self.current_partition = None
if not self.pending(): else:
self.current_connection.close() self.current_connection.close()
self.current_connection = None
def act(self): 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