Harden ACC installer update and endpoint performance
This commit is contained in:
@@ -120,7 +120,15 @@ namespace BizTalkCheckmkPulse
|
||||
|
||||
try
|
||||
{
|
||||
foreach (var probeResult in ProbeAllAsync(activeEntries).GetAwaiter().GetResult())
|
||||
var probeStopwatch = Stopwatch.StartNew();
|
||||
var probeResults = ProbeAllAsync(activeEntries).GetAwaiter().GetResult();
|
||||
probeStopwatch.Stop();
|
||||
state.ProbeDurationMilliseconds = probeStopwatch.ElapsedMilliseconds;
|
||||
state.UniqueTargets = activeEntries
|
||||
.Select(TargetKey)
|
||||
.Distinct(StringComparer.OrdinalIgnoreCase)
|
||||
.Count();
|
||||
foreach (var probeResult in probeResults)
|
||||
{
|
||||
state.Results.Add(probeResult);
|
||||
if (!probeResult.Available)
|
||||
@@ -192,10 +200,9 @@ namespace BizTalkCheckmkPulse
|
||||
{
|
||||
var catalog = SynchronizeCatalog(existing, candidates, synchronizedUtc);
|
||||
catalog.EnvironmentName = _options.EnvironmentName ?? string.Empty;
|
||||
if (catalog.Entries.Count > _options.EndpointMaxCount
|
||||
|| catalog.ActiveCandidates > _options.EndpointMaxCount)
|
||||
if (catalog.Entries.Count > _options.EndpointMaxCount)
|
||||
{
|
||||
throw new InvalidDataException("Discovered endpoint candidates exceed EndpointMaxCount.");
|
||||
throw new InvalidDataException("Probeable endpoints exceed EndpointMaxCount.");
|
||||
}
|
||||
|
||||
return catalog;
|
||||
@@ -221,7 +228,7 @@ namespace BizTalkCheckmkPulse
|
||||
private async Task<IReadOnlyCollection<EndpointProbeResult>> ProbeAllAsync(EndpointCatalogEntry[] endpoints)
|
||||
{
|
||||
var unique = endpoints
|
||||
.GroupBy(x => x.Protocol.ToUpperInvariant() + "|" + x.Host.ToUpperInvariant() + "|" + x.Port)
|
||||
.GroupBy(TargetKey, StringComparer.OrdinalIgnoreCase)
|
||||
.ToArray();
|
||||
var outcomes = new Dictionary<string, NetworkOutcome>(StringComparer.OrdinalIgnoreCase);
|
||||
using (var gate = new SemaphoreSlim(_options.EndpointProbeMaxConcurrency))
|
||||
@@ -248,7 +255,7 @@ namespace BizTalkCheckmkPulse
|
||||
|
||||
return endpoints.Select(endpoint =>
|
||||
{
|
||||
var key = endpoint.Protocol.ToUpperInvariant() + "|" + endpoint.Host.ToUpperInvariant() + "|" + endpoint.Port;
|
||||
var key = TargetKey(endpoint);
|
||||
var outcome = outcomes[key];
|
||||
return new EndpointProbeResult
|
||||
{
|
||||
@@ -260,6 +267,28 @@ namespace BizTalkCheckmkPulse
|
||||
}).ToArray();
|
||||
}
|
||||
|
||||
internal static long CalculateWorstCaseProbeMilliseconds(int targetCount, int concurrency, int timeoutMilliseconds)
|
||||
{
|
||||
if (targetCount <= 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (concurrency <= 0 || timeoutMilliseconds <= 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("concurrency");
|
||||
}
|
||||
|
||||
return ((targetCount + concurrency - 1L) / concurrency) * timeoutMilliseconds;
|
||||
}
|
||||
|
||||
private static string TargetKey(EndpointCatalogEntry endpoint)
|
||||
{
|
||||
return endpoint.Protocol.ToUpperInvariant()
|
||||
+ "|" + endpoint.Host.ToUpperInvariant()
|
||||
+ "|" + endpoint.Port;
|
||||
}
|
||||
|
||||
private async Task<NetworkOutcome> ProbeOneAsync(EndpointCatalogEntry endpoint)
|
||||
{
|
||||
return string.Equals(endpoint.Protocol, "UDP", StringComparison.OrdinalIgnoreCase)
|
||||
|
||||
Reference in New Issue
Block a user