qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ritch...@apache.org
Subject svn commit: r761253 - in /qpid/branches/0.5-release/qpid/java: client/src/main/java/org/apache/qpid/jms/ client/src/main/java/org/apache/qpid/jms/failover/ systests/src/main/java/org/apache/qpid/server/failover/
Date Thu, 02 Apr 2009 11:34:25 GMT
Author: ritchiem
Date: Thu Apr  2 11:34:24 2009
New Revision: 761253

URL: http://svn.apache.org/viewvc?rev=761253&view=rev
Log:
QPID-1778 : Add NoFailover FailoverMethod that blocks that still allows connection retry but
only on the initial connection...
Merged from trunk r759097


Added:
    qpid/branches/0.5-release/qpid/java/client/src/main/java/org/apache/qpid/jms/failover/NoFailover.java
      - copied unchanged from r759097, qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/jms/failover/NoFailover.java
Modified:
    qpid/branches/0.5-release/qpid/java/client/src/main/java/org/apache/qpid/jms/FailoverPolicy.java
    qpid/branches/0.5-release/qpid/java/client/src/main/java/org/apache/qpid/jms/failover/FailoverMethod.java
    qpid/branches/0.5-release/qpid/java/client/src/main/java/org/apache/qpid/jms/failover/FailoverSingleServer.java
    qpid/branches/0.5-release/qpid/java/systests/src/main/java/org/apache/qpid/server/failover/FailoverMethodTest.java

Modified: qpid/branches/0.5-release/qpid/java/client/src/main/java/org/apache/qpid/jms/FailoverPolicy.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.5-release/qpid/java/client/src/main/java/org/apache/qpid/jms/FailoverPolicy.java?rev=761253&r1=761252&r2=761253&view=diff
==============================================================================
--- qpid/branches/0.5-release/qpid/java/client/src/main/java/org/apache/qpid/jms/FailoverPolicy.java
(original)
+++ qpid/branches/0.5-release/qpid/java/client/src/main/java/org/apache/qpid/jms/FailoverPolicy.java
Thu Apr  2 11:34:24 2009
@@ -25,6 +25,7 @@
 import org.apache.qpid.jms.failover.FailoverMethod;
 import org.apache.qpid.jms.failover.FailoverRoundRobinServers;
 import org.apache.qpid.jms.failover.FailoverSingleServer;
+import org.apache.qpid.jms.failover.NoFailover;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -94,6 +95,10 @@
                 {
                     method = new FailoverExchangeMethod(connectionDetails, conn);
                 }
