public void HandleIndexRename(string oldIndexName, string newIndexName, int newIndexId, IStorageActionsAccessor accessor) { // remap indexing errors (if any) var indexesToRename = indexingErrors.Where(x => StringComparer.OrdinalIgnoreCase.Equals(x.IndexName, oldIndexName)).ToList(); foreach (var indexingError in indexesToRename) { indexingError.IndexName = newIndexName; } var oldListName = "Raven/Indexing/Errors/" + oldIndexName; var existingErrors = accessor.Lists.Read(oldListName, Etag.Empty, null, 5000).ToList(); if (existingErrors.Any()) { lock (indexingErrorLocks.GetOrAdd(newIndexId, new object())) { var newListName = "Raven/Indexing/Errors/" + newIndexName; foreach (var existingError in existingErrors) { accessor.Lists.Set(newListName, existingError.Key, existingError.Data, UuidType.Indexing); } var timestamp = SystemTime.UtcNow; accessor.Lists.RemoveAllOlderThan(oldListName, timestamp); } } // update queryTime var queryTime = accessor.Lists.Read("Raven/Indexes/QueryTime", oldIndexName); if (queryTime != null) { accessor.Lists.Set("Raven/Indexes/QueryTime", newIndexName, queryTime.Data, UuidType.Indexing); accessor.Lists.Remove("Raven/Indexes/QueryTime", oldIndexName); } // discard index/reduce/deletion stats, instead of updating them LastActualIndexingBatchInfo.Clear(); LastActualReducingBatchInfo.Clear(); LastActualDeletionBatchInfo.Clear(); }
public void ReportIndexingBatchCompleted(IndexingBatchInfo batchInfo) { batchInfo.BatchCompleted(); batchInfo.Id = Interlocked.Increment(ref nextIndexingBatchInfoId); LastActualIndexingBatchInfo.Add(batchInfo); }