public void AddData() { MemoryUsage.Clear(); doneImporting = false; var session = store.OpenSession(); var count = 0; logger.Info("Testing RavenDB Log"); var sp = ParseDisks(diskToAdd => { session.Store(diskToAdd); count += 1; if (count < BatchSize) { return; } session.SaveChanges(); session = store.OpenSession(); count = 0; }); session.SaveChanges(); logger.Info(" "); logger.Info("Done in {0}", sp.Elapsed); doneImporting = true; }
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); } }