diff options
Diffstat (limited to 'dotnet/Qpid.Client/qms')
| -rw-r--r-- | dotnet/Qpid.Client/qms/BrokerInfo.cs | 31 | ||||
| -rw-r--r-- | dotnet/Qpid.Client/qms/ConnectionInfo.cs | 48 | ||||
| -rw-r--r-- | dotnet/Qpid.Client/qms/FailoverPolicy.cs | 50 | ||||
| -rw-r--r-- | dotnet/Qpid.Client/qms/UrlSyntaxException.cs | 2 | ||||
| -rw-r--r-- | dotnet/Qpid.Client/qms/failover/FailoverMethod.cs | 81 | ||||
| -rw-r--r-- | dotnet/Qpid.Client/qms/failover/FailoverRoundRobin.cs | 46 | ||||
| -rw-r--r-- | dotnet/Qpid.Client/qms/failover/FailoverSingleServer.cs | 40 |
7 files changed, 137 insertions, 161 deletions
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\'&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 ',' + /// </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() |
