[jboss-cvs] JBoss Messaging SVN: r5463 - in trunk: src/main/org/jboss/messaging/core/remoting and 7 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Dec 5 09:15:43 EST 2008


Author: timfox
Date: 2008-12-05 09:15:42 -0500 (Fri, 05 Dec 2008)
New Revision: 5463

Added:
   trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/FailureListenerOnFailoverTest.java
   trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/FailureOnCreateConnectionTest.java
Modified:
   trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionFactoryImpl.java
   trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionImpl.java
   trunk/src/main/org/jboss/messaging/core/client/impl/ConnectionManagerImpl.java
   trunk/src/main/org/jboss/messaging/core/remoting/FailureListener.java
   trunk/src/main/org/jboss/messaging/core/remoting/RemotingConnection.java
   trunk/src/main/org/jboss/messaging/core/remoting/impl/RemotingConnectionImpl.java
   trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMConnector.java
   trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionImpl.java
   trunk/src/main/org/jboss/messaging/jms/client/JBossConnection.java
   trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/ReconnectTest.java
   trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/ReconnectWithBackupTest.java
   trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/SimpleAutomaticFailoverTest.java
   trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/SimpleManualFailoverTest.java
   trunk/tests/src/org/jboss/messaging/tests/integration/jms/cluster/JMSFailoverTest.java
   trunk/tests/src/org/jboss/messaging/tests/integration/remoting/PingTest.java
Log:
More reconnection stuff.


Modified: trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionFactoryImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionFactoryImpl.java	2008-12-04 15:39:04 UTC (rev 5462)
+++ trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionFactoryImpl.java	2008-12-05 14:15:42 UTC (rev 5463)
@@ -550,7 +550,7 @@
    */
    public ClientSessionFactoryImpl(final TransportConfiguration connectorConfig)
    {
-      this(connectorConfig, null);
+      this(connectorConfig, null, 0, 0, 0, 0);
    }
 
    // ClientSessionFactory implementation------------------------------------------------------------

Modified: trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionImpl.java	2008-12-04 15:39:04 UTC (rev 5462)
+++ trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionImpl.java	2008-12-05 14:15:42 UTC (rev 5463)
@@ -719,8 +719,6 @@
             // closed on the server so we need to interrupt it
             channel.returnBlocking();
          }
-
-         //backupConnection = null;
       }
       catch (Throwable t)
       {
@@ -732,9 +730,6 @@
       }
 
       channel.send(new SessionFailoverCompleteMessage(name));
-
-      // Now we can add a failure listener since if a further failure occurs we cleanup since no backup any more
-      //remotingConnection.addFailureListener(this);
    }
 
    // XAResource implementation
@@ -1007,7 +1002,7 @@
 
    // FailureListener implementation --------------------------------------------
 
-   public void connectionFailed(final MessagingException me)
+   public boolean connectionFailed(final MessagingException me)
    {
       try
       {
@@ -1017,6 +1012,8 @@
       {
          log.error("Failed to cleanup session");
       }
+      
+      return true;
    }
 
    // Public
@@ -1032,16 +1029,6 @@
       return remotingConnection;
    }
 
-//   public RemotingConnection getBackupConnection()
-//   {
-//      return backupConnection;
-//   }
-//
-//   public void setBackupConnection(RemotingConnection connection)
-//   {
-//      this.backupConnection = connection;
-//   }
-
    // Protected
    // ----------------------------------------------------------------------------
 

Modified: trunk/src/main/org/jboss/messaging/core/client/impl/ConnectionManagerImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/client/impl/ConnectionManagerImpl.java	2008-12-04 15:39:04 UTC (rev 5462)
+++ trunk/src/main/org/jboss/messaging/core/client/impl/ConnectionManagerImpl.java	2008-12-05 14:15:42 UTC (rev 5463)
@@ -89,11 +89,11 @@
    private Map<String, Object> backupTransportParams;
 
    private final int maxConnections;
-   
+
    private final long callTimeout;
-   
+
    private final long pingPeriod;
-   
+
    private final long connectionTTL;
 
    private final Map<ClientSessionInternal, RemotingConnection> sessions = new HashMap<ClientSessionInternal, RemotingConnection>();
@@ -117,13 +117,13 @@
    private Iterator<ConnectionEntry> mapIterator;
 
    private Object failConnectionLock = new Object();
-   
+
    private final long retryInterval;
 
    private final double retryIntervalMultiplier; // For exponential backoff
-      
+
    private final int maxRetriesBeforeFailover;
-   
+
    private final int maxRetriesAfterFailover;
 
    // Static
@@ -136,10 +136,10 @@
                                 final TransportConfiguration backupConfig,
                                 final int maxConnections,
                                 final long callTimeout,
-                                final long pingPeriod,             
+                                final long pingPeriod,
                                 final long connectionTTL,
                                 final long retryInterval,
-                                final double retryIntervalMultiplier,                                
+                                final double retryIntervalMultiplier,
                                 final int maxRetriesBeforeFailover,
                                 final int maxRetriesAfterFailover)
    {
@@ -159,21 +159,21 @@
 
          backupTransportParams = null;
       }
-      
+
       this.maxConnections = maxConnections;
-      
+
       this.callTimeout = callTimeout;
-      
+
       this.pingPeriod = pingPeriod;
-      
+
       this.connectionTTL = connectionTTL;
-      
+
       this.retryInterval = retryInterval;
-      
+
       this.retryIntervalMultiplier = retryIntervalMultiplier;
-                 
+
       this.maxRetriesBeforeFailover = maxRetriesBeforeFailover;
