You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ri...@apache.org on 2009/04/14 16:38:35 UTC

svn commit: r764795 - in /qpid/branches/0.5-fix/qpid/java: broker/bin/ broker/src/main/java/org/apache/qpid/server/management/ broker/src/main/java/org/apache/qpid/server/queue/ client/src/main/java/org/apache/qpid/jms/ client/src/main/java/org/apache/...

Author: ritchiem
Date: Tue Apr 14 14:38:35 2009
New Revision: 764795

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

merged from trunk r759097

Added:
    qpid/branches/0.5-fix/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-fix/qpid/java/broker/bin/   (props changed)
    qpid/branches/0.5-fix/qpid/java/broker/src/main/java/org/apache/qpid/server/management/   (props changed)
    qpid/branches/0.5-fix/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/   (props changed)
    qpid/branches/0.5-fix/qpid/java/client/src/main/java/org/apache/qpid/jms/FailoverPolicy.java
    qpid/branches/0.5-fix/qpid/java/client/src/main/java/org/apache/qpid/jms/failover/FailoverMethod.java
    qpid/branches/0.5-fix/qpid/java/client/src/main/java/org/apache/qpid/jms/failover/FailoverSingleServer.java
    qpid/branches/0.5-fix/qpid/java/systests/src/main/java/org/apache/qpid/server/failover/FailoverMethodTest.java

Propchange: qpid/branches/0.5-fix/qpid/java/broker/bin/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Apr 14 14:38:35 2009
@@ -1,2 +1,2 @@
 /qpid/branches/0.5-release/qpid/java/broker/bin:757268
-/qpid/trunk/qpid/java/broker/bin:753219-753220,753253,758730,760919,761721,762365,762992,763959
+/qpid/trunk/qpid/java/broker/bin:753219-753220,753253,758730,759097,760919,761721,762365,762992,763959

Propchange: qpid/branches/0.5-fix/qpid/java/broker/src/main/java/org/apache/qpid/server/management/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Apr 14 14:38:35 2009
@@ -1,2 +1,2 @@
 /qpid/branches/0.5-release/qpid/java/broker/src/main/java/org/apache/qpid/server/management:757268
-/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/management:753219-753220,753253,758730,760919,761721,762365,762992,763959
+/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/management:753219-753220,753253,758730,759097,760919,761721,762365,762992,763959

Propchange: qpid/branches/0.5-fix/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Apr 14 14:38:35 2009
@@ -1,2 +1,2 @@
 /qpid/branches/0.5-release/qpid/java/broker/src/main/java/org/apache/qpid/server/queue:757257
-/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue:753219-753220,753253,757270,758730,760919,761721,762365,762992,763959
+/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue:753219-753220,753253,757270,758730,759097,760919,761721,762365,762992,763959

Modified: qpid/branches/0.5-fix/qpid/java/client/src/main/java/org/apache/qpid/jms/FailoverPolicy.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.5-fix/qpid/java/client/src/main/java/org/apache/qpid/jms/FailoverPolicy.java?rev=764795&r1=764794&r2=764795&view=diff
==============================================================================
--- qpid/branches/0.5-fix/qpid/java/client/src/main/java/org/apache/qpid/jms/FailoverPolicy.java (original)
+++ qpid/branches/0.5-fix/qpid/java/client/src/main/java/org/apache/qpid/jms/FailoverPolicy.java Tue Apr 14 14:38:35 2009
@@ -23,6 +23,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;
@@ -88,6 +89,10 @@
                 {
                     method = new FailoverRoundRobinServers(connectionDetails);
                 }
+                else if (failoverMethod.equals(FailoverMethod.NO_FAILOVER))
+                {
+                    method = new NoFailover(connectionDetails);
+                }
                 else
                 {
                     try

Modified: qpid/branches/0.5-fix/qpid/java/client/src/main/java/org/apache/qpid/jms/failover/FailoverMethod.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.5-fix/qpid/java/client/src/main/java/org/apache/qpid/jms/failover/FailoverMethod.java?rev=764795&r1=764794&r2=764795&view=diff
==============================================================================
--- qpid/branches/0.5-fix/qpid/java/client/src/main/java/org/apache/qpid/jms/failover/FailoverMethod.java (original)
+++ qpid/branches/0.5-fix/qpid/java/client/src/main/java/org/apache/qpid/jms/failover/FailoverMethod.java Tue Apr 14 14:38:35 2009
@@ -28,6 +28,8 @@
     public static final String SINGLE_BROKER = "singlebroker";
     public static final String ROUND_ROBIN = "roundrobin";
     public static final String RANDOM = "random";
+    public static final String NO_FAILOVER = "nofailover";
+
     /**
      * Reset the Failover to initial conditions
      */

Modified: qpid/branches/0.5-fix/qpid/java/client/src/main/java/org/apache/qpid/jms/failover/FailoverSingleServer.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.5-fix/qpid/java/client/src/main/java/org/apache/qpid/jms/failover/FailoverSingleServer.java?rev=764795&r1=764794&r2=764795&view=diff
==============================================================================
--- qpid/branches/0.5-fix/qpid/java/client/src/main/java/org/apache/qpid/jms/failover/FailoverSingleServer.java (original)
+++ qpid/branches/0.5-fix/qpid/java/client/src/main/java/org/apache/qpid/jms/failover/FailoverSingleServer.java Tue Apr 14 14:38:35 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-fix/qpid/java/systests/src/main/java/org/apache/qpid/server/failover/FailoverMethodTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.5-fix/qpid/java/systests/src/main/java/org/apache/qpid/server/failover/FailoverMethodTest.java?rev=764795&r1=764794&r2=764795&view=diff
==============================================================================
--- qpid/branches/0.5-fix/qpid/java/systests/src/main/java/org/apache/qpid/server/failover/FailoverMethodTest.java (original)
+++ qpid/branches/0.5-fix/qpid/java/systests/src/main/java/org/apache/qpid/server/failover/FailoverMethodTest.java Tue Apr 14 14:38:35 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