summaryrefslogtreecommitdiff
path: root/qpid/java/client
diff options
context:
space:
mode:
authorMartin Ritchie <ritchiem@apache.org>2009-04-14 14:38:35 +0000
committerMartin Ritchie <ritchiem@apache.org>2009-04-14 14:38:35 +0000
commita2c4c70d6218a9ff70372d55c8528e48f033d542 (patch)
treec7290f522bc7de22a6750ed2cd69e2db8c913047 /qpid/java/client
parent51f6e8c0f8f17ba00c5f78ddf3c368a1eaab7f09 (diff)
downloadqpid-python-a2c4c70d6218a9ff70372d55c8528e48f033d542.tar.gz
QPID-1778 : Add NoFailover FailoverMethod that blocks that still allows connection retry but only on the initial
merged from trunk r759097 git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/0.5-fix@764795 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/client')
-rw-r--r--qpid/java/client/src/main/java/org/apache/qpid/jms/FailoverPolicy.java5
-rw-r--r--qpid/java/client/src/main/java/org/apache/qpid/jms/failover/FailoverMethod.java2
-rw-r--r--qpid/java/client/src/main/java/org/apache/qpid/jms/failover/FailoverSingleServer.java6
-rw-r--r--qpid/java/client/src/main/java/org/apache/qpid/jms/failover/NoFailover.java62
4 files changed, 72 insertions, 3 deletions
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/jms/FailoverPolicy.java b/qpid/java/client/src/main/java/org/apache/qpid/jms/FailoverPolicy.java
index 4186706ade..b366648663 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/jms/FailoverPolicy.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/jms/FailoverPolicy.java
@@ -23,6 +23,7 @@ package org.apache.qpid.jms;
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 @@ public class FailoverPolicy
{
method = new FailoverRoundRobinServers(connectionDetails);
}
+ else if (failoverMethod.equals(FailoverMethod.NO_FAILOVER))
+ {
+ method = new NoFailover(connectionDetails);
+ }
else
{
try
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/jms/failover/FailoverMethod.java b/qpid/java/client/src/main/java/org/apache/qpid/jms/failover/FailoverMethod.java
index d7ec46dea3..f6db72e885 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/jms/failover/FailoverMethod.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/jms/failover/FailoverMethod.java
@@ -28,6 +28,8 @@ public interface FailoverMethod
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
*/
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/jms/failover/FailoverSingleServer.java b/qpid/java/client/src/main/java/org/apache/qpid/jms/failover/FailoverSingleServer.java
index 9fa006233b..0d5507e8f8 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/jms/failover/FailoverSingleServer.java
+++ b/qpid/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/qpid/java/client/src/main/java/org/apache/qpid/jms/failover/NoFailover.java b/qpid/java/client/src/main/java/org/apache/qpid/jms/failover/NoFailover.java
new file mode 100644
index 0000000000..1231324397
--- /dev/null
+++ b/qpid/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";
+ }
+
+}