-      
+
       this.maxRetriesAfterFailover = maxRetriesAfterFailover;
    }
 
@@ -202,9 +202,9 @@
    {
       failConnection(me);
    }
+
+   // ConnectionManager implementation ------------------------------------------------------------------
    
-   // ConnectionManager implementation ------------------------------------------------------------------
-
    public ClientSession createSession(final String username,
                                       final String password,
                                       final boolean xa,
@@ -216,10 +216,10 @@
                                       final boolean blockOnAcknowledge,
                                       final boolean autoGroup,
                                       final int sendWindowSize,
-                                      final int consumerWindowSize,                            
-                                      final int consumerMaxRate,                            
-                                      final int producerMaxRate,                            
-                                      final boolean blockOnNonPersistentSend,                            
+                                      final int consumerWindowSize,
+                                      final int consumerMaxRate,
+                                      final int producerMaxRate,
+                                      final boolean blockOnNonPersistentSend,
                                       final boolean blockOnPersistentSend) throws MessagingException
    {
       synchronized (createSessionLock)
@@ -241,7 +241,7 @@
 
                synchronized (failoverLock)
                {
-                  connection = getConnection(1);
+                  connection = getConnectionForCreateSession();
 
                   channel1 = connection.getChannel(1, -1, false);
 
@@ -299,11 +299,11 @@
                                                                         blockOnAcknowledge,
                                                                         autoGroup,
                                                                         ackBatchSize,
-                                                                        consumerWindowSize,                            
-                                                                        consumerMaxRate,                            
-                                                                        producerMaxRate,                            
-                                                                        blockOnNonPersistentSend,                            
-                                                                        blockOnPersistentSend,                            
+                                                                        consumerWindowSize,
+                                                                        consumerMaxRate,
+                                                                        producerMaxRate,
+                                                                        blockOnNonPersistentSend,
+                                                                        blockOnPersistentSend,
                                                                         minLargeMessageSize,
                                                                         connection,
                                                                         response.getServerVersion(),
@@ -395,17 +395,58 @@
 
    // FailureListener implementation --------------------------------------------------------
 
-   public void connectionFailed(final MessagingException me)
-   {      
+   public boolean connectionFailed(final MessagingException me)
+   {
       if (me.getCode() == MessagingException.OBJECT_CLOSED)
       {
          // The server has closed the connection. We don't want failover to occur in this case -
          // either the server has booted off the connection, or it didn't receive a ping in time
          // in either case server side resources on both live and backup will be removed so the client
          // can't failover anyway
-         return;
+         return true;
       }
 
+      return !failover();
+   }
+
+   // Public
+   // ---------------------------------------------------------------------------------------
+
+   // Protected
+   // ------------------------------------------------------------------------------------
+
+   // Package Private
+   // ------------------------------------------------------------------------------
+
+   // Private
+   // --------------------------------------------------------------------------------------
+
+   private RemotingConnection getConnectionForCreateSession() throws MessagingException
+   {
+      while (true)
+      {
+         RemotingConnection connection = getConnection(1);
+   
+         if (connection == null)
+         {
+            // Connection is dead - failover/reconnect
+            boolean failedOver = failover();
+            
+            if (!failedOver)
+            {
+               //Nothing we can do here
+               throw new MessagingException(MessagingException.NOT_CONNECTED, "Unabled to create session - server is unavailable and no backup server or backup is unavailable");
+            }
+         }
+         else
+         {
+            return connection;
+         }
+      }
+   }
+   
+   private boolean failover()
+   {
       synchronized (failoverLock)
       {
          // Now get locks on all channel 1s, whilst holding the failoverLock - this makes sure
@@ -436,7 +477,7 @@
          if (backupConnectorFactory != null || maxRetriesBeforeFailover != 0 || maxRetriesAfterFailover != 0)
          {
             log.info("Commencing automatic failover / reconnection");
-            
+
             lockAllChannel1s();
 
             final boolean needToInterrupt;
@@ -471,56 +512,56 @@
                   }
                }
             }
-            
+
             // Now we absolutely know that no threads are executing in or blocked in createSession, and no
             // more will execute it until failover is complete
 
             // So.. do failover / reconnection
-            
+
             Set<RemotingConnection> oldConnections = new HashSet<RemotingConnection>();
 
             for (ConnectionEntry entry : connections.values())
             {
                oldConnections.add(entry.connection);
             }
-            
+
             connections.clear();
 
             refCount = 0;
 
             mapIterator = null;
-            
+
             boolean done = false;
-                       
+
             if (maxRetriesBeforeFailover != 0)
             {
-               //First try reconnecting to current node if configured to do this
-               
+               // First try reconnecting to current node if configured to do this
+
                done = reconnect(maxRetriesBeforeFailover);
-               
+
                if (done)
                {
                   log.info("reconnected to original node");
                }
             }
-            
+
             if (!done)
             {
-               //If didn't reconnect to current node then try failover to backup
-               
+               // If didn't reconnect to current node then try failover to backup
+
                int retries = maxRetriesAfterFailover;
-               
+
                if (backupConnectorFactory != null)
                {
                   connectorFactory = backupConnectorFactory;
-      
+
                   transportParams = backupTransportParams;
-                  
+
                   if (maxRetriesAfterFailover == 0)
                   {
                      retries = 1;
                   }
-                  
+
                   log.info("Failing over to backup");
                }
                else
@@ -531,25 +572,37 @@
                backupConnectorFactory = null;
 
                backupTransportParams = null;
-               
-               done = reconnect(retries);           
-               
+
+               done = reconnect(retries);
+
                if (done)
                {
                   log.info("Successfully reconnected");
                }
+               else
+               {
+                  log.info("Unable to failover/reconnect");
+               }
             }
 
             for (RemotingConnection connection : oldConnections)
             {
                connection.destroy();
-            }            
+            }
+
+            log.info("done is " + done);
+
+            return done;
          }
+         else
+         {
+            return false;
+         }
       }
    }
 
    private boolean reconnect(final int retries)
