Пример #1
0
        public override HealthCheck Check()
        {
            var enabledProviders = _providerFactory.GetAvailableProviders();
            var backOffProviders = enabledProviders.Join(_providerStatusService.GetBlockedProviders(),
                                                         i => i.Definition.Id,
                                                         s => s.ProviderId,
                                                         (i, s) => new { Provider = i, Status = s })
                                   .Where(p => p.Status.InitialFailure.HasValue &&
                                          p.Status.InitialFailure.Value.After(
                                              DateTime.UtcNow.AddHours(-6)))
                                   .ToList();

            if (backOffProviders.Empty())
            {
                return(new HealthCheck(GetType()));
            }

            if (backOffProviders.Count == enabledProviders.Count)
            {
                return(new HealthCheck(GetType(),
                                       HealthCheckResult.Error,
                                       _localizationService.GetLocalizedString("IndexerStatusCheckAllClientMessage"),
                                       "#indexers-are-unavailable-due-to-failures"));
            }

            return(new HealthCheck(GetType(),
                                   HealthCheckResult.Warning,
                                   string.Format(_localizationService.GetLocalizedString("IndexerStatusCheckSingleClientMessage"),
                                                 string.Join(", ", backOffProviders.Select(v => v.Provider.Definition.Name))),
                                   "#indexers-are-unavailable-due-to-failures"));
        }
Пример #2
0
        public override HealthCheck Check()
        {
            var enabledProviders = _providerFactory.GetAvailableProviders();
            var backOffProviders = enabledProviders.Join(_providerStatusService.GetBlockedProviders(),
                                                         i => i.Definition.Id,
                                                         s => s.ProviderId,
                                                         (i, s) => new { Provider = i, Status = s })
                                   .Where(p => p.Status.InitialFailure.HasValue &&
                                          p.Status.InitialFailure.Value.Before(
                                              DateTime.UtcNow.AddHours(-6)))
                                   .ToList();

            if (backOffProviders.Empty())
            {
                return(new HealthCheck(GetType()));
            }

            if (backOffProviders.Count == enabledProviders.Count)
            {
                return(new HealthCheck(GetType(),
                                       HealthCheckResult.Error,
                                       "All indexers are unavailable due to failures for more than 6 hours",
                                       "#indexers-are-unavailable-due-to-failures"));
            }

            return(new HealthCheck(GetType(),
                                   HealthCheckResult.Warning,
                                   string.Format("Indexers unavailable due to failures for more than 6 hours: {0}",
                                                 string.Join(", ", backOffProviders.Select(v => v.Provider.Definition.Name))),
                                   "#indexers-are-unavailable-due-to-failures"));
        }
Пример #3
0
        private IEnumerable <IIndexer> FilterBlockedIndexers(IEnumerable <IIndexer> indexers)
        {
            var blockedIndexers = _indexerStatusService.GetBlockedProviders().ToDictionary(v => v.ProviderId, v => v);

            foreach (var indexer in indexers)
            {
                IndexerStatus blockedIndexerStatus;
                if (blockedIndexers.TryGetValue(indexer.Definition.Id, out blockedIndexerStatus))
                {
                    _logger.Debug("Temporarily ignoring indexer {0} till {1} due to recent failures.", indexer.Definition.Name, blockedIndexerStatus.DisabledTill.Value.ToLocalTime());
                    continue;
                }

                yield return(indexer);
            }
        }
Пример #4
0
        public override HealthCheck Check()
        {
            var enabledProviders = _providerFactory.GetAvailableProviders();
            var backOffProviders = enabledProviders.Join(_providerStatusService.GetBlockedProviders(),
                                                         i => i.Definition.Id,
                                                         s => s.ProviderId,
                                                         (i, s) => new { Indexer = i, Status = s })
                                   .ToList();

            if (backOffProviders.Empty())
            {
                return(new HealthCheck(GetType()));
            }

            if (backOffProviders.Count == enabledProviders.Count)
            {
                return(new HealthCheck(GetType(), HealthCheckResult.Error, "All indexers are unavailable due to failures", "#indexers-are-unavailable-due-to-failures"));
            }

            return(new HealthCheck(GetType(), HealthCheckResult.Warning, string.Format("Indexers unavailable due to failures: {0}", string.Join(", ", backOffProviders.Select(v => v.Indexer.Definition.Name))), "#indexers-are-unavailable-due-to-failures"));
        }
Пример #5
0
        private List <ReleaseInfo> FilterBlockedIndexers(List <ReleaseInfo> releases)
        {
            var blockedIndexers = new HashSet <int>(_indexerStatusService.GetBlockedProviders().Select(v => v.ProviderId));

            return(releases.Where(release => !blockedIndexers.Contains(release.IndexerId)).ToList());
        }
Пример #6
0
 private IDictionary <string, IndexerStatus> FetchBlockedIndexer()
 {
     return(_indexerStatusService.GetBlockedProviders().ToDictionary(v => v.ProviderId.ToString()));
 }
Пример #7
0
 public List <IndexerStatusResource> GetAll()
 {
     return(_indexerStatusService.GetBlockedProviders().ToResource());
 }