[Neo-report] r2733 jm - in /trunk/neo/storage: handlers/replication.py replicator.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Wed Apr 27 17:41:02 CEST 2011
Author: jm
Date: Wed Apr 27 17:41:02 2011
New Revision: 2733
Log:
replication: fix AttributeError when storage switches to another storage
Modified:
trunk/neo/storage/handlers/replication.py
trunk/neo/storage/replicator.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] Wed Apr 27 17:41:02 2011
@@ -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(
Modified: trunk/neo/storage/replicator.py
==============================================================================
--- trunk/neo/storage/replicator.py [iso-8859-1] (original)
+++ trunk/neo/storage/replicator.py [iso-8859-1] Wed Apr 27 17:41:02 2011
@@ -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):
More information about the Neo-report
mailing list