-   {     
+   {
       // We fail over sessions per connection to ensure there is the same mapping of channel id
       // on live and backup connections
 
@@ -560,7 +613,7 @@
          ClientSessionInternal session = entry.getKey();
 
          RemotingConnection connection = entry.getValue();
-         
+
          List<ClientSessionInternal> sessions = sessionsPerConnection.get(connection);
 
          if (sessions == null)
@@ -574,78 +627,96 @@
       }
 
       boolean ok = true;
-      
+
       for (Map.Entry<RemotingConnection, List<ClientSessionInternal>> entry : sessionsPerConnection.entrySet())
       {
          List<ClientSessionInternal> theSessions = entry.getValue();
-         
+
          RemotingConnection backupConnection = getConnectionWithRetry(theSessions, retries);
-                  
+
          if (backupConnection == null)
          {
             log.warn("Failed to reconnect to server.");
-            
+
             ok = false;
-            
+
             break;
          }
-         
-         backupConnection.addFailureListener(this);
-                  
+
+         List<FailureListener> oldListeners = entry.getKey().getFailureListeners();
+
+         List<FailureListener> newListeners = new ArrayList<FailureListener>(oldListeners.size());
+
+         newListeners.add(this);
+
+         for (int i = 0; i < oldListeners.size(); i++)
+         {
+            // Add all apart from the first one which is the old connectionmanager
+
+            FailureListener listener = oldListeners.get(i);
+
+            if (listener instanceof ConnectionManagerImpl == false)
+            {
+               newListeners.add(oldListeners.get(i));
+            }
+         }
+
+         backupConnection.setFailureListeners(newListeners);
+
          for (ClientSessionInternal session : theSessions)
          {
             sessions.put(session, backupConnection);
          }
       }
-      
+
       if (ok)
       {
-         //If all connections got ok, then handle failover
-         for (Map.Entry<ClientSessionInternal, RemotingConnection> entry: sessions.entrySet())
+         // If all connections got ok, then handle failover
+         for (Map.Entry<ClientSessionInternal, RemotingConnection> entry : sessions.entrySet())
          {
             entry.getKey().handleFailover(entry.getValue());
          }
       }
-  
+
       return ok;
    }
