summaryrefslogtreecommitdiff
path: root/dotnet/Qpid.Client/qms
diff options
context:
space:
mode:
authorSteven Shaw <steshaw@apache.org>2006-12-04 16:35:07 +0000
committerSteven Shaw <steshaw@apache.org>2006-12-04 16:35:07 +0000
commit9bbc2fb73926209434894bdb6b8f74a02e1d5fd7 (patch)
tree68c1b51d963aa8b4cd92dade264fee12aa367971 /dotnet/Qpid.Client/qms
parentbfe3152312b1a6cd89fadd3f1c23e8bd37e1226d (diff)
downloadqpid-python-9bbc2fb73926209434894bdb6b8f74a02e1d5fd7.tar.gz
QPID-153 Initial port of URL parsing from Java client. Due to .NET Uri parser must support "host" name. Use "default" when you don't want to really supply one.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@482237 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'dotnet/Qpid.Client/qms')
-rw-r--r--dotnet/Qpid.Client/qms/BrokerInfo.cs2
-rw-r--r--dotnet/Qpid.Client/qms/ConnectionInfo.cs25
-rw-r--r--dotnet/Qpid.Client/qms/FailoverPolicy.cs6
-rw-r--r--dotnet/Qpid.Client/qms/UrlSyntaxException.cs116
-rw-r--r--dotnet/Qpid.Client/qms/failover/FailoverRoundRobin.cs36
-rw-r--r--dotnet/Qpid.Client/qms/failover/FailoverSingleServer.cs6
6 files changed, 154 insertions, 37 deletions
diff --git a/dotnet/Qpid.Client/qms/BrokerInfo.cs b/dotnet/Qpid.Client/qms/BrokerInfo.cs
index dd0504968e..6fe02403b7 100644
--- a/dotnet/Qpid.Client/qms/BrokerInfo.cs
+++ b/dotnet/Qpid.Client/qms/BrokerInfo.cs
@@ -26,7 +26,7 @@ namespace Qpid.Client.qms
/// Know URL option names.
/// <seealso cref="ConnectionInfo"/>
/// </summary>
- public class BrokerDetailsConstants
+ public class BrokerInfoConstants
{
public const String OPTIONS_RETRY = "retries";
public const String OPTIONS_SSL = ConnectionUrlConstants.OPTIONS_SSL;
diff --git a/dotnet/Qpid.Client/qms/ConnectionInfo.cs b/dotnet/Qpid.Client/qms/ConnectionInfo.cs
index 1d099daa3e..8ac11ec1ab 100644
--- a/dotnet/Qpid.Client/qms/ConnectionInfo.cs
+++ b/dotnet/Qpid.Client/qms/ConnectionInfo.cs
@@ -39,15 +39,16 @@ namespace Qpid.Client.qms
*/
public interface ConnectionInfo
{
- string asUrl();
+ string AsUrl();
- string getFailoverMethod();
+ string GetFailoverMethod();
+ void SetFailoverMethod(string failoverMethod);
- string getFailoverOption(string key);
+ string GetFailoverOption(string key);
- int getBrokerCount();
+ int GetBrokerCount();
- BrokerInfo GetBrokerDetails(int index);
+ BrokerInfo GetBrokerInfo(int index);
void AddBrokerInfo(BrokerInfo broker);
@@ -57,20 +58,20 @@ namespace Qpid.Client.qms
void SetClientName(string clientName);
- string getUsername();
+ string GetUsername();
void setUsername(string username);
- string getPassword();
+ string GetPassword();
- void setPassword(string password);
+ void SetPassword(string password);
- string getVirtualHost();
+ string GetVirtualHost();
- void setVirtualHost(string virtualHost);
+ void SetVirtualHost(string virtualHost);
- string getOption(string key);
+ string GetOption(string key);
- void setOption(string key, string value);
+ void SetOption(string key, string value);
}
}
diff --git a/dotnet/Qpid.Client/qms/FailoverPolicy.cs b/dotnet/Qpid.Client/qms/FailoverPolicy.cs
index 15d52491df..5d3eceb58e 100644
--- a/dotnet/Qpid.Client/qms/FailoverPolicy.cs
+++ b/dotnet/Qpid.Client/qms/FailoverPolicy.cs
@@ -56,9 +56,9 @@ namespace Qpid.Client.qms
_methodsRetries = 0;
- if (connectionInfo.getFailoverMethod() == null)
+ if (connectionInfo.GetFailoverMethod() == null)
{
- if (connectionInfo.getBrokerCount() > 1)
+ if (connectionInfo.GetBrokerCount() > 1)
{
method = new FailoverRoundRobin(connectionInfo);
}
@@ -69,7 +69,7 @@ namespace Qpid.Client.qms
}
else
{
- string failoverMethod = connectionInfo.getFailoverMethod();
+ string failoverMethod = connectionInfo.GetFailoverMethod();
/*
if (failoverMethod.equals(FailoverMethod.RANDOM))
diff --git a/dotnet/Qpid.Client/qms/UrlSyntaxException.cs b/dotnet/Qpid.Client/qms/UrlSyntaxException.cs
new file mode 100644
index 0000000000..f7aaf56085
--- /dev/null
+++ b/dotnet/Qpid.Client/qms/UrlSyntaxException.cs
@@ -0,0 +1,116 @@
+/*
+ *
+ * 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.
+ *
+ */
+using System;
+using System.Text;
+
+namespace Qpid.Client.qms
+{
+ public class UrlSyntaxException : UriFormatException
+ {
+ private string _url;
+ private int _index;
+ private int _length;
+
+ public int GetIndex()
+ {
+ return _index;
+ }
+
+ public UrlSyntaxException(String input, String reason)
+ : this(input, reason, -1)
+ {
+ }
+
+ private UrlSyntaxException(string input, string reason, int index)
+ :
+ this(input, reason, index, input.Length)
+ {
+ }
+
+ public UrlSyntaxException(String url, String error, int index, int length)
+ : base(error)
+ {
+ _url = url;
+ _index = index;
+ _length = length;
+ }
+
+ private static String getPositionString(int index, int length)
+ {
+ StringBuilder sb = new StringBuilder(index + 1);
+
+ for (int i = 0; i < index; i++)
+ {
+ sb.Append(" ");
+ }
+
+ if (length > -1)
+ {
+ for (int i = 0; i < length; i++)
+ {
+ sb.Append('^');
+ }
+ }
+
+ return sb.ToString();
+ }
+
+
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder();
+
+// sb.Append(getReason());
+
+ if (_index > -1)
+ {
+ if (_length != -1)
+ {
+ sb.Append(" between indicies ");
+ sb.Append(_index);
+ sb.Append(" and ");
+ sb.Append(_length);
+ }
+ else
+ {
+ sb.Append(" at index ");
+ sb.Append(_index);
+ }
+ }
+
+ sb.Append(" ");
+ if (_index != -1)
+ {
+ sb.Append("\n");
+ }
+
+ sb.Append(_url);
+
+ if (_index != -1)
+ {
+ sb.Append("\n");
+ sb.Append(getPositionString(_index, _length));
+ }
+
+ return sb.ToString();
+ }
+ }
+}
diff --git a/dotnet/Qpid.Client/qms/failover/FailoverRoundRobin.cs b/dotnet/Qpid.Client/qms/failover/FailoverRoundRobin.cs
index c0e832ce21..aac16a40fa 100644
--- a/dotnet/Qpid.Client/qms/failover/FailoverRoundRobin.cs
+++ b/dotnet/Qpid.Client/qms/failover/FailoverRoundRobin.cs
@@ -65,7 +65,7 @@ namespace Qpid.Client.qms.failover
public FailoverRoundRobin(ConnectionInfo connectionDetails)
{
- if (!(connectionDetails.getBrokerCount() > 0))
+ if (!(connectionDetails.GetBrokerCount() > 0))
{
throw new ArgumentException("At least one broker details must be specified.");
}
@@ -75,7 +75,7 @@ namespace Qpid.Client.qms.failover
//There is no current broker at startup so set it to -1.
_currentBrokerIndex = -1;
- String cycleRetries = _connectionDetails.getFailoverOption(ConnectionUrlConstants.OPTIONS_FAILOVER_CYCLE);
+ String cycleRetries = _connectionDetails.GetFailoverOption(ConnectionUrlConstants.OPTIONS_FAILOVER_CYCLE);
if (cycleRetries != null)
{
@@ -106,7 +106,7 @@ namespace Qpid.Client.qms.failover
{
return ((_currentCycleRetries < _cycleRetries)
|| (_currentServerRetry < _serverRetries)
- || (_currentBrokerIndex < (_connectionDetails.getBrokerCount() - 1)));
+ || (_currentBrokerIndex < (_connectionDetails.GetBrokerCount() - 1)));
}
public void attainedConnection()
@@ -122,12 +122,12 @@ namespace Qpid.Client.qms.failover
return null;
}
- return _connectionDetails.GetBrokerDetails(_currentBrokerIndex);
+ return _connectionDetails.GetBrokerInfo(_currentBrokerIndex);
}
public BrokerInfo getNextBrokerDetails()
{
- if (_currentBrokerIndex == (_connectionDetails.getBrokerCount() - 1))
+ if (_currentBrokerIndex == (_connectionDetails.GetBrokerCount() - 1))
{
if (_currentServerRetry < _serverRetries)
{
@@ -135,13 +135,13 @@ namespace Qpid.Client.qms.failover
{
_currentBrokerIndex = 0;
- setBroker(_connectionDetails.GetBrokerDetails(_currentBrokerIndex ));
+ setBroker(_connectionDetails.GetBrokerInfo(_currentBrokerIndex ));
- _logger.Info("First Run using " + _connectionDetails.GetBrokerDetails(_currentBrokerIndex));
+ _logger.Info("First Run using " + _connectionDetails.GetBrokerInfo(_currentBrokerIndex));
}
else
{
- _logger.Info("Retrying " + _connectionDetails.GetBrokerDetails(_currentBrokerIndex));
+ _logger.Info("Retrying " + _connectionDetails.GetBrokerInfo(_currentBrokerIndex));
}
_currentServerRetry++;
@@ -152,7 +152,7 @@ namespace Qpid.Client.qms.failover
//failed to connect to first broker
_currentBrokerIndex = 0;
- setBroker(_connectionDetails.GetBrokerDetails(_currentBrokerIndex ));
+ setBroker(_connectionDetails.GetBrokerInfo(_currentBrokerIndex ));
// This is zero rather than -1 as we are already retrieving the details.
_currentServerRetry = 0;
@@ -167,13 +167,13 @@ namespace Qpid.Client.qms.failover
{
_currentBrokerIndex = 0;
- setBroker(_connectionDetails.GetBrokerDetails(_currentBrokerIndex ));
+ setBroker(_connectionDetails.GetBrokerInfo(_currentBrokerIndex ));
- _logger.Info("First Run using " + _connectionDetails.GetBrokerDetails(_currentBrokerIndex));
+ _logger.Info("First Run using " + _connectionDetails.GetBrokerInfo(_currentBrokerIndex));
}
else
{
- _logger.Info("Retrying " + _connectionDetails.GetBrokerDetails(_currentBrokerIndex));
+ _logger.Info("Retrying " + _connectionDetails.GetBrokerInfo(_currentBrokerIndex));
}
_currentServerRetry++;
}
@@ -181,13 +181,13 @@ namespace Qpid.Client.qms.failover
{
_currentBrokerIndex++;
- setBroker(_connectionDetails.GetBrokerDetails(_currentBrokerIndex ));
+ setBroker(_connectionDetails.GetBrokerInfo(_currentBrokerIndex ));
// This is zero rather than -1 as we are already retrieving the details.
_currentServerRetry = 0;
}
}
- return _connectionDetails.GetBrokerDetails(_currentBrokerIndex);
+ return _connectionDetails.GetBrokerInfo(_currentBrokerIndex);
}
public void setBroker(BrokerInfo broker)
@@ -196,7 +196,7 @@ namespace Qpid.Client.qms.failover
int index = _connectionDetails.GetAllBrokerInfos().IndexOf(broker);
- String serverRetries = broker.getOption(BrokerDetailsConstants.OPTIONS_RETRY);
+ String serverRetries = broker.getOption(BrokerInfoConstants.OPTIONS_RETRY);
if (serverRetries != null)
{
@@ -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.GetBrokerCount());
sb.Append("\ncurrent broker index: ").Append(_currentBrokerIndex);
sb.Append("\nCycle Retries: ").Append(_cycleRetries);
@@ -239,13 +239,13 @@ 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.GetBrokerCount() ; i++)
{
if (i == _currentBrokerIndex)
{
sb.Append(">");
}
- sb.Append(_connectionDetails.GetBrokerDetails(i));
+ sb.Append(_connectionDetails.GetBrokerInfo(i));
sb.Append("\n");
}
diff --git a/dotnet/Qpid.Client/qms/failover/FailoverSingleServer.cs b/dotnet/Qpid.Client/qms/failover/FailoverSingleServer.cs
index 60e4c24987..be29429035 100644
--- a/dotnet/Qpid.Client/qms/failover/FailoverSingleServer.cs
+++ b/dotnet/Qpid.Client/qms/failover/FailoverSingleServer.cs
@@ -45,9 +45,9 @@ namespace Qpid.Client.qms.failover
public FailoverSingleServer(ConnectionInfo connectionDetails)
{
- if (connectionDetails.getBrokerCount() > 0)
+ if (connectionDetails.GetBrokerCount() > 0)
{
- setBroker(connectionDetails.GetBrokerDetails(0));
+ setBroker(connectionDetails.GetBrokerInfo(0));
}
else
{
@@ -105,7 +105,7 @@ namespace Qpid.Client.qms.failover
}
_brokerDetail = broker;
- String retries = broker.getOption(BrokerDetailsConstants.OPTIONS_RETRY);
+ String retries = broker.getOption(BrokerInfoConstants.OPTIONS_RETRY);
if (retries != null)
{
try