+                else if (failoverMethod.equals(FailoverMethod.NO_FAILOVER))
+                {
+                    method = new NoFailover(connectionDetails);
+                }
                 else
                 {
                     try

Modified: qpid/branches/0.5-release/qpid/java/client/src/main/java/org/apache/qpid/jms/failover/FailoverMethod.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.5-release/qpid/java/client/src/main/java/org/apache/qpid/jms/failover/FailoverMethod.java?rev=761253&r1=761252&r2=761253&view=diff
==============================================================================
--- qpid/branches/0.5-release/qpid/java/client/src/main/java/org/apache/qpid/jms/failover/FailoverMethod.java
(original)
+++ qpid/branches/0.5-release/qpid/java/client/src/main/java/org/apache/qpid/jms/failover/FailoverMethod.java
Thu Apr  2 11:34:24 2009
@@ -29,6 +29,8 @@
     public static final String ROUND_ROBIN = "roundrobin";
     public static final String FAILOVER_EXCHANGE= "failover_exchange";
     public static final String RANDOM = "random";
+    public static final String NO_FAILOVER = "nofailover";
+
     /**
      * Reset the Failover to initial conditions
      */

Modified: qpid/branches/0.5-release/qpid/java/client/src/main/java/org/apache/qpid/jms/failover/FailoverSingleServer.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.5-release/qpid/java/client/src/main/java/org/apache/qpid/jms/failover/FailoverSingleServer.java?rev=761253&r1=761252&r2=761253&view=diff
==============================================================================
--- qpid/branches/0.5-release/qpid/java/client/src/main/java/org/apache/qpid/jms/failover/FailoverSingleServer.java
(original)
+++ qpid/branches/0.5-release/qpid/java/client/src/main/java/org/apache/qpid/jms/failover/FailoverSingleServer.java
Thu Apr  2 11:34:24 2009
@@ -36,10 +36,10 @@
     private BrokerDetails _brokerDetail;
 
     /** The number of times to retry connecting to the sever */
-    private int _retries;
+    protected int _retries;
 
     /** The current number of attempts made to the server */
-    private int _currentRetries;
+    protected int _currentRetries;
 
 
     public FailoverSingleServer(ConnectionURL connectionDetails)
@@ -157,7 +157,7 @@
 
     public String toString()
     {
-        return "SingleServer:\n" +
+        return methodName()+":\n" +
                "Max Retries:" + _retries +
                "\nCurrent Retry:" + _currentRetries +
                "\n" + _brokerDetail + "\n";

Modified: qpid/branches/0.5-release/qpid/java/systests/src/main/java/org/apache/qpid/server/failover/FailoverMethodTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.5-release/qpid/java/systests/src/main/java/org/apache/qpid/server/failover/FailoverMethodTest.java?rev=761253&r1=761252&r2=761253&view=diff
==============================================================================
--- qpid/branches/0.5-release/qpid/java/systests/src/main/java/org/apache/qpid/server/failover/FailoverMethodTest.java
(original)
+++ qpid/branches/0.5-release/qpid/java/systests/src/main/java/org/apache/qpid/server/failover/FailoverMethodTest.java
Thu Apr  2 11:34:24 2009
@@ -28,8 +28,6 @@
 import org.apache.qpid.client.transport.TransportConnection;
 import org.apache.qpid.client.vmbroker.AMQVMBrokerCreationException;
 import org.apache.qpid.url.URLSyntaxException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 import javax.jms.ExceptionListener;
 import javax.jms.JMSException;
@@ -151,4 +149,78 @@
             _failoverComplete.countDown();
         }
     }
+
+    public void testNoFailover() throws URLSyntaxException, AMQVMBrokerCreationException,
+                                        InterruptedException, JMSException
+    {
+        String connectionString = "amqp://guest:guest@/test?brokerlist='vm://:1?connectdelay='500',retries='3'',failover='nofailover'";
+
+        AMQConnectionURL url = new AMQConnectionURL(connectionString);
+
+        try
+        {
+            //Kill initial broker
+            TransportConnection.killAllVMBrokers();
+
+            //Create a thread to start the broker asynchronously
+            Thread brokerStart = new Thread(new Runnable()
+            {
+                public void run()
+                {
+                    try
+                    {
+                        //Wait before starting broker
+                        // The wait should allow atleast 1 retries to fail before broker
is ready
+                        Thread.sleep(750);
+                        TransportConnection.createVMBroker(1);
+                    }
+                    catch (Exception e)
+                    {
+                        System.err.println(e.getMessage());
+                        e.printStackTrace();
+                    }
+                }
+            });
+
+
+            brokerStart.start();
+            long start = System.currentTimeMillis();
+
+
+            //Start the connection so it will use the retries
+            AMQConnection connection = new AMQConnection(url, null);
+
+            long end = System.currentTimeMillis();
+
+            long duration = (end - start);
+
+            // Check that we actually had a delay had a delay in connection
+            assertTrue("Initial connection should be longer than 1 delay : 500 <:(" +
duration + ")", duration > 500);
+
+
+            connection.setExceptionListener(this);
+
+            //Ensure we collect the brokerStart thread
+            brokerStart.join();
+
+            start = System.currentTimeMillis();
+
+            //Kill connection
+            TransportConnection.killAllVMBrokers();                                    
+
+            _failoverComplete.await();
+
+            end = System.currentTimeMillis();
+
+            duration = (end - start);
+
+            // Notification of the connection failure should be very quick as we are denying
the ability to failover.
+            assertTrue("Notification of the connection failure took was : 100 >:(" + duration
+ ")", duration < 100);
+        }
+        catch (AMQException e)
+        {
+            fail(e.getMessage());
+        }
+    }
+
 }



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org


Mime
View raw message