activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rajdav...@apache.org
Subject svn commit: r636425 - /activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java
Date Wed, 12 Mar 2008 17:10:30 GMT
Author: rajdavies
Date: Wed Mar 12 10:10:17 2008
New Revision: 636425

URL: http://svn.apache.org/viewvc?rev=636425&view=rev
Log:
use a separate mutex for building backups

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

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java?rev=636425&r1=636424&r2=636425&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java
Wed Mar 12 10:10:17 2008
@@ -68,6 +68,7 @@
     private final CopyOnWriteArrayList<URI> uris = new CopyOnWriteArrayList<URI>();
 
     private final Object reconnectMutex = new Object();
+    private final Object backupMutex = new Object();
     private final Object sleepMutex = new Object();
     private final ConnectionStateTracker stateTracker = new ConnectionStateTracker();
     private final ConcurrentHashMap<Integer, Command> requestMap = new ConcurrentHashMap<Integer,
Command>();
@@ -633,26 +634,28 @@
                     if (!useExponentialBackOff) {
                         reconnectDelay = initialReconnectDelay;
                     }
-                    if (backup && !backups.isEmpty()) {
-                    	BackupTransport bt = backups.remove(0);
-                        Transport t = bt.getTransport();
-                        URI uri = bt.getUri();
-                        t.setTransportListener(myTransportListener);
-                        try {
-                            if (started) { 
-                                    restoreTransport(t);  
-                            }
-                            reconnectDelay = initialReconnectDelay;
-                            failedConnectTransportURI=null;
-                            connectedTransportURI = uri;
-                            connectedTransport.set(t);
-                            reconnectMutex.notifyAll();
-                            connectFailures = 0;
-                            LOG.info("Successfully reconnected to backup " + uri);
-                            return false;
-                        }catch (Exception e) {
-                            LOG.debug("Backup transport failed",e);
-                         }
+                    synchronized(backupMutex) {
+                        if (backup && !backups.isEmpty()) {
+                        	BackupTransport bt = backups.remove(0);
+                            Transport t = bt.getTransport();
+                            URI uri = bt.getUri();
+                            t.setTransportListener(myTransportListener);
+                            try {
+                                if (started) { 
+                                        restoreTransport(t);  
+                                }
+                                reconnectDelay = initialReconnectDelay;
+                                failedConnectTransportURI=null;
+                                connectedTransportURI = uri;
+                                connectedTransport.set(t);
+                                reconnectMutex.notifyAll();
+                                connectFailures = 0;
+                                LOG.info("Successfully reconnected to backup " + uri);
+                                return false;
+                            }catch (Exception e) {
+                                LOG.debug("Backup transport failed",e);
+                             }
+                        }
                     }
                     
                     Iterator<URI> iter = connectList.iterator();
@@ -742,7 +745,7 @@
 
    
    final boolean buildBackups() {
-	   synchronized (reconnectMutex) {
+	   synchronized (backupMutex) {
 		   if (!disposed && backup && backups.size() < backupPoolSize) {
 			   List<URI> connectList = getConnectList();
 			   //removed disposed backups



Mime
View raw message