Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>10.4.17</Version>
<Version>10.4.18</Version>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<Title>Live Integration</Title>
<Description>Live Integration</Description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Connectors;
using Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Logging;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Threading;

namespace Dynamicweb.Ecommerce.DynamicwebLiveIntegration.EndpointMonitoring
Expand All @@ -13,7 +12,7 @@ namespace Dynamicweb.Ecommerce.DynamicwebLiveIntegration.EndpointMonitoring
internal class EndpointMonitoringService
{
private static readonly ConcurrentDictionary<string, EndpointStatus> EndpointCollection = new ConcurrentDictionary<string, EndpointStatus>();
private static readonly List<string> EndpointsInPing = new List<string>();
private static readonly ConcurrentDictionary<string, string> EndpointsInPing = new ConcurrentDictionary<string, string>();
private static readonly ConcurrentDictionary<string, Timer> PingTimers = new ConcurrentDictionary<string, Timer>();

/// <summary>
Expand All @@ -26,7 +25,7 @@ public static bool IsStillValid(Settings settings, EndpointInfo endpoint, out bo
{
connectionAvailable = false;

if (EndpointsInPing.Contains(endpoint.Id))
if (EndpointsInPing.ContainsKey(endpoint.Id))
{
return true;
}
Expand Down Expand Up @@ -72,6 +71,7 @@ public static void Success(EndpointInfo endpoint)
PingTimers.TryRemove(endpoint.Id, out Timer timer);
timer?.Dispose();
}
EndpointsInPing.TryRemove(endpoint.Id, out _);
status.SetSuccess();
}

Expand All @@ -87,7 +87,7 @@ public static void Error(Settings settings, EndpointInfo endpoint)
status = new EndpointStatus();
EndpointCollection.TryAdd(url, status);
}
if (!EndpointsInPing.Contains(endpoint.Id) && !Environment.ExecutingContext.IsBackEnd())
if (!EndpointsInPing.ContainsKey(endpoint.Id) && !Environment.ExecutingContext.IsBackEnd())
{
PingEndpoint(settings, endpoint);
}
Expand Down Expand Up @@ -133,9 +133,9 @@ private static void PingEndpoint(Settings settings, EndpointInfo endpoint)
{
return;
}
if (!EndpointsInPing.Contains(endpoint.Id) && !PingTimers.ContainsKey(endpoint.Id))
if (!EndpointsInPing.ContainsKey(endpoint.Id) && !PingTimers.ContainsKey(endpoint.Id))
{
EndpointsInPing.Add(endpoint.Id);
EndpointsInPing.TryAdd(endpoint.Id, null);
var statusChecker = new EndpointMonitoringService();
var timer = new Timer(statusChecker.Ping, settings, 0, autoPingInterval.Value * 1000);
PingTimers.TryAdd(endpoint.Id, timer);
Expand All @@ -158,10 +158,7 @@ private void Ping(object stateInfo)
currentConnector = new WebServiceConnector(settings, logger);
endpoint = new EndpointInfo(settings.WebServiceURI);
}
if (EndpointsInPing.Contains(endpoint.Id))
{
EndpointsInPing.RemoveAll(e => e == endpoint.Id);
}
EndpointsInPing.TryRemove(endpoint.Id, out _);
currentConnector.IsWebServiceConnectionAvailable();
}
}
Expand Down
Loading