summaryrefslogtreecommitdiff
path: root/dotnet/Qpid.Client
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
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')
-rw-r--r--dotnet/Qpid.Client/Client/AMQConnection.cs30
-rw-r--r--dotnet/Qpid.Client/Client/AmqBrokerInfo.cs118
-rw-r--r--dotnet/Qpid.Client/Client/QpidConnectionInfo.cs92
-rw-r--r--dotnet/Qpid.Client/qms/BrokerInfo.cs31
-rw-r--r--dotnet/Qpid.Client/qms/ConnectionInfo.cs48
-rw-r--r--dotnet/Qpid.Client/qms/FailoverPolicy.cs50
-rw-r--r--dotnet/Qpid.Client/qms/UrlSyntaxException.cs2
-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
10 files changed, 242 insertions, 296 deletions
diff --git a/dotnet/Qpid.Client/Client/AMQConnection.cs b/dotnet/Qpid.Client/Client/AMQConnection.cs
index 3192b0018d..1a342f0b15 100644
--- a/dotnet/Qpid.Client/Client/AMQConnection.cs
+++ b/dotnet/Qpid.Client/Client/AMQConnection.cs
@@ -26,7 +26,7 @@ using System.Threading;
using log4net;
using Qpid.Client.Failover;
using Qpid.Client.Protocol;
-using Qpid.Client.qms;
+using Qpid.Client.Qms;
using Qpid.Client.State;
using Qpid.Client.Transport;
using Qpid.Client.Transport.Socket.Blocking;
@@ -40,7 +40,7 @@ namespace Qpid.Client
{
private static readonly ILog _log = LogManager.GetLogger(typeof(AMQConnection));
- ConnectionInfo _connectionInfo;
+ IConnectionInfo _connectionInfo;
private int _nextChannelId = 0;
// _Connected should be refactored with a suitable wait object.
@@ -121,7 +121,7 @@ namespace Qpid.Client
get { return _protocolWriter; }
}
- public AMQConnection(ConnectionInfo connectionInfo)
+ public AMQConnection(IConnectionInfo connectionInfo)
{
if (connectionInfo == null)
{
@@ -129,7 +129,7 @@ namespace Qpid.Client
}
_log.Info("ConnectionInfo: " + connectionInfo);
_connectionInfo = connectionInfo;
- _log.Info("password = " + _connectionInfo.GetPassword());
+ _log.Info("password = " + _connectionInfo.Password);
_failoverPolicy = new FailoverPolicy(connectionInfo);
// We are not currently connected.
@@ -140,7 +140,7 @@ namespace Qpid.Client
{
try
{
- BrokerInfo brokerInfo = _failoverPolicy.GetNextBrokerInfo();
+ IBrokerInfo brokerInfo = _failoverPolicy.GetNextBrokerInfo();
_log.Info("Connecting to " + brokerInfo);
MakeBrokerConnection(brokerInfo);
break;
@@ -220,12 +220,12 @@ namespace Qpid.Client
get
{
CheckNotClosed();
- return _connectionInfo.GetClientName();
+ return _connectionInfo.ClientName;
}
set
{
CheckNotClosed();
- _connectionInfo.SetClientName(value);
+ _connectionInfo.ClientName = value;
}
}
@@ -505,7 +505,7 @@ namespace Qpid.Client
{
get
{
- return _failoverPolicy.GetCurrentBrokerInfo().getHost();
+ return _failoverPolicy.GetCurrentBrokerInfo().Host;
}
}
@@ -513,7 +513,7 @@ namespace Qpid.Client
{
get
{
- return _failoverPolicy.GetCurrentBrokerInfo().getPort();
+ return _failoverPolicy.GetCurrentBrokerInfo().Port;
}
}
@@ -521,7 +521,7 @@ namespace Qpid.Client
{
get
{
- return _connectionInfo.GetUsername();
+ return _connectionInfo.Username;
}
}
@@ -529,7 +529,7 @@ namespace Qpid.Client
{
get
{
- return _connectionInfo.GetPassword();
+ return _connectionInfo.Password;
}
}
@@ -537,7 +537,7 @@ namespace Qpid.Client
{
get
{
- return _connectionInfo.GetVirtualHost();
+ return _connectionInfo.VirtualHost;
}
}
@@ -674,7 +674,7 @@ namespace Qpid.Client
public bool AttemptReconnection(String host, int port, bool useSSL)
{
- BrokerInfo bd = new AmqBrokerInfo("amqp", host, port, useSSL);
+ IBrokerInfo bd = new AmqBrokerInfo("amqp", host, port, useSSL);
_failoverPolicy.setBroker(bd);
@@ -691,7 +691,7 @@ namespace Qpid.Client
return false;
}
- private void MakeBrokerConnection(BrokerInfo brokerDetail)
+ private void MakeBrokerConnection(IBrokerInfo brokerDetail)
{
try
{
@@ -708,7 +708,7 @@ namespace Qpid.Client
_transport = LoadTransportFromAssembly(brokerDetail.getHost(), brokerDetail.getPort(), assemblyName, transportType);
*/
- _transport = new BlockingSocketTransport(brokerDetail.getHost(), brokerDetail.getPort(), this);
+ _transport = new BlockingSocketTransport(brokerDetail.Host, brokerDetail.Port, this);
// Connect.
_transport.Open();
diff --git a/dotnet/Qpid.Client/Client/AmqBrokerInfo.cs b/dotnet/Qpid.Client/Client/AmqBrokerInfo.cs
index 81a5f10647..f26756ccad 100644
--- a/dotnet/Qpid.Client/Client/AmqBrokerInfo.cs
+++ b/dotnet/Qpid.Client/Client/AmqBrokerInfo.cs
@@ -21,11 +21,11 @@
using System;
using System.Collections;
using System.Text;
-using Qpid.Client.qms;
+using Qpid.Client.Qms;
namespace Qpid.Client
{
- public class AmqBrokerInfo : BrokerInfo
+ public class AmqBrokerInfo : IBrokerInfo
{
public readonly string URL_FORMAT_EXAMPLE =
"<transport>://<hostname>[:<port Default=\""+BrokerInfoConstants.DEFAULT_PORT+"\">][?<option>='<value>'[,<option>='<value>']]";
@@ -90,10 +90,10 @@ namespace Qpid.Client
" In broker URL:'" + url + "' Format: " + URL_FORMAT_EXAMPLE, "");
}
- setTransport(transport);
+ Transport = transport;
String host = connection.Host;
- if (!host.Equals("default")) setHost(host);
+ if (!host.Equals("default")) Host = host;
int port = connection.Port;
@@ -130,7 +130,7 @@ namespace Qpid.Client
}
if (found)
{
- setPort(int.Parse(auth.Substring(start, end-start+1)));
+ Port = int.Parse(auth.Substring(start, end-start+1));
}
else
{
@@ -140,12 +140,12 @@ namespace Qpid.Client
}
else
{
- setPort(BrokerInfoConstants.DEFAULT_PORT);
+ Port = BrokerInfoConstants.DEFAULT_PORT;
}
}
else
{
- setPort(port);
+ Port = port;
}
String queryString = connection.Query;
@@ -178,70 +178,58 @@ namespace Qpid.Client
if (useSSL)
{
- setOption(BrokerInfoConstants.OPTIONS_SSL, "true");
+ SetOption(BrokerInfoConstants.OPTIONS_SSL, "true");
}
}
- public string getHost()
+ public string Host
{
- return _host;
+ get { return _host; }
+ set { _host = value; }
}
- public void setHost(string _host)
+ public int Port
{
- this._host = _host;
+ get { return _port; }
+ set { _port = value; }
}
- public int getPort()
+ public string Transport
{
- return _port;
+ get { return _transport; }
+ set { _transport = value; }
}
- public void setPort(int _port)
- {
- this._port = _port;
- }
-
- public string getTransport()
- {
- return _transport;
- }
-
- public void setTransport(string _transport)
- {
- this._transport = _transport;
- }
-
- public string getOption(string key)
+ public string GetOption(string key)
{
return (string)_options[key];
}
- public void setOption(string key, string value)
+ public void SetOption(string key, string value)
{
_options[key] = value;
}
- public long getTimeout()
+ public long Timeout
{
- if (_options.ContainsKey(BrokerInfoConstants.OPTIONS_CONNECT_TIMEOUT))
+ get
{
- try
- {
- return long.Parse((string)_options[BrokerInfoConstants.OPTIONS_CONNECT_TIMEOUT]);
- }
- catch (FormatException)
+ if ( _options.ContainsKey(BrokerInfoConstants.OPTIONS_CONNECT_TIMEOUT) )
{
- //Do nothing as we will use the default below.
+ try
+ {
+ return long.Parse(GetOption(BrokerInfoConstants.OPTIONS_CONNECT_TIMEOUT));
+ } catch ( FormatException )
+ {
+ //Do nothing as we will use the default below.
+ }
}
+ return BrokerInfoConstants.DEFAULT_CONNECT_TIMEOUT;
+ }
+ set
+ {
+ SetOption(BrokerInfoConstants.OPTIONS_CONNECT_TIMEOUT, value.ToString());
}
-
- return BrokerInfoConstants.DEFAULT_CONNECT_TIMEOUT;
- }
-
- public void setTimeout(long timeout)
- {
- setOption(BrokerInfoConstants.OPTIONS_CONNECT_TIMEOUT, timeout.ToString());
}
public override string ToString()
@@ -267,15 +255,15 @@ namespace Qpid.Client
public override bool Equals(object obj)
{
- if (!(obj is BrokerInfo))
+ if (!(obj is IBrokerInfo))
{
return false;
}
- BrokerInfo bd = (BrokerInfo) obj;
- return StringEqualsIgnoreCase(_host, bd.getHost()) &&
- _port == bd.getPort() &&
- _transport == bd.getTransport();
+ IBrokerInfo bd = (IBrokerInfo) obj;
+ return StringEqualsIgnoreCase(_host, bd.Host) &&
+ _port == bd.Port &&
+ _transport == bd.Transport;
}
public override int GetHashCode()
@@ -318,23 +306,25 @@ namespace Qpid.Client
// return optionsURL.tostring();
// }
- public bool useSSL()
+ public bool UseSSL
{
- // To be friendly to users we should be case insensitive.
- // or simply force users to conform to OPTIONS_SSL
- // todo make case insensitive by trying ssl Ssl sSl ssL SSl SsL sSL SSL
-
- if (_options.ContainsKey(BrokerInfoConstants.OPTIONS_SSL))
+ get
{
- return StringEqualsIgnoreCase((string)_options[BrokerInfoConstants.OPTIONS_SSL], "true");
- }
+ // To be friendly to users we should be case insensitive.
+ // or simply force users to conform to OPTIONS_SSL
+ // todo make case insensitive by trying ssl Ssl sSl ssL SSl SsL sSL SSL
- return false;
- }
+ if ( _options.ContainsKey(BrokerInfoConstants.OPTIONS_SSL) )
+ {
+ return StringEqualsIgnoreCase(GetOption(BrokerInfoConstants.OPTIONS_SSL), "true");
+ }
- public void useSSL(bool ssl)
- {
- setOption(BrokerInfoConstants.OPTIONS_SSL, ssl.ToString());
+ return false;
+ }
+ set
+ {
+ SetOption(BrokerInfoConstants.OPTIONS_SSL, value.ToString());
+ }
}
}
}
diff --git a/dotnet/Qpid.Client/Client/QpidConnectionInfo.cs b/dotnet/Qpid.Client/Client/QpidConnectionInfo.cs
index 7207253603..66bb549779 100644
--- a/dotnet/Qpid.Client/Client/QpidConnectionInfo.cs
+++ b/dotnet/Qpid.Client/Client/QpidConnectionInfo.cs
@@ -24,7 +24,7 @@ using System.Net;
using System.Text;
using System.Text.RegularExpressions;
using log4net;
-using Qpid.Client.qms;
+using Qpid.Client.Qms;
namespace Qpid.Client
{
@@ -192,10 +192,10 @@ namespace Qpid.Client
public class QpidConnectionUrl
{
- internal static ConnectionInfo FromUrl(string fullURL)
+ internal static IConnectionInfo FromUrl(string fullURL)
{
//_url = fullURL;
- ConnectionInfo connectionInfo = new QpidConnectionInfo();
+ IConnectionInfo connectionInfo = new QpidConnectionInfo();
// _options = new HashMap<String, String>();
@@ -216,7 +216,7 @@ namespace Qpid.Client
if (connection.Host != null && connection.Host.Length > 0 && !connection.Host.Equals("default"))
{
- connectionInfo.SetClientName(connection.Host);
+ connectionInfo.ClientName = connection.Host;
}
String userInfo = connection.UserInfo;
@@ -231,9 +231,9 @@ namespace Qpid.Client
}
String virtualHost = connection.AbsolutePath; // XXX: is AbsolutePath corrrect?
- if (virtualHost != null && (!virtualHost.Equals("")))
+ if (virtualHost != null && virtualHost.Length > 0)
{
- connectionInfo.SetVirtualHost(virtualHost);
+ connectionInfo.VirtualHost = virtualHost;
}
else
{
@@ -290,7 +290,7 @@ namespace Qpid.Client
}
}
- private static void parseUserInfo(String userinfo, string fullUrl, ConnectionInfo connectionInfo)
+ private static void parseUserInfo(String userinfo, string fullUrl, IConnectionInfo connectionInfo)
{
//user info = user:pass
@@ -303,12 +303,12 @@ namespace Qpid.Client
}
else
{
- connectionInfo.setUsername(userinfo.Substring(0, colonIndex));
- connectionInfo.SetPassword(userinfo.Substring(colonIndex + 1));
+ connectionInfo.Username = userinfo.Substring(0, colonIndex);
+ connectionInfo.Password = userinfo.Substring(colonIndex + 1);
}
}
- private static void processOptions(ConnectionInfo connectionInfo)
+ private static void processOptions(IConnectionInfo connectionInfo)
{
string brokerlist = connectionInfo.GetOption(ConnectionUrlConstants.OPTIONS_BROKERLIST);
if (brokerlist != null)
@@ -334,14 +334,14 @@ namespace Qpid.Client
if (methodIndex > -1)
{
- connectionInfo.SetFailoverMethod(failover.Substring(0, methodIndex));
+ connectionInfo.FailoverMethod = failover.Substring(0, methodIndex);
QpidConnectionInfo qpidConnectionInfo = (QpidConnectionInfo)connectionInfo;
URLHelper.parseOptions(qpidConnectionInfo.GetFailoverOptions(),
failover.Substring(methodIndex + 1));
}
else
{
- connectionInfo.SetFailoverMethod(failover);
+ connectionInfo.FailoverMethod = failover;
}
connectionInfo.SetOption(ConnectionUrlConstants.OPTIONS_FAILOVER, null);
@@ -349,14 +349,14 @@ namespace Qpid.Client
}
}
- internal static ConnectionInfo FromUri(Uri uri)
+ internal static IConnectionInfo FromUri(Uri uri)
{
return null; // FIXME
}
}
- public class QpidConnectionInfo : ConnectionInfo
+ public class QpidConnectionInfo : IConnectionInfo
{
string _username = "guest";
string _password = "guest";
@@ -378,7 +378,7 @@ namespace Qpid.Client
return _options;
}
- public static ConnectionInfo FromUrl(String url)
+ public static IConnectionInfo FromUrl(String url)
{
return QpidConnectionUrl.FromUrl(url);
}
@@ -386,7 +386,7 @@ namespace Qpid.Client
public string AsUrl()
{
string result = "amqp://";
- foreach (BrokerInfo info in _brokerInfos)
+ foreach (IBrokerInfo info in _brokerInfos)
{
result += info.ToString();
}
@@ -394,14 +394,10 @@ namespace Qpid.Client
}
- public string GetFailoverMethod()
+ public string FailoverMethod
{
- return _failoverMethod;
- }
-
- public void SetFailoverMethod(string failoverMethod)
- {
- _failoverMethod = failoverMethod;
+ get { return _failoverMethod; }
+ set { _failoverMethod = value; }
}
public string GetFailoverOption(string key)
@@ -409,17 +405,17 @@ namespace Qpid.Client
return (string)_failoverOptions[key];
}
- public int GetBrokerCount()
+ public int BrokerCount
{
- return _brokerInfos.Count;
+ get { return _brokerInfos.Count; }
}
- public BrokerInfo GetBrokerInfo(int index)
+ public IBrokerInfo GetBrokerInfo(int index)
{
- return (BrokerInfo)_brokerInfos[index];
+ return (IBrokerInfo)_brokerInfos[index];
}
- public void AddBrokerInfo(BrokerInfo brokerInfo)
+ public void AddBrokerInfo(IBrokerInfo brokerInfo)
{
if (!_brokerInfos.Contains(brokerInfo))
{
@@ -432,44 +428,28 @@ namespace Qpid.Client
return _brokerInfos;
}
- public string GetClientName()
- {
- return _clientName;
- }
-
- public void SetClientName(string clientName)
- {
- _clientName = clientName;
- }
-
- public string GetUsername()
- {
- return _username;
- }
-
- public void setUsername(string username)
- {
- _username = username;
- }
-
- public string GetPassword()
+ public string ClientName
{
- return _password;
+ get { return _clientName; }
+ set { _clientName = value; }
}
- public void SetPassword(string password)
+ public string Username
{
- _password = password;
+ get { return _username; }
+ set { _username = value; }
}
- public string GetVirtualHost()
+ public string Password
{
- return _virtualHost;
+ get { return _password; }
+ set { _password = value; }
}
- public void SetVirtualHost(string virtualHost)
+ public string VirtualHost
{
- _virtualHost = virtualHost;
+ get { return _virtualHost; }
+ set { _virtualHost = value; }
}
public string GetOption(string key)
diff --git a/dotnet/Qpid.Client/qms/BrokerInfo.cs b/dotnet/Qpid.Client/qms/BrokerInfo.cs
index 6fe02403b7..69cd1bdbf7 100644
--- a/dotnet/Qpid.Client/qms/BrokerInfo.cs
+++ b/dotnet/Qpid.Client/qms/BrokerInfo.cs
@@ -20,7 +20,7 @@
*/
using System;
-namespace Qpid.Client.qms
+namespace Qpid.Client.Qms
{
/// <summary>
/// Know URL option names.
@@ -40,24 +40,15 @@ namespace Qpid.Client.qms
public const long DEFAULT_CONNECT_TIMEOUT = 30000L;
}
- public interface BrokerInfo
+ public interface IBrokerInfo
{
- String getHost();
- void setHost(string host);
-
- int getPort();
- void setPort(int port);
-
- String getTransport();
- void setTransport(string transport);
-
- bool useSSL();
- void useSSL(bool ssl);
-
- String getOption(string key);
- void setOption(string key, string value);
-
- long getTimeout();
- void setTimeout(long timeout);
+ string Host { get; set; }
+ int Port { get; set; }
+ string Transport { get; set; }
+ bool UseSSL { get; set; }
+ long Timeout { get; set; }
+
+ String GetOption(string key);
+ void SetOption(string key, string value);
}
-} \ No newline at end of file
+}
diff --git a/dotnet/Qpid.Client/qms/ConnectionInfo.cs b/dotnet/Qpid.Client/qms/ConnectionInfo.cs
index 8ac11ec1ab..4bdf8f4d7c 100644
--- a/dotnet/Qpid.Client/qms/ConnectionInfo.cs
+++ b/dotnet/Qpid.Client/qms/ConnectionInfo.cs
@@ -20,7 +20,7 @@
*/
using System.Collections;
-namespace Qpid.Client.qms
+namespace Qpid.Client.Qms
{
class ConnectionUrlConstants
{
@@ -31,45 +31,31 @@ namespace Qpid.Client.qms
public const string OPTIONS_SSL = "ssl";
}
- /**
- Connection URL format
- amqp://[user:pass@][clientid]/virtualhost?brokerlist='tcp://host:port?option=\'value\'&option=\'value\';vm://:3/virtualpath?option=\'value\''&failover='method?option=\'value\'&option='value''"
- Options are of course optional except for requiring a single broker in the broker list.
- The option seperator is defined to be either '&' or ','
- */
- public interface ConnectionInfo
+ /// <summary>
+ /// Connection URL format
+ /// amqp://[user:pass@][clientid]/virtualhost?brokerlist='tcp://host:port?option=\'value\'&amp;option=\'value\';vm://:3/virtualpath?option=\'value\''&amp;failover='method?option=\'value\'&amp;option='value''"
+ /// Options are of course optional except for requiring a single broker in the broker list.
+ /// The option seperator is defined to be either '&amp;' or ','
+ /// </summary>
+ public interface IConnectionInfo
{
string AsUrl();
- string GetFailoverMethod();
- void SetFailoverMethod(string failoverMethod);
-
+ string FailoverMethod { get; set; }
+ string ClientName { get; set; }
+ string Username { get; set; }
+ string Password { get; set; }
+ string VirtualHost { get; set; }
string GetFailoverOption(string key);
+
+ int BrokerCount { get; }
- int GetBrokerCount();
-
- BrokerInfo GetBrokerInfo(int index);
+ IBrokerInfo GetBrokerInfo(int index);
- void AddBrokerInfo(BrokerInfo broker);
+ void AddBrokerInfo(IBrokerInfo broker);
IList GetAllBrokerInfos();
- string GetClientName();
-
- void SetClientName(string clientName);
-
- string GetUsername();
-
- void setUsername(string username);
-
- string GetPassword();
-
- void SetPassword(string password);
-
- string GetVirtualHost();
-
- void SetVirtualHost(string virtualHost);
-
string GetOption(string key);
void SetOption(string key, string value);
diff --git a/dotnet/Qpid.Client/qms/FailoverPolicy.cs b/dotnet/Qpid.Client/qms/FailoverPolicy.cs
index 5d3eceb58e..99ab3dc66e 100644
--- a/dotnet/Qpid.Client/qms/FailoverPolicy.cs
+++ b/dotnet/Qpid.Client/qms/FailoverPolicy.cs
@@ -21,9 +21,9 @@
using System;
using System.Text;
using log4net;
-using Qpid.Client.qms.failover;
+using Qpid.Client.Qms.Failover;
-namespace Qpid.Client.qms
+namespace Qpid.Client.Qms
{
public class FailoverPolicy
{
@@ -34,7 +34,7 @@ namespace Qpid.Client.qms
private const long DEFAULT_METHOD_TIMEOUT = 1 * MINUTE;
private const long DEFAULT_FAILOVER_TIMEOUT = 4 * MINUTE;
- private FailoverMethod[] _methods = new FailoverMethod[1];
+ private IFailoverMethod[] _methods = new IFailoverMethod[1];
private int _currentMethod;
@@ -47,18 +47,18 @@ namespace Qpid.Client.qms
private long _lastMethodTime;
private long _lastFailTime;
- public FailoverPolicy(ConnectionInfo connectionInfo)
+ public FailoverPolicy(IConnectionInfo connectionInfo)
{
- FailoverMethod method;
+ IFailoverMethod method;
//todo This should be integrated in to the connection url when it supports
// multiple strategies.
_methodsRetries = 0;
- if (connectionInfo.GetFailoverMethod() == null)
+ if (connectionInfo.FailoverMethod == null)
{
- if (connectionInfo.GetBrokerCount() > 1)
+ if (connectionInfo.BrokerCount > 1)
{
method = new FailoverRoundRobin(connectionInfo);
}
@@ -69,7 +69,7 @@ namespace Qpid.Client.qms
}
else
{
- string failoverMethod = connectionInfo.GetFailoverMethod();
+ string failoverMethod = connectionInfo.FailoverMethod;
/*
if (failoverMethod.equals(FailoverMethod.RANDOM))
@@ -110,11 +110,11 @@ namespace Qpid.Client.qms
_methods[_currentMethod] = method;
}
- public FailoverPolicy(FailoverMethod method) : this(method, 0)
+ public FailoverPolicy(IFailoverMethod method) : this(method, 0)
{
}
- public FailoverPolicy(FailoverMethod method, int retries)
+ public FailoverPolicy(IFailoverMethod method, int retries)
{
_methodsRetries = retries;
@@ -169,7 +169,7 @@ namespace Qpid.Client.qms
}
- if (_methods[_currentMethod].failoverAllowed())
+ if (_methods[_currentMethod].FailoverAllowed())
{
failoverAllowed = true;
}
@@ -178,7 +178,7 @@ namespace Qpid.Client.qms
if (_currentMethod < (_methods.Length - 1))
{
nextMethod();
- _logger.Info("Changing method to " + _methods[_currentMethod].methodName());
+ _logger.Info("Changing method to " + _methods[_currentMethod].MethodName);
return FailoverAllowed();
}
else
@@ -200,7 +200,7 @@ namespace Qpid.Client.qms
if (_currentMethod < (_methods.Length - 1))
{
_currentMethod++;
- _methods[_currentMethod].reset();
+ _methods[_currentMethod].Reset();
return true;
}
else
@@ -217,8 +217,8 @@ namespace Qpid.Client.qms
_currentMethod = 0;
- _logger.Info("Retrying methods starting with " + _methods[_currentMethod].methodName());
- _methods[_currentMethod].reset();
+ _logger.Info("Retrying methods starting with " + _methods[_currentMethod].MethodName);
+ _methods[_currentMethod].Reset();
return FailoverAllowed();
}
else
@@ -235,30 +235,30 @@ namespace Qpid.Client.qms
{
_currentRetry = 0;
- _methods[_currentMethod].attainedConnection();
+ _methods[_currentMethod].AttainedConnection();
_timing = false;
}
- public BrokerInfo GetCurrentBrokerInfo()
+ public IBrokerInfo GetCurrentBrokerInfo()
{
return _methods[_currentMethod].GetCurrentBrokerInfo();
}
- public BrokerInfo GetNextBrokerInfo()
+ public IBrokerInfo GetNextBrokerInfo()
{
- return _methods[_currentMethod].getNextBrokerDetails();
+ return _methods[_currentMethod].GetNextBrokerDetails();
}
- public void setBroker(BrokerInfo broker)
+ public void setBroker(IBrokerInfo broker)
{
- _methods[_currentMethod].setBroker(broker);
+ _methods[_currentMethod].SetBroker(broker);
}
- public void addMethod(FailoverMethod method)
+ public void addMethod(IFailoverMethod method)
{
int len = _methods.Length + 1;
- FailoverMethod[] newMethods = new FailoverMethod[len];
+ IFailoverMethod[] newMethods = new IFailoverMethod[len];
_methods.CopyTo(newMethods, 0);
// System.arraycopy(_methods, 0, newMethods, 0, _methods.length);
int index = len - 1;
@@ -271,7 +271,7 @@ namespace Qpid.Client.qms
_methodsRetries = retries;
}
- public FailoverMethod getCurrentMethod()
+ public IFailoverMethod getCurrentMethod()
{
if (_currentMethod >= 0 && _currentMethod < (_methods.Length - 1))
{
@@ -312,4 +312,4 @@ namespace Qpid.Client.qms
return sb.ToString();
}
}
-} \ No newline at end of file
+}
diff --git a/dotnet/Qpid.Client/qms/UrlSyntaxException.cs b/dotnet/Qpid.Client/qms/UrlSyntaxException.cs
index e6da62a829..dc0c06c22f 100644
--- a/dotnet/Qpid.Client/qms/UrlSyntaxException.cs
+++ b/dotnet/Qpid.Client/qms/UrlSyntaxException.cs
@@ -22,7 +22,7 @@ using System;
using System.Runtime.Serialization;
using System.Text;
-namespace Qpid.Client.qms
+namespace Qpid.Client.Qms
{
[Serializable]
public class UrlSyntaxException : UriFormatException
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()