Fixed: Provider Status housekeeping

This commit is contained in:
Qstick
2017-10-29 17:32:57 -04:00
parent 492cf1b1bb
commit 0e1dfed8d7
10 changed files with 326 additions and 66 deletions
@@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Linq;
using NLog;
using NzbDrone.Core.Messaging.Events;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.ThingiProvider.Events;
namespace NzbDrone.Core.ThingiProvider.Status
@@ -21,17 +20,6 @@ namespace NzbDrone.Core.ThingiProvider.Status
where TProvider : IProvider
where TModel : ProviderStatusBase, new()
{
private static readonly int[] EscalationBackOffPeriods = {
0,
5 * 60,
15 * 60,
30 * 60,
60 * 60,
3 * 60 * 60,
6 * 60 * 60,
12 * 60 * 60,
24 * 60 * 60
};
protected readonly object _syncRoot = new object();
@@ -39,7 +27,7 @@ namespace NzbDrone.Core.ThingiProvider.Status
protected readonly IEventAggregator _eventAggregator;
protected readonly Logger _logger;
protected int MaximumEscalationLevel { get; set; } = EscalationBackOffPeriods.Length - 1;
protected int MaximumEscalationLevel { get; set; } = EscalationBackOff.Periods.Length - 1;
protected TimeSpan MinimumTimeSinceInitialFailure { get; set; } = TimeSpan.Zero;
public ProviderStatusServiceBase(IProviderStatusRepository<TModel> providerStatusRepository, IEventAggregator eventAggregator, Logger logger)
@@ -63,7 +51,7 @@ namespace NzbDrone.Core.ThingiProvider.Status
{
var level = Math.Min(MaximumEscalationLevel, status.EscalationLevel);
return TimeSpan.FromSeconds(EscalationBackOffPeriods[level]);
return TimeSpan.FromSeconds(EscalationBackOff.Periods[level]);
}
public virtual void RecordSuccess(int providerId)