summaryrefslogtreecommitdiff
path: root/java/client
diff options
context:
space:
mode:
authorMartin Ritchie <ritchiem@apache.org>2009-03-27 10:38:41 +0000
committerMartin Ritchie <ritchiem@apache.org>2009-03-27 10:38:41 +0000
commit29be45fd8e28fe8ddf3571c7e6a5b1f71368a14b (patch)
tree2d75b9d63b12deecb077db7636f161c533f6403b /java/client
parentd4f28cf5814a0594c3d7287b51331149ee8962ba (diff)
downloadqpid-python-29be45fd8e28fe8ddf3571c7e6a5b1f71368a14b.tar.gz
QPID-1778 : Add NoFailover FailoverMethod that blocks that still allows connection retry but only on the initial connection. Failover will not be attempted after an established connection is lost. Updated FailoverMethodTest to test this behaviour.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@759097 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/client')
-rw-r--r--java/client/src/main/java/org/apache/qpid/jms/FailoverPolicy.java5
-rw-r--r--java/client/src/main/java/org/apache/qpid/jms/failover/FailoverMethod.java2
-rw-r--r--java/client/src/main/java/org/apache/qpid/jms/failover/FailoverSingleServer.java6
-rw-r--r--java/client/src/main/java/org/apache/qpid/jms/failover/NoFailover.java62
4 files changed, 72 insertions, 3 deletions
diff --git a/java/client/src/main/java/org/apache/qpid/jms/FailoverPolicy.java b/java/client/src/main/java/org/apache/qpid/jms/FailoverPolicy.java
index bfd1161c90..7cdcd32306 100644
--- a/java/client/src/main/java/org/apache/qpid/jms/FailoverPolicy.java
+++ b/java/client/src/main/java/org/apache/qpid/jms/FailoverPolicy.java
@@ -25,6 +25,7 @@ import org.apache.qpid.jms.failover.FailoverExchangeMethod;
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 @@ public class FailoverPolicy
{
method = new FailoverExchangeMethod(connectionDetails, conn);
}
+ else if (failoverMethod.equals(FailoverMethod.NO_FAILOVER))
+ {
+ method = new NoFailover(connectionDetails);
+ }
else
{
try
diff --git a/java/client/src/main/java/org/apache/qpid/jms/failover/FailoverMethod.java b/java/client/src/main/java/org/apache/qpid/jms/failover/FailoverMethod.java
index a921649829..1cef067e5f 100644
--- a/java/client/src/main/java/org/apache/qpid/jms/failover/FailoverMethod.java
+++ b/java/client/src/main/java/org/apache/qpid/jms/failover/FailoverMethod.java
@@ -29,6 +29,8 @@ public interface FailoverMethod
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
*/
diff --git a/java/client/src/main/java/org/apache/qpid/jms/failover/FailoverSingleServer.java b/java/client/src/main/java/org/apache/qpid/jms/failover/FailoverSingleServer.java
index 9fa006233b..0d5507e8f8 100644
--- a/java/client/src/main/java/org/apache/qpid/jms/failover/FailoverSingleServer.java
+++ b/java/client/src/main/java/org/apache/qpid/jms/failover/FailoverSingleServer.java
@@ -36,10 +36,10 @@ public class FailoverSingleServer implements FailoverMethod
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 class FailoverSingleServer implements FailoverMethod
public String toString()
{
- return "SingleServer:\n" +
+ return methodName()+":\n" +
"Max Retries:" + _retries +
"\nCurrent Retry:" + _currentRetries +
"\n" + _brokerDetail + "\n";
diff --git a/java/client/src/main/java/org/apache/qpid/jms/failover/NoFailover.java b/java/client/src/main/java/org/apache/qpid/jms/failover/NoFailover.java
new file mode 100644
index 0000000000..1231324397
--- /dev/null
+++ b/java/client/src/main/java/org/apache/qpid/jms/failover/NoFailover.java
@@ -0,0 +1,62 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.jms.failover;
+
+import org.apache.qpid.jms.BrokerDetails;
+import org.apache.qpid.jms.ConnectionURL;
+
+/**
+ * Extend the Single Server Model to gain retry functionality but once connected do not attempt to failover.
+ */
+public class NoFailover extends FailoverSingleServer
+{
+ private boolean _connected = false;
+
+ public NoFailover(BrokerDetails brokerDetail)
+ {
+ super(brokerDetail);
+ }
+
+ public NoFailover(ConnectionURL connectionDetails)
+ {
+ super(connectionDetails);
+ }
+
+ @Override
+ public void attainedConnection()
+ {
+ _connected=true;
+ _currentRetries = _retries;
+ }
+
+ @Override
+ public String methodName()
+ {
+ return "NoFailover";
+ }
+
+ @Override
+ public String toString()
+ {
+ return super.toString() + (_connected ? "Connection attained." : "Never connected.") + "\n";
+ }
+
+}