-   
+
    private RemotingConnection getConnectionWithRetry(final List<ClientSessionInternal> sessions, final int retries)
    {
       long interval = retryInterval;
-      
+
       int count = 0;
-      
+
       while (true)
-      {                        
+      {
          RemotingConnection connection = getConnection(sessions.size());
-               
+
          if (connection == null)
          {
-            //Failed to get backup connection
-            
+            // Failed to get backup connection
+
             if (retries != 0)
             {
                if (retries != -1 && count == retries)
                {
                   log.warn("Retried " + retries + " times to reconnect. Now giving up.");
-                  
-                  return null;                  
+
+                  return null;
                }
-               
+
                count++;
-               
+
                log.warn("Now waiting " + interval + " ms before attempting reconnection.");
-               
+
                try
                {
                   Thread.sleep(interval);
                }
                catch (InterruptedException ignore)
-               {                  
+               {
                }
-               
-               //Exponential back-off
+
+               // Exponential back-off
                interval *= retryIntervalMultiplier;
             }
             else
@@ -659,19 +730,7 @@
          }
       }
    }
-      
-   // Public
-   // ---------------------------------------------------------------------------------------
-
-   // Protected
-   // ------------------------------------------------------------------------------------
-
-   // Package Private
-   // ------------------------------------------------------------------------------
-
-   // Private
-   // --------------------------------------------------------------------------------------
-
+   
    private void checkCloseConnections()
    {
       if (refCount == 0)
@@ -711,7 +770,20 @@
 
          connector.start();
 
-         Connection tc = connector.createConnection();
+         Connection tc;
+         
+         try
+         {
+            tc = connector.createConnection();
+         }
+         catch (Exception e)
+         {
+            //Sanity catch for badly behaved remoting plugins
+            
+            log.warn("connector.create should never throw an exception, implementation is badly behaved");
+            
+            tc = null;
+         }
 
          if (tc == null)
          {

Modified: trunk/src/main/org/jboss/messaging/core/remoting/FailureListener.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/FailureListener.java	2008-12-04 15:39:04 UTC (rev 5462)
+++ trunk/src/main/org/jboss/messaging/core/remoting/FailureListener.java	2008-12-05 14:15:42 UTC (rev 5463)
@@ -34,5 +34,5 @@
  */
 public interface FailureListener
 {
-   void connectionFailed(MessagingException me);
+   boolean connectionFailed(MessagingException me);
 }

Modified: trunk/src/main/org/jboss/messaging/core/remoting/RemotingConnection.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/RemotingConnection.java	2008-12-04 15:39:04 UTC (rev 5462)
+++ trunk/src/main/org/jboss/messaging/core/remoting/RemotingConnection.java	2008-12-05 14:15:42 UTC (rev 5463)
@@ -12,6 +12,8 @@
 
 package org.jboss.messaging.core.remoting;
 
+import java.util.List;
+
 import org.jboss.messaging.core.exception.MessagingException;
 import org.jboss.messaging.core.remoting.spi.BufferHandler;
 import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
@@ -35,6 +37,10 @@
    void addFailureListener(FailureListener listener);
 
    boolean removeFailureListener(FailureListener listener);
+   
+   List<FailureListener> getFailureListeners();
+   
+   void setFailureListeners(List<FailureListener> listeners);
 
    MessagingBuffer createBuffer(int size);
 

Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/RemotingConnectionImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/RemotingConnectionImpl.java	2008-12-04 15:39:04 UTC (rev 5462)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/RemotingConnectionImpl.java	2008-12-05 14:15:42 UTC (rev 5463)
@@ -64,11 +64,10 @@
 import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.SESS_XA_START;
 import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.SESS_XA_SUSPEND;
 
-import java.util.HashSet;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 import java.util.Queue;
-import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentLinkedQueue;
 import java.util.concurrent.CopyOnWriteArrayList;
@@ -354,6 +353,18 @@
    // RemotingConnection implementation
    // ------------------------------------------------------------
 
+   public List<FailureListener> getFailureListeners()
+   {
+      return new ArrayList<FailureListener>(failureListeners);
+   }
+   
+   public void setFailureListeners(final List<FailureListener> listeners)
+   {
+      this.failureListeners.clear();
+      
+      this.failureListeners.addAll(listeners);
+   }
+   
    public Object getID()
    {
       return transportConnection.getID();
@@ -379,7 +390,7 @@
    }
 
    public void addFailureListener(final FailureListener listener)
-   {
+   {   
       if (listener == null)
       {
          throw new IllegalStateException("FailureListener cannot be null");
@@ -535,13 +546,18 @@
 
    private void callListeners(final MessagingException me)
    {
-      final Set<FailureListener> listenersClone = new HashSet<FailureListener>(failureListeners);
+      final List<FailureListener> listenersClone = new ArrayList<FailureListener>(failureListeners);
 
       for (final FailureListener listener : listenersClone)
       {
          try
          {
-            listener.connectionFailed(me);
+            boolean callNext = listener.connectionFailed(me);
+            
+            if (!callNext)
+            {
+               break;
+            }
          }
          catch (final Throwable t)
          {
@@ -1605,7 +1621,7 @@
 
    private class ReplicatingConnectionFailureListener implements FailureListener
    {
-      public void connectionFailed(final MessagingException me)
+      public boolean connectionFailed(final MessagingException me)
       {
          synchronized (RemotingConnectionImpl.this)
          {
@@ -1614,6 +1630,8 @@
                channel.replicatingChannelDead();
             }
          }
+         
+         return true;
       }
    }
 }

Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMConnector.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMConnector.java	2008-12-04 15:39:04 UTC (rev 5462)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMConnector.java	2008-12-05 14:15:42 UTC (rev 5463)
@@ -45,6 +45,22 @@
    
    //Used for testing failure only
    public static volatile boolean failOnCreateConnection;
+   public static volatile int numberOfFailures = -1;
+   private static volatile int failures;
+   public static synchronized void resetFailures()
+   {
+      failures = 0;
+      failOnCreateConnection = false;
+      numberOfFailures = -1;
+   }
+   private static synchronized void incFailures()
+   {
+      failures++;
+      if (failures == numberOfFailures)
+      {
+         resetFailures();
+      }
+   }
 
    private final int id;
    
@@ -99,6 +115,7 @@
    {
       if (failOnCreateConnection)
       {
+         incFailures();
          //For testing only
          return null;
       }

Modified: trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionImpl.java	2008-12-04 15:39:04 UTC (rev 5462)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionImpl.java	2008-12-05 14:15:42 UTC (rev 5463)
@@ -2407,7 +2407,7 @@
    // FailureListener implementation
    // --------------------------------------------------------------------
 
-   public void connectionFailed(final MessagingException me)
+   public boolean connectionFailed(final MessagingException me)
    {
       try
       {
@@ -2434,6 +2434,8 @@
       {
          log.error("Failed to close connection " + this);
       }
+      
+      return true;
    }
 
    // Public

Modified: trunk/src/main/org/jboss/messaging/jms/client/JBossConnection.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/client/JBossConnection.java	2008-12-04 15:39:04 UTC (rev 5462)
+++ trunk/src/main/org/jboss/messaging/jms/client/JBossConnection.java	2008-12-05 14:15:42 UTC (rev 5463)
@@ -515,11 +515,11 @@
 
    private class JMSFailureListener implements FailureListener
    {
-      public void connectionFailed(final MessagingException me)
+      public boolean connectionFailed(final MessagingException me)
       {
          if (me == null)
          {
-            return;
+            return true;
          }
 
          if (exceptionListener != null)
@@ -530,6 +530,8 @@
 
             exceptionListener.onException(je);
          }
+         
+         return true;
       }
 
    }

Added: trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/FailureListenerOnFailoverTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/FailureListenerOnFailoverTest.java	                        (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/FailureListenerOnFailoverTest.java	2008-12-05 14:15:42 UTC (rev 5463)
@@ -0,0 +1,380 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2005-2008, Red Hat
+ * Middleware LLC, and individual contributors by the @authors tag. See the
+ * copyright.txt in the distribution for a full listing of individual
+ * contributors.
+ * 
+ * This is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This software is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this software; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
+ * site: http://www.fsf.org.
+ */
+
+package org.jboss.messaging.tests.integration.cluster.failover;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.jboss.messaging.core.client.ClientSession;
+import org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl;
+import org.jboss.messaging.core.client.impl.ClientSessionFactoryInternal;
+import org.jboss.messaging.core.client.impl.ClientSessionImpl;
+import org.jboss.messaging.core.config.Configuration;
+import org.jboss.messaging.core.config.TransportConfiguration;
+import org.jboss.messaging.core.config.impl.ConfigurationImpl;
+import org.jboss.messaging.core.exception.MessagingException;
+import org.jboss.messaging.core.logging.Logger;
+import org.jboss.messaging.core.remoting.FailureListener;
+import org.jboss.messaging.core.remoting.RemotingConnection;
+import org.jboss.messaging.core.remoting.impl.invm.InVMConnector;
+import org.jboss.messaging.core.remoting.impl.invm.InVMRegistry;
+import org.jboss.messaging.core.remoting.impl.invm.TransportConstants;
+import org.jboss.messaging.core.server.MessagingService;
+import org.jboss.messaging.core.server.impl.MessagingServiceImpl;
+import org.jboss.messaging.util.SimpleString;
+
+/**
+ * 
+ * A FailureListenerOnFailoverTest
+ * 
+ * Make sure FailuerListener is called at the right places during the failover process
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * 
+ * Created 4 Nov 2008 16:54:50
+ *
+ *
+ */
+public class FailureListenerOnFailoverTest extends TestCase
+{
+   private static final Logger log = Logger.getLogger(FailureListenerOnFailoverTest.class);
+
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   private static final SimpleString ADDRESS = new SimpleString("FailoverTestAddress");
+
+   private MessagingService liveService;
+
+   private MessagingService backupService;
+
+   private final Map<String, Object> backupParams = new HashMap<String, Object>();
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   // Public --------------------------------------------------------
+
+   /*
+    * Listener shouldn't be called if failed over successfully
+    */
+   public void testFailureListenerNotCalledOnFailover() throws Exception
+   {
+      ClientSessionFactoryInternal sf = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"),
+                                                                     new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory",
+                                                                                                backupParams));
+
+      ClientSession session = sf.createSession(false, true, true);
+
+      RemotingConnection conn = ((ClientSessionImpl)session).getConnection();
+      
+      class MyListener implements FailureListener
+      {
+         volatile boolean listenerCalled;
+         
+         public boolean connectionFailed(final MessagingException me)
+         {
+            log.info("** calling my failure listener");
+            listenerCalled = true;
+            
+            return true;
+         }
+      }
+      
+      MyListener listener = new MyListener();
+
+      session.addFailureListener(listener);
+      
+      conn.fail(new MessagingException(MessagingException.NOT_CONNECTED));
+            
+      assertFalse(listener.listenerCalled);
+
+      session.close();
+
+      sf.close();
+   }
+   
+   /*
+    * Listener should be called if no backup server or reconnect
+    */
+   public void testFailureListenerCalledNoFailover() throws Exception
+   {
+      ClientSessionFactoryInternal sf = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"));
+
+      ClientSession session = sf.createSession(false, true, true);
+
+      RemotingConnection conn = ((ClientSessionImpl)session).getConnection();
+      
+      class MyListener implements FailureListener
+      {
+         volatile boolean listenerCalled;
+         
+         public boolean connectionFailed(final MessagingException me)
+         {
+            log.info("** calling my failure listener");
+            listenerCalled = true;
+            
+            return true;
+         }
+      }
+      
+      MyListener listener = new MyListener();
+
+      session.addFailureListener(listener);
+      
+      conn.fail(new MessagingException(MessagingException.NOT_CONNECTED));
+            
+      assertTrue(listener.listenerCalled);
+
+      session.close();
+
+      sf.close();
+   }
+   
+   /*
+    * Listener should be called if failed to connect before failover
+    */
+   public void testFailureListenerCalledOnFailureToReconnectBeforeFailover() throws Exception
+   {
+      final long retryInterval = 250;
+
+      final double retryMultiplier = 1d;
+
+      final int maxRetriesBeforeFailover = 1;
+
+      final int maxRetriesAfterFailover = 0;
+      
+      ClientSessionFactoryInternal sf = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"),
+                                                                     new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory",
+                                                                                                backupParams),
+                                                                                                retryInterval,
+                                                                                                retryMultiplier,
+                                                                                                maxRetriesBeforeFailover,
+                                                                                                maxRetriesAfterFailover);
+
+      ClientSession session = sf.createSession(false, true, true);
+
+      RemotingConnection conn = ((ClientSessionImpl)session).getConnection();
+      
+      class MyListener implements FailureListener
+      {
+         volatile boolean listenerCalled;
+         
+         public boolean connectionFailed(final MessagingException me)
+         {
+            listenerCalled = true;
+            
+            return true;
+         }
+      }
+      
+      MyListener listener = new MyListener();
+
+      session.addFailureListener(listener);
+
+      InVMConnector.failOnCreateConnection = true;
+      
+      conn.fail(new MessagingException(MessagingException.NOT_CONNECTED));
+
+      Thread.sleep(retryInterval * 2);
+      
+      assertTrue(listener.listenerCalled);
+
+      session.close();
+
+      sf.close();
+   }
+   
+   /*
+    * Listener should be called if failed to connect after failover
+    */
+   public void testFailureListenerCalledOnFailureToReconnectAfterFailover() throws Exception
+   {
+      log.info("Starting 2nd test");
+      
+      final long retryInterval = 250;
+
+      final double retryMultiplier = 1d;
+
+      final int maxRetriesBeforeFailover = 0;
+
+      final int maxRetriesAfterFailover = 1;
+      
+      ClientSessionFactoryInternal sf = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"),
+                                                                     new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory",
+                                                                                                backupParams),
+                                                                                                retryInterval,
+                                                                                                retryMultiplier,
+                                                                                                maxRetriesBeforeFailover,
+                                                                                                maxRetriesAfterFailover);
+
+      ClientSession session = sf.createSession(false, true, true);
+
+      RemotingConnection conn = ((ClientSessionImpl)session).getConnection();
+      
+      class MyListener implements FailureListener
+      {
+         volatile boolean listenerCalled;
+         
+         public boolean connectionFailed(final MessagingException me)
+         {
+            listenerCalled = true;
+            
+            return true;
+         }
+      }
+      
+      MyListener listener = new MyListener();
+
+      session.addFailureListener(listener);
+
+      conn.fail(new MessagingException(MessagingException.NOT_CONNECTED));
+      
+      assertFalse(listener.listenerCalled);
+      
+      InVMConnector.failOnCreateConnection = true;
+           
+      log.info("Failing again");
+      
+      conn = ((ClientSessionImpl)session).getConnection();
+      
+      //Now fail again
+      conn.fail(new MessagingException(MessagingException.NOT_CONNECTED));
+
+      Thread.sleep(retryInterval * 2);
+      
+      assertTrue(listener.listenerCalled);
+
+      session.close();
+
+      sf.close();
+   }
+   
+   /*
+    * Listener should be called if failed to connect before failover
+    */
+   public void testFailureListenerCalledOnStraightFailureToReconnect() throws Exception
+   {
+      final long retryInterval = 250;
+
+      final double retryMultiplier = 1d;
+
+      final int maxRetriesBeforeFailover = 1;
+
+      final int maxRetriesAfterFailover = 0;
+      
+      ClientSessionFactoryInternal sf = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"),                                                                     
+                                                                                                retryInterval,
+                                                                                                retryMultiplier,
+                                                                                                maxRetriesBeforeFailover,
+                                                                                                maxRetriesAfterFailover);
+
+      ClientSession session = sf.createSession(false, true, true);
+
+      RemotingConnection conn = ((ClientSessionImpl)session).getConnection();
+      
+      class MyListener implements FailureListener
+      {
+         volatile boolean listenerCalled;
+         
+         public boolean connectionFailed(final MessagingException me)
+         {
+            listenerCalled = true;
+            
+            return true;
+         }
+      }
+      
+      MyListener listener = new MyListener();
+
+      session.addFailureListener(listener);
+
+      InVMConnector.failOnCreateConnection = true;
+      
+      conn.fail(new MessagingException(MessagingException.NOT_CONNECTED));
+
+      Thread.sleep(retryInterval * 2);
+      
+      assertTrue(listener.listenerCalled);
+
+      session.close();
+
+      sf.close();
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   @Override
+   protected void setUp() throws Exception
+   {
+      Configuration backupConf = new ConfigurationImpl();
+      backupConf.setSecurityEnabled(false);
+      backupParams.put(TransportConstants.SERVER_ID_PROP_NAME, 1);
+      backupConf.getAcceptorConfigurations()
+                .add(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMAcceptorFactory",
+                                                backupParams));
+      backupConf.setBackup(true);
+      backupService = MessagingServiceImpl.newNullStorageMessagingServer(backupConf);
+      backupService.start();
+
+      Configuration liveConf = new ConfigurationImpl();
+      liveConf.setSecurityEnabled(false);
+      liveConf.getAcceptorConfigurations()
+              .add(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMAcceptorFactory"));
+      Map<String, TransportConfiguration> connectors = new HashMap<String, TransportConfiguration>();
+      TransportConfiguration backupTC = new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory",
+                                                                   backupParams,
+                                                                   "backup-connector");
+      connectors.put(backupTC.getName(), backupTC);
+      liveConf.setConnectorConfigurations(connectors);
+      liveConf.setBackupConnectorName(backupTC.getName());
+      liveService = MessagingServiceImpl.newNullStorageMessagingServer(liveConf);
+      liveService.start();
+   }
+
+   @Override
+   protected void tearDown() throws Exception
+   {
+      InVMConnector.resetFailures();
+      
+      assertEquals(0, backupService.getServer().getRemotingService().getConnections().size());
+
+      backupService.stop();
+
+      assertEquals(0, liveService.getServer().getRemotingService().getConnections().size());
+
+      liveService.stop();
+
+      assertEquals(0, InVMRegistry.instance.size());
+   }
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}

Added: trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/FailureOnCreateConnectionTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/FailureOnCreateConnectionTest.java	                        (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/FailureOnCreateConnectionTest.java	2008-12-05 14:15:42 UTC (rev 5463)
@@ -0,0 +1,192 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2005-2008, Red Hat
+ * Middleware LLC, and individual contributors by the @authors tag. See the
+ * copyright.txt in the distribution for a full listing of individual
+ * contributors.
+ * 
+ * This is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This software is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this software; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
+ * site: http://www.fsf.org.
+ */
+
+package org.jboss.messaging.tests.integration.cluster.failover;
+
+import junit.framework.TestCase;
+
+import org.jboss.messaging.core.client.ClientConsumer;
+import org.jboss.messaging.core.client.ClientMessage;
+import org.jboss.messaging.core.client.ClientProducer;
+import org.jboss.messaging.core.client.ClientSession;
+import org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl;
+import org.jboss.messaging.core.client.impl.ClientSessionFactoryInternal;
+import org.jboss.messaging.core.client.impl.ClientSessionImpl;
+import org.jboss.messaging.core.config.Configuration;
+import org.jboss.messaging.core.config.TransportConfiguration;
+import org.jboss.messaging.core.config.impl.ConfigurationImpl;
+import org.jboss.messaging.core.exception.MessagingException;
+import org.jboss.messaging.core.logging.Logger;
+import org.jboss.messaging.core.remoting.RemotingConnection;
+import org.jboss.messaging.core.remoting.impl.invm.InVMConnector;
+import org.jboss.messaging.core.remoting.impl.invm.InVMRegistry;
+import org.jboss.messaging.core.server.MessagingService;
+import org.jboss.messaging.core.server.impl.MessagingServiceImpl;
+import org.jboss.messaging.jms.client.JBossTextMessage;
+import org.jboss.messaging.util.SimpleString;
+
+/**
+ * 
+ * A FailureOnCreateConnectionTest
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * 
+ * Created 4 Nov 2008 16:54:50
+ *
+ *
+ */
+public class FailureOnCreateConnectionTest extends TestCase
+{
+   private static final Logger log = Logger.getLogger(FailureOnCreateConnectionTest.class);
+
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   private static final SimpleString ADDRESS = new SimpleString("FailoverTestAddress");
+
+   private MessagingService service;
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   // Public --------------------------------------------------------
+
+   public void testFailureOnCreateConnectionReconnectSameServerOneFailure() throws Exception
+   {
+      testFailureOnCreateConnectionReconnectSameServer(1);
+   }
+   
+   public void testFailureOnCreateConnectionReconnectSameServerMultipleFailures() throws Exception
+   {
+      testFailureOnCreateConnectionReconnectSameServer(10);
+   }
+
+   
+   
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   @Override
+   protected void setUp() throws Exception
+   {
+      Configuration liveConf = new ConfigurationImpl();
+      liveConf.setSecurityEnabled(false);
+      liveConf.getAcceptorConfigurations()
+              .add(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMAcceptorFactory"));
+      service = MessagingServiceImpl.newNullStorageMessagingServer(liveConf);
+      service.start();
+   }
+
+   @Override
+   protected void tearDown() throws Exception
+   {
+      InVMConnector.resetFailures();
+      
+      assertEquals(0, service.getServer().getRemotingService().getConnections().size());
+
+      service.stop();
+
+      assertEquals(0, InVMRegistry.instance.size());
+   }
+
+   // Private -------------------------------------------------------
+   
+   private void testFailureOnCreateConnectionReconnectSameServer(final int numFailures) throws Exception
+   {
+      final long retryInterval = 500;
+
+      final double retryMultiplier = 1d;
+
+      final int maxRetriesBeforeFailover = -1;
+      
+      final int maxRetriesAfterFailover = 0;      
+
+      ClientSessionFactoryInternal sf = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"),
+                                                                     retryInterval,
+                                                                     retryMultiplier,
+                                                                     maxRetriesBeforeFailover,
+                                                                     maxRetriesAfterFailover);
+
+      InVMConnector.failOnCreateConnection = true;
+      //One failure only
+      InVMConnector.numberOfFailures = numFailures;
+      
+      ClientSession session = sf.createSession(false, true, true);
+
+      session.createQueue(ADDRESS, ADDRESS, null, false, false, true);
+
+      ClientProducer producer = session.createProducer(ADDRESS);
+
+      final int numMessages = 1000;
+                 
+      for (int i = 0; i < numMessages; i++)
+      {
+         ClientMessage message = session.createClientMessage(JBossTextMessage.TYPE,
+                                                             false,
+                                                             0,
+                                                             System.currentTimeMillis(),
+                                                             (byte)1);
+         message.putIntProperty(new SimpleString("count"), i);
+         message.getBody().putString("aardvarks");
+         message.getBody().flip();
+         producer.send(message);
+      }
+
+      ClientConsumer consumer = session.createConsumer(ADDRESS);
+
+      RemotingConnection conn = ((ClientSessionImpl)session).getConnection();
+
+      conn.fail(new MessagingException(MessagingException.NOT_CONNECTED));
+
+      session.start();
+
+      for (int i = 0; i < numMessages; i++)
+      {
+         ClientMessage message = consumer.receive(500);
+
+         assertNotNull(message);
+
+         assertEquals("aardvarks", message.getBody().getString());
+
+         assertEquals(i, message.getProperty(new SimpleString("count")));
+
+         message.acknowledge();
+      }
+
+      ClientMessage message = consumer.receiveImmediate();
+
+      assertNull(message);
+      
+      producer.close();
+      
+      consumer.close();
+
+      session.close();
+      
+      sf.close();
+   }
+
+   // Inner classes -------------------------------------------------
+}

Modified: trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/ReconnectTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/ReconnectTest.java	2008-12-04 15:39:04 UTC (rev 5462)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/ReconnectTest.java	2008-12-05 14:15:42 UTC (rev 5463)
@@ -628,6 +628,8 @@
    @Override
    protected void tearDown() throws Exception
    {
+      InVMConnector.resetFailures();
+      
       assertEquals(0, service.getServer().getRemotingService().getConnections().size());
 
       service.stop();

Modified: trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/ReconnectWithBackupTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/ReconnectWithBackupTest.java	2008-12-04 15:39:04 UTC (rev 5462)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/ReconnectWithBackupTest.java	2008-12-05 14:15:42 UTC (rev 5463)
@@ -230,7 +230,6 @@
       
       for (int j = 0; j < numIterations; j++)
       {
-
          // Send some more messages
 
          for (int i = numMessages; i < numMessages * 2; i++)

Modified: trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/SimpleAutomaticFailoverTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/SimpleAutomaticFailoverTest.java	2008-12-04 15:39:04 UTC (rev 5462)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/SimpleAutomaticFailoverTest.java	2008-12-05 14:15:42 UTC (rev 5463)
@@ -437,91 +437,8 @@
       assertEquals(0, sf.numConnections());
    }
 
-   public void testFailureListenerCalledOnFailure() throws Exception
-   {
-      ClientSessionFactoryInternal sf = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"),
-                                                                     new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory",
-                                                                                                backupParams));
+  
 
-      sf.setSendWindowSize(32 * 1024);
-      
-      ClientSession session = sf.createSession(false, true, true);
-
-      session.createQueue(ADDRESS, ADDRESS, null, false, false, true);
-
-      ClientProducer producer = session.createProducer(ADDRESS);
-
-      final int numMessages = 1000;
-
-      for (int i = 0; i < numMessages; i++)
-      {
-         ClientMessage message = session.createClientMessage(JBossTextMessage.TYPE,
-                                                             false,
-                                                             0,
-                                                             System.currentTimeMillis(),
-                                                             (byte)1);
-         message.putIntProperty(new SimpleString("count"), i);
-         message.getBody().putString("aardvarks");
-         message.getBody().flip();
-         producer.send(message);
-      }
-
-      RemotingConnection conn = ((ClientSessionImpl)session).getConnection();
-
-      final CountDownLatch latch = new CountDownLatch(1);
-
-      class MyListener implements FailureListener
-      {
-         public void connectionFailed(final MessagingException me)
-         {
-            latch.countDown();
-         }
-      }
-
-      conn.addFailureListener(new MyListener());
-
-      // Simulate failure on connection
-      conn.fail(new MessagingException(MessagingException.NOT_CONNECTED));
-
-      boolean ok = latch.await(1000, TimeUnit.MILLISECONDS);
-
-      assertTrue(ok);
-
-      ClientConsumer consumer = session.createConsumer(ADDRESS);
-
-      session.start();
-
-      for (int i = 0; i < numMessages; i++)
-      {
-         ClientMessage message2 = consumer.receive();
-
-         assertEquals("aardvarks", message2.getBody().getString());
-
-         assertEquals(i, message2.getProperty(new SimpleString("count")));
-
-         message2.acknowledge();
-      }
-
-      session.close();
-
-      sf = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory",
-                                                                   backupParams));
-
-      session = sf.createSession(false, true, true);
-
-      consumer = session.createConsumer(ADDRESS);
-
-      ClientMessage message3 = consumer.receive(250);
-
-      assertNull(message3);
-
-      session.close();
-
-      assertEquals(0, sf.numSessions());
-
-      assertEquals(0, sf.numConnections());
-   }
-
    public void testFailoverMultipleSessions() throws Exception
    {
       ClientSessionFactoryInternal sf = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"),
@@ -747,9 +664,11 @@
 
       class MyListener implements FailureListener
       {
-         public void connectionFailed(final MessagingException me)
+         public boolean connectionFailed(final MessagingException me)
          {
             latch.countDown();
+            
+            return true;
          }
       }
 

Modified: trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/SimpleManualFailoverTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/SimpleManualFailoverTest.java	2008-12-04 15:39:04 UTC (rev 5462)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/SimpleManualFailoverTest.java	2008-12-05 14:15:42 UTC (rev 5463)
@@ -135,10 +135,12 @@
 
       class MyListener implements FailureListener
       {
-         public void connectionFailed(MessagingException me)
+         public boolean connectionFailed(MessagingException me)
          {
             log.info("*** connection failed");
             latch.countDown();
+            
+            return true;
          }
       }
 

Modified: trunk/tests/src/org/jboss/messaging/tests/integration/jms/cluster/JMSFailoverTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/jms/cluster/JMSFailoverTest.java	2008-12-04 15:39:04 UTC (rev 5462)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/jms/cluster/JMSFailoverTest.java	2008-12-05 14:15:42 UTC (rev 5463)
@@ -186,11 +186,7 @@
 
       conn.close();
 
-      assertNotNull(listener.e);
-
-      JMSException je = listener.e;
-
-      assertEquals(me, je.getCause());
+      assertNull(listener.e);     
    }
 
    public void testManualFailover() throws Exception
@@ -217,8 +213,8 @@
                                                                    DEFAULT_PRE_ACKNOWLEDGE,                                                                
                                                                    DEFAULT_RETRY_INTERVAL,
                                                                    DEFAULT_RETRY_INTERVAL_MULTIPLIER,
-                                                                   DEFAULT_MAX_RETRIES_BEFORE_FAILOVER,
-                                                                   DEFAULT_MAX_RETRIES_AFTER_FAILOVER);
+                                                                   0,
+                                                                   0);
 
       JBossConnectionFactory jbcfBackup = new JBossConnectionFactory(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory",
                                                                                                 backupParams),
@@ -243,8 +239,8 @@
                                                                      DEFAULT_PRE_ACKNOWLEDGE,                                                                   
                                                                      DEFAULT_RETRY_INTERVAL,
                                                                      DEFAULT_RETRY_INTERVAL_MULTIPLIER,
-                                                                     DEFAULT_MAX_RETRIES_BEFORE_FAILOVER,
-                                                                     DEFAULT_MAX_RETRIES_AFTER_FAILOVER);
+                                                                     0,
+                                                                     0);
 
       Connection connLive = jbcfLive.createConnection();
 

Modified: trunk/tests/src/org/jboss/messaging/tests/integration/remoting/PingTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/remoting/PingTest.java	2008-12-04 15:39:04 UTC (rev 5462)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/remoting/PingTest.java	2008-12-05 14:15:42 UTC (rev 5463)
@@ -107,9 +107,11 @@
    {
       volatile MessagingException me;
 
-      public void connectionFailed(MessagingException me)
+      public boolean connectionFailed(MessagingException me)
       {
          this.me = me;
+         
+         return true;
       }
 
       public MessagingException getException()




More information about the jboss-cvs-commits mailing list