Beispiel #1
0
        private IEnumerable <IIndexer> FilterBlockedIndexers(IEnumerable <IIndexer> indexers)
        {
            var blockedIndexers = _indexerStatusService.GetBlockedIndexers().ToDictionary(v => v.IndexerId, 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);
            }
        }
Beispiel #2
0
        public override HealthCheck Check()
        {
            var enabledIndexers = _indexerFactory.GetAvailableProviders();
            var backOffIndexers = enabledIndexers.Join(_indexerStatusService.GetBlockedIndexers(),
                                                       i => i.Definition.Id,
                                                       s => s.IndexerId,
                                                       (i, s) => new { Indexer = i, Status = s })
                                  .Where(v => (v.Status.MostRecentFailure - v.Status.InitialFailure) > TimeSpan.FromHours(1))
                                  .ToList();

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

            if (backOffIndexers.Count == enabledIndexers.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(", ", backOffIndexers.Select(v => v.Indexer.Definition.Name))), "#indexers-are-unavailable-due-to-failures"));
        }
Beispiel #3
0
        private List <ReleaseInfo> FilterBlockedIndexers(List <ReleaseInfo> releases)
        {
            var blockedIndexers = new HashSet <int>(_indexerStatusService.GetBlockedIndexers().Select(v => v.IndexerId));

            return(releases.Where(release => !blockedIndexers.Contains(release.IndexerId)).ToList());
        }