Exemple #1
0
        public void WaitForIndexesToBecomeNonStale()
        {
            MemoryUsage.Clear();
            while (true)
            {
                process.Refresh();
                MemoryUsage.Add(process.WorkingSet64);

                var statistics = store.DatabaseCommands.GetStatistics();

                if (statistics.StaleIndexes.Length == 0 && doneImporting)
                {
                    return;
                }

                foreach (var staleIndex in statistics.StaleIndexes)
                {
                    var indexStats    = statistics.Indexes.Single(x => x.Name == staleIndex);
                    var latencyInTime = (DateTime.UtcNow - indexStats.LastIndexedTimestamp).TotalMilliseconds;
                    LatencyTimes.Add(new KeyValuePair <string, double>(staleIndex, latencyInTime));

                    var latencyInDocuments = statistics.CountOfDocuments - indexStats.IndexingAttempts;
                    LatencyInDocuments.Add(new KeyValuePair <string, long>(staleIndex, latencyInDocuments));

                    logger.Debug("Stale index {0} - {1:#,#}/{2:#,#} - latency: {3:#,#}, {4:#,#}ms", indexStats.Id, indexStats.IndexingAttempts, statistics.CountOfDocuments,
                                 latencyInDocuments,
                                 latencyInTime);
                }

                Thread.Sleep(1000);
            }
        }
Exemple #2
0
 public IEnumerable <Tuple <string, IEnumerable <double>, IEnumerable <long> > > Latencies()
 {
     foreach (var item in LatencyTimes.GroupBy(x => x.Key))
     {
         yield return
             (Tuple.Create(item.Key, item.Select(x => x.Value),
                           LatencyInDocuments.Where(pair => pair.Key == item.Key).Select(x => x.Value)));
     }
 }