summaryrefslogtreecommitdiff
path: root/java/client
diff options
context:
space:
mode:
authorRajith Muditha Attapattu <rajith@apache.org>2009-05-14 19:50:23 +0000
committerRajith Muditha Attapattu <rajith@apache.org>2009-05-14 19:50:23 +0000
commit90f49326a937bc0c767b99c922e2bcf29058ef36 (patch)
tree1582196f7a6d79c27eb7aed6dc28338abc9c3e5b /java/client
parentd09122c9d97801ace53279f7eb463c21b905ba89 (diff)
downloadqpid-python-90f49326a937bc0c767b99c922e2bcf29058ef36.tar.gz
This is a fix for QPID-1859
For FailoverSingleServer the default for retries is set to 0 and the current_retries start from 0 instead of -1. For FailoverRoundRobinServers the current_broker_index now starts from 0 instead of -1. The AMQConnection now uses the getCurrentBrokerDetails() instead of the getNextBrokerDetails() to get the initial broker to connect. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@774899 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/client')
-rw-r--r--java/client/src/main/java/org/apache/qpid/client/AMQConnection.java2
-rw-r--r--java/client/src/main/java/org/apache/qpid/jms/failover/FailoverRoundRobinServers.java55
-rw-r--r--java/client/src/main/java/org/apache/qpid/jms/failover/FailoverSingleServer.java6
3 files changed, 19 insertions, 44 deletions
diff --git a/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java b/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java
index e6968100f3..0d2adcec8a 100644
--- a/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java
+++ b/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java
@@ -455,7 +455,7 @@ public class AMQConnection extends Closeable implements Connection, QueueConnect
}
_failoverPolicy = new FailoverPolicy(connectionURL, this);
- BrokerDetails brokerDetails = _failoverPolicy.getNextBrokerDetails();
+ BrokerDetails brokerDetails = _failoverPolicy.getCurrentBrokerDetails();
if (brokerDetails.getTransport().equals(BrokerDetails.VM))
{
_delegate = new AMQConnectionDelegate_8_0(this);
diff --git a/java/client/src/main/java/org/apache/qpid/jms/failover/FailoverRoundRobinServers.java b/java/client/src/main/java/org/apache/qpid/jms/failover/FailoverRoundRobinServers.java
index c7d8c69fff..869944dd6e 100644
--- a/java/client/src/main/java/org/apache/qpid/jms/failover/FailoverRoundRobinServers.java
+++ b/java/client/src/main/java/org/apache/qpid/jms/failover/FailoverRoundRobinServers.java
@@ -35,19 +35,19 @@ public class FailoverRoundRobinServers implements FailoverMethod
public static final int DEFAULT_SERVER_RETRIES = 0;
/** The index into the hostDetails array of the broker to which we are connected */
- private int _currentBrokerIndex = -1;
+ private int _currentBrokerIndex = 0;
/** The number of times to retry connecting for each server */
private int _serverRetries;
/** The current number of retry attempts made */
- private int _currentServerRetry;
+ private int _currentServerRetry = 0;
/** The number of times to cycle through the servers */
private int _cycleRetries;
/** The current number of cycles performed. */
- private int _currentCycleRetries;
+ private int _currentCycleRetries = 0;
/** Array of BrokerDetail used to make connections. */
protected ConnectionURL _connectionDetails;
@@ -62,7 +62,7 @@ public class FailoverRoundRobinServers implements FailoverMethod
_connectionDetails = connectionDetails;
// There is no current broker at startup so set it to -1.
- _currentBrokerIndex = -1;
+ _currentBrokerIndex = 0;
String cycleRetries = _connectionDetails.getFailoverOption(ConnectionURL.OPTIONS_FAILOVER_CYCLE);
@@ -83,18 +83,21 @@ public class FailoverRoundRobinServers implements FailoverMethod
_currentCycleRetries = 0;
_serverRetries = 0;
- _currentServerRetry = -1;
+ _currentServerRetry = 0;
}
public void reset()
{
_currentBrokerIndex = 0;
_currentCycleRetries = 0;
- _currentServerRetry = -1;
+ _currentServerRetry = 0;
}
public boolean failoverAllowed()
{
+ System.out.println("====================================");
+ System.out.println(toString());
+ System.out.println("====================================");
return ((_currentCycleRetries < _cycleRetries) || (_currentServerRetry < _serverRetries));
//|| (_currentBrokerIndex <= (_connectionDetails.getBrokerCount() - 1)));
}
@@ -102,16 +105,11 @@ public class FailoverRoundRobinServers implements FailoverMethod
public void attainedConnection()
{
_currentCycleRetries = 0;
- _currentServerRetry = -1;
+ _currentServerRetry = 0;
}
public BrokerDetails getCurrentBrokerDetails()
{
- if (_currentBrokerIndex == -1)
- {
- return null;
- }
-
return _connectionDetails.getBrokerDetails(_currentBrokerIndex);
}
@@ -123,20 +121,8 @@ public class FailoverRoundRobinServers implements FailoverMethod
{
if (_currentServerRetry < _serverRetries)
{
- if (_currentBrokerIndex == -1)
- {
- _currentBrokerIndex = 0;
-
- setBroker(_connectionDetails.getBrokerDetails(_currentBrokerIndex));
-
- _logger.info("First run using " + _connectionDetails.getBrokerDetails(_currentBrokerIndex));
- }
- else
- {
- _logger.info("Retrying " + _connectionDetails.getBrokerDetails(_currentBrokerIndex));
- doDelay=true;
- }
-
+ _logger.info("Trying " + _connectionDetails.getBrokerDetails(_currentBrokerIndex));
+ doDelay= _currentBrokerIndex != 0;
_currentServerRetry++;
}
else
@@ -156,19 +142,8 @@ public class FailoverRoundRobinServers implements FailoverMethod
{
if (_currentServerRetry < _serverRetries)
{
- if (_currentBrokerIndex == -1)
- {
- _currentBrokerIndex = 0;
-
- setBroker(_connectionDetails.getBrokerDetails(_currentBrokerIndex));
-
- _logger.info("First run using " + _connectionDetails.getBrokerDetails(_currentBrokerIndex));
- }
- else
- {
- _logger.info("Retrying " + _connectionDetails.getBrokerDetails(_currentBrokerIndex));
- doDelay=true;
- }
+ _logger.info("Trying " + _connectionDetails.getBrokerDetails(_currentBrokerIndex));
+ doDelay= _currentBrokerIndex != 0;
_currentServerRetry++;
}
@@ -227,7 +202,7 @@ public class FailoverRoundRobinServers implements FailoverMethod
}
}
- _currentServerRetry = -1;
+ _currentServerRetry = 0;
_currentBrokerIndex = index;
}
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 0d5507e8f8..d033a49f5c 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
@@ -30,7 +30,7 @@ public class FailoverSingleServer implements FailoverMethod
private static final Logger _logger = LoggerFactory.getLogger(FailoverSingleServer.class);
/** The default number of times to rety a conection to this server */
- public static final int DEFAULT_SERVER_RETRIES = 1;
+ public static final int DEFAULT_SERVER_RETRIES = 0;
/** The details of the Single Server */
private BrokerDetails _brokerDetail;
@@ -39,7 +39,7 @@ public class FailoverSingleServer implements FailoverMethod
protected int _retries;
/** The current number of attempts made to the server */
- protected int _currentRetries;
+ protected int _currentRetries = 0;
public FailoverSingleServer(ConnectionURL connectionDetails)
@@ -61,7 +61,7 @@ public class FailoverSingleServer implements FailoverMethod
public void reset()
{
- _currentRetries = -1;
+ _currentRetries = 0;
}
public boolean failoverAllowed()