activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rajdav...@apache.org
Subject svn commit: r379397 - /incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java
Date Tue, 21 Feb 2006 09:14:10 GMT
Author: rajdavies
Date: Tue Feb 21 01:14:07 2006
New Revision: 379397

URL: http://svn.apache.org/viewcvs?rev=379397&view=rev
Log:
fixed exponentialBackoff

Modified:
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java?rev=379397&r1=379396&r2=379397&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java
Tue Feb 21 01:14:07 2006
@@ -59,6 +59,7 @@
     private final CopyOnWriteArrayList uris = new CopyOnWriteArrayList();
 
     private final Object reconnectMutex = new Object();
+    private final Object sleepMutex = new Object();
     private final ConnectionStateTracker stateTracker = new ConnectionStateTracker();
     private final ConcurrentHashMap requestMap = new ConcurrentHashMap();
 
@@ -136,7 +137,9 @@
                         if( connectList.isEmpty() ) {
                             failure = new IOException("No uris available to connect to.");
                         } else {
-                            reconnectDelay = initialReconnectDelay;
+                            if (!useExponentialBackOff){
+                                reconnectDelay = initialReconnectDelay;
+                            }
                             Iterator iter = connectList.iterator();
                             for (int i = 0; iter.hasNext() && connectedTransport
== null && !disposed; i++) {
                                 URI uri = (URI) iter.next();
@@ -175,12 +178,17 @@
                 }
 
                 if(!disposed){
-                    try{
+                    
                         log.debug("Waiting "+reconnectDelay+" ms before attempting connection.
");
-                        Thread.sleep(reconnectDelay);
-                    }catch(InterruptedException e1){
-                        Thread.currentThread().interrupt();
-                    }
+                        synchronized(sleepMutex){
+                            try{
+                                sleepMutex.wait(reconnectDelay);
+                            }catch(InterruptedException e){
+                               Thread.currentThread().interrupt();
+                            }
+                        }
+                        
+                    
                     if(useExponentialBackOff){
                         // Exponential increment of reconnect delay.
                         reconnectDelay*=backOffMultiplier;
@@ -234,6 +242,10 @@
             if (connectedTransport != null) {
                 connectedTransport.stop();
             }
+            reconnectMutex.notifyAll();
+        }
+        synchronized(sleepMutex){
+            sleepMutex.notifyAll();
         }
     }
 



Mime
View raw message