summaryrefslogtreecommitdiff
path: root/dotnet/Qpid.Client/qms/failover
diff options
context:
space:
mode:
authorRobert Greig <rgreig@apache.org>2007-01-29 11:05:20 +0000
committerRobert Greig <rgreig@apache.org>2007-01-29 11:05:20 +0000
commit509d48d3a12c3477c893456549e0d052d9e5e9f9 (patch)
treedb601f414a0f65e79bd74a3957fc8a78f918df12 /dotnet/Qpid.Client/qms/failover
parenta6808589c1ce06773f599bc28fe90938e2dcd60f (diff)
downloadqpid-python-509d48d3a12c3477c893456549e0d052d9e5e9f9.tar.gz
(Patch supplied by Tomas Restrepo) QPID-312.diff applied. This converts Javadoc copied accross from the orignal Java code to .Net format. Renames some files/classes/methods to use .Net conventions.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@501006 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'dotnet/Qpid.Client/qms/failover')
-rw-r--r--dotnet/Qpid.Client/qms/failover/FailoverMethod.cs81
-rw-r--r--dotnet/Qpid.Client/qms/failover/FailoverRoundRobin.cs46
-rw-r--r--dotnet/Qpid.Client/qms/failover/FailoverSingleServer.cs40
3 files changed, 83 insertions, 84 deletions
diff --git a/dotnet/Qpid.Client/qms/failover/FailoverMethod.cs b/dotnet/Qpid.Client/qms/failover/FailoverMethod.cs
index 7db9ef32fa..076c62a6d6 100644
--- a/dotnet/Qpid.Client/qms/failover/FailoverMethod.cs
+++ b/dotnet/Qpid.Client/qms/failover/FailoverMethod.cs
@@ -20,7 +20,7 @@
*/
using System;
-namespace Qpid.Client.qms.failover
+namespace Qpid.Client.Qms.Failover
{
public class FailoverMethodConstants
{
@@ -28,52 +28,51 @@ namespace Qpid.Client.qms.failover
public const String RANDOM = "random";
}
- public interface FailoverMethod
+ public interface IFailoverMethod
{
- /**
- * Reset the Failover to initial conditions
- */
- void reset();
+ /// <summary>
+ /// The name of this method for display purposes.
+ /// </summary>
+ String MethodName { get; }
+
+ /// <summary>
+ /// Reset the Failover to initial conditions
+ /// </summary>
+ void Reset();
- /**
- * Check if failover is possible for this method
- *
- * @return true if failover is allowed
- */
- bool failoverAllowed();
+ /// <summary>
+ /// Check if failover is possible for this method
+ /// </summary>
+ /// <returns>true if failover is allowed</returns>
+ bool FailoverAllowed();
- /**
- * Notification to the Failover method that a connection has been attained.
- */
- void attainedConnection();
+ /// <summary>
+ /// Notification to the Failover method that a connection has been attained.
+ /// </summary>
+ void AttainedConnection();
- /**
- * If there is no current BrokerInfo the null will be returned.
- * @return The current BrokerDetail value to use
- */
- BrokerInfo GetCurrentBrokerInfo();
+ /// <summary>
+ /// If there is no current BrokerInfo the null will be returned.
+ /// </summary>
+ /// <returns>The current BrokerDetail value to use</returns>
+ IBrokerInfo GetCurrentBrokerInfo();
- /**
- * Move to the next BrokerInfo if one is available.
- * @return the next BrokerDetail or null if there is none.
- */
- BrokerInfo getNextBrokerDetails();
+ /// <summary>
+ /// Move to the next BrokerInfo if one is available.
+ /// </summary>
+ /// <returns>the next BrokerDetail or null if there is none.</returns>
+ IBrokerInfo GetNextBrokerDetails();
- /**
- * Set the currently active broker to be the new value.
- * @param broker The new BrokerDetail value
- */
- void setBroker(BrokerInfo broker);
+ /// <summary>
+ /// Set the currently active broker to be the new value.
+ /// </summary>
+ /// <param name="broker">The new BrokerDetail value</param>
+ void SetBroker(IBrokerInfo broker);
- /**
- * Set the retries for this method
- * @param maxRetries the maximum number of time to retry this Method
- */
- void setRetries(int maxRetries);
-
- /**
- * @return The name of this method for display purposes.
- */
- String methodName();
+ /// <summary>
+ /// Set the retries for this method
+ /// </summary>
+ /// <param name="maxRetries">the maximum number of time to retry this Method</param>
+ void SetRetries(int maxRetries);
}
}
diff --git a/dotnet/Qpid.Client/qms/failover/FailoverRoundRobin.cs b/dotnet/Qpid.Client/qms/failover/FailoverRoundRobin.cs
index aac16a40fa..4e6b23ce86 100644
--- a/dotnet/Qpid.Client/qms/failover/FailoverRoundRobin.cs
+++ b/dotnet/Qpid.Client/qms/failover/FailoverRoundRobin.cs
@@ -22,9 +22,9 @@ using System;
using System.Text;
using log4net;
-namespace Qpid.Client.qms.failover
+namespace Qpid.Client.Qms.Failover
{
- public class FailoverRoundRobin : FailoverMethod
+ public class FailoverRoundRobin : IFailoverMethod
{
private static readonly ILog _logger = LogManager.GetLogger(typeof(FailoverRoundRobin));
@@ -61,11 +61,11 @@ namespace Qpid.Client.qms.failover
/**
* Array of BrokerDetail used to make connections.
*/
- private ConnectionInfo _connectionDetails;
+ private IConnectionInfo _connectionDetails;
- public FailoverRoundRobin(ConnectionInfo connectionDetails)
+ public FailoverRoundRobin(IConnectionInfo connectionDetails)
{
- if (!(connectionDetails.GetBrokerCount() > 0))
+ if (!(connectionDetails.BrokerCount > 0))
{
throw new ArgumentException("At least one broker details must be specified.");
}
@@ -95,27 +95,27 @@ namespace Qpid.Client.qms.failover
_currentServerRetry = -1;
}
- public void reset()
+ public void Reset()
{
_currentBrokerIndex = 0;
_currentCycleRetries = 0;
_currentServerRetry = -1;
}
- public bool failoverAllowed()
+ public bool FailoverAllowed()
{
return ((_currentCycleRetries < _cycleRetries)
|| (_currentServerRetry < _serverRetries)
- || (_currentBrokerIndex < (_connectionDetails.GetBrokerCount() - 1)));
+ || (_currentBrokerIndex < (_connectionDetails.BrokerCount - 1)));
}
- public void attainedConnection()
+ public void AttainedConnection()
{
_currentCycleRetries = 0;
_currentServerRetry = -1;
}
- public BrokerInfo GetCurrentBrokerInfo()
+ public IBrokerInfo GetCurrentBrokerInfo()
{
if (_currentBrokerIndex == -1)
{
@@ -125,9 +125,9 @@ namespace Qpid.Client.qms.failover
return _connectionDetails.GetBrokerInfo(_currentBrokerIndex);
}
- public BrokerInfo getNextBrokerDetails()
+ public IBrokerInfo GetNextBrokerDetails()
{
- if (_currentBrokerIndex == (_connectionDetails.GetBrokerCount() - 1))
+ if (_currentBrokerIndex == (_connectionDetails.BrokerCount - 1))
{
if (_currentServerRetry < _serverRetries)
{
@@ -135,7 +135,7 @@ namespace Qpid.Client.qms.failover
{
_currentBrokerIndex = 0;
- setBroker(_connectionDetails.GetBrokerInfo(_currentBrokerIndex ));
+ SetBroker(_connectionDetails.GetBrokerInfo(_currentBrokerIndex ));
_logger.Info("First Run using " + _connectionDetails.GetBrokerInfo(_currentBrokerIndex));
}
@@ -152,7 +152,7 @@ namespace Qpid.Client.qms.failover
//failed to connect to first broker
_currentBrokerIndex = 0;
- setBroker(_connectionDetails.GetBrokerInfo(_currentBrokerIndex ));
+ SetBroker(_connectionDetails.GetBrokerInfo(_currentBrokerIndex ));
// This is zero rather than -1 as we are already retrieving the details.
_currentServerRetry = 0;
@@ -167,7 +167,7 @@ namespace Qpid.Client.qms.failover
{
_currentBrokerIndex = 0;
- setBroker(_connectionDetails.GetBrokerInfo(_currentBrokerIndex ));
+ SetBroker(_connectionDetails.GetBrokerInfo(_currentBrokerIndex ));
_logger.Info("First Run using " + _connectionDetails.GetBrokerInfo(_currentBrokerIndex));
}
@@ -181,7 +181,7 @@ namespace Qpid.Client.qms.failover
{
_currentBrokerIndex++;
- setBroker(_connectionDetails.GetBrokerInfo(_currentBrokerIndex ));
+ SetBroker(_connectionDetails.GetBrokerInfo(_currentBrokerIndex ));
// This is zero rather than -1 as we are already retrieving the details.
_currentServerRetry = 0;
}
@@ -190,13 +190,13 @@ namespace Qpid.Client.qms.failover
return _connectionDetails.GetBrokerInfo(_currentBrokerIndex);
}
- public void setBroker(BrokerInfo broker)
+ public void SetBroker(IBrokerInfo broker)
{
_connectionDetails.AddBrokerInfo(broker);
int index = _connectionDetails.GetAllBrokerInfos().IndexOf(broker);
- String serverRetries = broker.getOption(BrokerInfoConstants.OPTIONS_RETRY);
+ String serverRetries = broker.GetOption(BrokerInfoConstants.OPTIONS_RETRY);
if (serverRetries != null)
{
@@ -214,14 +214,14 @@ namespace Qpid.Client.qms.failover
_currentBrokerIndex = index;
}
- public void setRetries(int maxRetries)
+ public void SetRetries(int maxRetries)
{
_cycleRetries = maxRetries;
}
- public String methodName()
+ public String MethodName
{
- return "Cycle Servers";
+ get { return "Cycle Servers"; }
}
public override string ToString()
@@ -230,7 +230,7 @@ namespace Qpid.Client.qms.failover
sb.Append(GetType().Name).Append("\n");
- sb.Append("Broker count: ").Append(_connectionDetails.GetBrokerCount());
+ sb.Append("Broker count: ").Append(_connectionDetails.BrokerCount);
sb.Append("\ncurrent broker index: ").Append(_currentBrokerIndex);
sb.Append("\nCycle Retries: ").Append(_cycleRetries);
@@ -239,7 +239,7 @@ namespace Qpid.Client.qms.failover
sb.Append("\nCurrent Retry:").Append(_currentServerRetry);
sb.Append("\n");
- for(int i=0; i < _connectionDetails.GetBrokerCount() ; i++)
+ for(int i=0; i < _connectionDetails.BrokerCount ; i++)
{
if (i == _currentBrokerIndex)
{
diff --git a/dotnet/Qpid.Client/qms/failover/FailoverSingleServer.cs b/dotnet/Qpid.Client/qms/failover/FailoverSingleServer.cs
index be29429035..18907df3c2 100644
--- a/dotnet/Qpid.Client/qms/failover/FailoverSingleServer.cs
+++ b/dotnet/Qpid.Client/qms/failover/FailoverSingleServer.cs
@@ -20,9 +20,9 @@
*/
using System;
-namespace Qpid.Client.qms.failover
+namespace Qpid.Client.Qms.Failover
{
- public class FailoverSingleServer : FailoverMethod
+ public class FailoverSingleServer : IFailoverMethod
{
/** The default number of times to rety a conection to this server */
public const int DEFAULT_SERVER_RETRIES = 1;
@@ -30,7 +30,7 @@ namespace Qpid.Client.qms.failover
/**
* The details of the Single Server
*/
- private BrokerInfo _brokerDetail;
+ private IBrokerInfo _brokerDetail;
/**
* The number of times to retry connecting to the sever
@@ -43,11 +43,11 @@ namespace Qpid.Client.qms.failover
private int _currentRetries;
- public FailoverSingleServer(ConnectionInfo connectionDetails)
+ public FailoverSingleServer(IConnectionInfo connectionDetails)
{
- if (connectionDetails.GetBrokerCount() > 0)
+ if (connectionDetails.BrokerCount > 0)
{
- setBroker(connectionDetails.GetBrokerInfo(0));
+ SetBroker(connectionDetails.GetBrokerInfo(0));
}
else
{
@@ -55,32 +55,32 @@ namespace Qpid.Client.qms.failover
}
}
- public FailoverSingleServer(BrokerInfo brokerDetail)
+ public FailoverSingleServer(IBrokerInfo brokerDetail)
{
- setBroker(brokerDetail);
+ SetBroker(brokerDetail);
}
- public void reset()
+ public void Reset()
{
_currentRetries = -1;
}
- public bool failoverAllowed()
+ public bool FailoverAllowed()
{
return _currentRetries < _retries;
}
- public void attainedConnection()
+ public void AttainedConnection()
{
- reset();
+ Reset();
}
- public BrokerInfo GetCurrentBrokerInfo()
+ public IBrokerInfo GetCurrentBrokerInfo()
{
return _brokerDetail;
}
- public BrokerInfo getNextBrokerDetails()
+ public IBrokerInfo GetNextBrokerDetails()
{
if (_currentRetries == _retries)
{
@@ -97,7 +97,7 @@ namespace Qpid.Client.qms.failover
}
}
- public void setBroker(BrokerInfo broker)
+ public void SetBroker(IBrokerInfo broker)
{
if (broker == null)
{
@@ -105,7 +105,7 @@ namespace Qpid.Client.qms.failover
}
_brokerDetail = broker;
- String retries = broker.getOption(BrokerInfoConstants.OPTIONS_RETRY);
+ String retries = broker.GetOption(BrokerInfoConstants.OPTIONS_RETRY);
if (retries != null)
{
try
@@ -122,17 +122,17 @@ namespace Qpid.Client.qms.failover
_retries = DEFAULT_SERVER_RETRIES;
}
- reset();
+ Reset();
}
- public void setRetries(int retries)
+ public void SetRetries(int retries)
{
_retries = retries;
}
- public String methodName()
+ public String MethodName
{
- return "Single Server";
+ get { return "Single Server"; }
}
public String toString()