public void Clean() { lock (transaction) { _indexStore.Clean(); } }
public async Task RebuildIndexAsync(IIndexBuildProgressReporter reporter = null) { using (MaintenanceMode.Enable(MaintenanceLockMode.Write)) // allow to read data while reindexing { var progress = new IndexRebuildProgress(reporter); await progress.StartedAsync().ConfigureAwait(false); // TODO: lock collections for writing somehow? var indexSettings = _sparkSettings.IndexSettings ?? new IndexSettings(); if (indexSettings.ClearIndexOnRebuild) { await progress.CleanStartedAsync().ConfigureAwait(false); await _indexStore.Clean().ConfigureAwait(false); await progress.CleanCompletedAsync().ConfigureAwait(false); } var paging = _entryReader .ReadAsync(new FhirStorePageReaderOptions { PageSize = indexSettings.ReindexBatchSize }) .ConfigureAwait(false); var count = 0; //async entries => //{ // Selecting records page-by-page (page size is defined in app config, default is 100). // This will help to keep memory usage under control. await foreach (var entry in paging) { count++; // TODO: use BulkWrite operation for this try { await _indexService.Process(entry).ConfigureAwait(false); } catch (Exception) { // TODO: log exception! await progress.ErrorAsync($"Failed to reindex entry {entry.Key}") .ConfigureAwait(false); } } await progress.RecordsProcessedAsync(count, count) .ConfigureAwait(false); // }) //.ConfigureAwait(false); // TODO: - unlock collections for writing await progress.DoneAsync().ConfigureAwait(false); } }
public async Task Clean() { await _transaction.WaitAsync().ConfigureAwait(false); try { await _indexStore.Clean().ConfigureAwait(false); } finally { _transaction.Release(); } }