You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by rh...@apache.org on 2010/04/01 23:36:57 UTC
svn commit: r930105 - in /qpid/trunk/qpid/python/qpid: messaging/driver.py
messaging/endpoints.py messaging/util.py tests/messaging/endpoints.py
Author: rhs
Date: Thu Apr 1 21:36:56 2010
New Revision: 930105
URL: http://svn.apache.org/viewvc?rev=930105&view=rev
Log:
added option to disable reconnect logging; fixed reconnect test to not loop forever if no broker is running; backups -> reconnect_hosts
Modified:
qpid/trunk/qpid/python/qpid/messaging/driver.py
qpid/trunk/qpid/python/qpid/messaging/endpoints.py
qpid/trunk/qpid/python/qpid/messaging/util.py
qpid/trunk/qpid/python/qpid/tests/messaging/endpoints.py
Modified: qpid/trunk/qpid/python/qpid/messaging/driver.py
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/python/qpid/messaging/driver.py?rev=930105&r1=930104&r2=930105&view=diff
==============================================================================
--- qpid/trunk/qpid/python/qpid/messaging/driver.py (original)
+++ qpid/trunk/qpid/python/qpid/messaging/driver.py Thu Apr 1 21:36:56 2010
@@ -325,7 +325,8 @@ class Driver:
self._attempts = 0
self._delay = self.connection.reconnect_interval_min
self._hosts = [(self.connection.host, self.connection.port)] + \
- self.connection.backups
+ self.connection.reconnect_hosts
+ self._reconnect_log = self.connection.options.get("reconnect_log", True)
self._host = 0
self._retrying = False
self._transport = None
@@ -395,9 +396,10 @@ class Driver:
self._delay = min(2*self._delay,
self.connection.reconnect_interval_max)
self._timeout = time.time() + delay
- log.warn("recoverable error[attempt %s]: %s" % (self._attempts, e))
- if delay > 0:
- log.warn("sleeping %s seconds" % delay)
+ if self._reconnect_log:
+ log.warn("recoverable error[attempt %s]: %s" % (self._attempts, e))
+ if delay > 0:
+ log.warn("sleeping %s seconds" % delay)
self._retrying = True
self.engine.close()
else:
@@ -456,7 +458,7 @@ class Driver:
if self._host == 0:
self._attempts += 1
host, port = self._hosts[self._host]
- if self._retrying:
+ if self._retrying and self._reconnect_log:
log.warn("trying: %s:%s", host, port)
self.engine = Engine(self.connection)
self.engine.open()
@@ -466,7 +468,7 @@ class Driver:
self._transport = trans(host, port)
else:
raise ConnectError("no such transport: %s" % self.connection.transport)
- if self._retrying:
+ if self._retrying and self._reconnect_log:
log.warn("reconnect succeeded: %s:%s", host, port)
self._timeout = None
self._attempts = 0
Modified: qpid/trunk/qpid/python/qpid/messaging/endpoints.py
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/python/qpid/messaging/endpoints.py?rev=930105&r1=930104&r2=930105&view=diff
==============================================================================
--- qpid/trunk/qpid/python/qpid/messaging/endpoints.py (original)
+++ qpid/trunk/qpid/python/qpid/messaging/endpoints.py Thu Apr 1 21:36:56 2010
@@ -94,8 +94,8 @@ class Connection:
else:
self.reconnect_interval_max = options.get("reconnect_interval", 2*60)
self.reconnect_limit = options.get("reconnect_limit")
+ self.reconnect_hosts = options.get("reconnect_hosts", [])
self.transport = options.get("transport", "plain")
- self.backups = options.get("backups", [])
self.options = options
if self.transport == "tls":
Modified: qpid/trunk/qpid/python/qpid/messaging/util.py
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/python/qpid/messaging/util.py?rev=930105&r1=930104&r2=930105&view=diff
==============================================================================
--- qpid/trunk/qpid/python/qpid/messaging/util.py (original)
+++ qpid/trunk/qpid/python/qpid/messaging/util.py Thu Apr 1 21:36:56 2010
@@ -26,31 +26,31 @@ from threading import Thread
log = getLogger("qpid.messaging.util")
-def auto_update_backups(conn):
- ssn = conn.session("auto-update-backups")
+def auto_fetch_reconnect_hosts(conn):
+ ssn = conn.session("auto-fetch-reconnect-hosts")
rcv = ssn.receiver("amq.failover")
rcv.capacity = 10
def main():
while True:
msg = rcv.fetch()
- update_backups(conn, msg)
+ set_reconnect_hosts(conn, msg)
ssn.acknowledge(msg, sync=False)
- thread = Thread(name="auto-update-backups", target=main)
+ thread = Thread(name="auto-fetch-reconnect-hosts", target=main)
thread.setDaemon(True)
thread.start()
-def update_backups(conn, msg):
- backups = []
+def set_reconnect_hosts(conn, msg):
+ reconnect_hosts = []
urls = msg.properties["amq.failover"]
for u in urls:
if u.startswith("amqp:tcp:"):
parts = u.split(":")
host, port = parts[2:4]
- backups.append((host, port))
- conn.backups = backups
- log.warn("updated backups for conn %s: %s", conn, backups)
+ reconnect_hosts.append((host, port))
+ conn.reconnect_hosts = reconnect_hosts
+ log.warn("set reconnect_hosts for conn %s: %s", conn, reconnect_hosts)
-__all__ = ["auto_update_backups", "update_backups"]
+__all__ = ["auto_fetch_reconnect_hosts", "set_reconnect_hosts"]
Modified: qpid/trunk/qpid/python/qpid/tests/messaging/endpoints.py
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/python/qpid/tests/messaging/endpoints.py?rev=930105&r1=930104&r2=930105&view=diff
==============================================================================
--- qpid/trunk/qpid/python/qpid/tests/messaging/endpoints.py (original)
+++ qpid/trunk/qpid/python/qpid/tests/messaging/endpoints.py Thu Apr 1 21:36:56 2010
@@ -116,6 +116,8 @@ class SetupTests(Base):
options["reconnect"] = True
options["reconnect_interval"] = 0
+ options["reconnect_limit"] = 100
+ options["reconnect_log"] = False
options["transport"] = "flaky"
self.conn = Connection.open(self.broker.host, self.broker.port, **options)
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org