Clean up and implement some outstanding todo work
diff --git a/src/Proton.Client/Client/Implementation/ClientConversionSupport.cs b/src/Proton.Client/Client/Implementation/ClientConversionSupport.cs
index 20e6e27..0300a0b 100644
--- a/src/Proton.Client/Client/Implementation/ClientConversionSupport.cs
+++ b/src/Proton.Client/Client/Implementation/ClientConversionSupport.cs
@@ -23,7 +23,6 @@
namespace Apache.Qpid.Proton.Client.Implementation
{
- // TODO
/// <summary>
/// Conversion utilities useful for multiple client operations.
/// </summary>
diff --git a/src/Proton.Client/Client/Implementation/ClientRedirect.cs b/src/Proton.Client/Client/Implementation/ClientRedirect.cs
index fc08185..31a625c 100644
--- a/src/Proton.Client/Client/Implementation/ClientRedirect.cs
+++ b/src/Proton.Client/Client/Implementation/ClientRedirect.cs
@@ -18,6 +18,7 @@
using System;
using System.Collections.Generic;
using System.IO;
+using Apache.Qpid.Proton.Logging;
using Apache.Qpid.Proton.Types;
namespace Apache.Qpid.Proton.Client.Implementation
@@ -28,6 +29,8 @@
/// </summary>
public sealed class ClientRedirect
{
+ private static IProtonLogger LOG = ProtonLoggerFactory.GetLogger<ClientRedirect>();
+
private readonly Dictionary<Symbol, object> redirect;
internal ClientRedirect(IEnumerable<KeyValuePair<Symbol, object>> redirect)
@@ -61,7 +64,7 @@
throw new IOException("Redirection information contained invalid port.");
}
- // TODO LOG.trace("Redirect issued host and port as follows: {}:{}", networkHost, networkPort);
+ LOG.Trace("Redirect issued host and port as follows: {0}:{1}", networkHost, networkPort);
return this;
}
diff --git a/src/Proton.Client/Client/Utilities/ReconnectLocationPool.cs b/src/Proton.Client/Client/Utilities/ReconnectLocationPool.cs
index fa5d5ec..c1f1206 100644
--- a/src/Proton.Client/Client/Utilities/ReconnectLocationPool.cs
+++ b/src/Proton.Client/Client/Utilities/ReconnectLocationPool.cs
@@ -17,12 +17,14 @@
using System;
using System.Collections.Generic;
+using System.Linq;
+using Apache.Qpid.Proton.Utilities;
namespace Apache.Qpid.Proton.Client.Utilities
{
public sealed class ReconnectLocationPool
{
- private readonly LinkedList<ReconnectLocation> entries = new LinkedList<ReconnectLocation>();
+ private readonly ArrayDeque<ReconnectLocation> entries = new ArrayDeque<ReconnectLocation>();
/// <summary>
/// Create a default empty reconnect location pool
@@ -41,7 +43,7 @@
{
foreach (ReconnectLocation item in locations)
{
- entries.AddLast(item);
+ entries.EnqueueBack(item);
}
}
}
@@ -87,9 +89,8 @@
{
if (entries.Count > 0)
{
- ReconnectLocation entry = entries.First.Value;
- entries.RemoveFirst();
- entries.AddLast(entry);
+ ReconnectLocation entry = entries.Dequeue();
+ entries.Enqueue(entry);
return entry;
}
@@ -107,7 +108,23 @@
{
lock (entries)
{
- // TODO
+ Random rand = new Random();
+ int n = entries.Count;
+ ReconnectLocation[] pool = entries.ToArray();
+ entries.Clear();
+
+ while (n > 1)
+ {
+ int k = rand.Next(n--);
+ ReconnectLocation temp = pool[n];
+ pool[n] = pool[k];
+ pool[k] = temp;
+ }
+
+ foreach(ReconnectLocation location in pool)
+ {
+ entries.Enqueue(location);
+ }
}
}
@@ -122,7 +139,7 @@
{
if (!entries.Contains(location))
{
- entries.AddLast(location);
+ entries.Enqueue(location);
}
}
@@ -142,7 +159,7 @@
{
if (!entries.Contains(location))
{
- entries.AddLast(location);
+ entries.Enqueue(location);
}
}
}
@@ -161,7 +178,7 @@
{
if (!entries.Contains(location))
{
- entries.AddFirst(location);
+ entries.EnqueueFront(location);
}
}
diff --git a/src/Proton/Engine/Implementation/ProtonEngine.cs b/src/Proton/Engine/Implementation/ProtonEngine.cs
index b9ab4a3..19d4a69 100644
--- a/src/Proton/Engine/Implementation/ProtonEngine.cs
+++ b/src/Proton/Engine/Implementation/ProtonEngine.cs
@@ -516,7 +516,7 @@
if (connection.ConnectionState == ConnectionState.Active && !IsShutdown)
{
// Using nano time since it is not related to the wall clock, which may change
- long now = 0; // TODO Tick TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
+ long now = Environment.TickCount64;
try
{