/// <summary> /// Creates the indexes found in the specified catalog /// </summary> /// <param name="catalogToGetnIndexingTasksFrom">The catalog to get indexing tasks from.</param> /// <param name="documentStore">The document store.</param> public static void CreateIndexes(ExportProvider catalogToGetnIndexingTasksFrom, IDocumentStore documentStore) { foreach (var task in catalogToGetnIndexingTasksFrom.GetExportedValues<AbstractIndexCreationTask>()) { task.Execute(documentStore); } foreach (var task in catalogToGetnIndexingTasksFrom.GetExportedValues<AbstractTransformerCreationTask>()) { task.Execute(documentStore); } }
/// <summary> /// Creates the indexes found in the specified catalog /// </summary> /// <param name="catalogToGetnIndexingTasksFrom">The catalog to get indexing tasks from.</param> public static void CreateIndexes(ExportProvider catalogToGetnIndexingTasksFrom, IDatabaseCommands databaseCommands, DocumentConvention conventions) { foreach (var task in catalogToGetnIndexingTasksFrom.GetExportedValues<AbstractIndexCreationTask>()) { task.Execute(databaseCommands, conventions); } foreach (var task in catalogToGetnIndexingTasksFrom.GetExportedValues<AbstractTransformerCreationTask>()) { task.Execute(databaseCommands, conventions); } }
/// <summary> /// Creates the indexes found in the specified catalog /// </summary> public static void CreateIndexes(ExportProvider catalogToGetnIndexingTasksFrom, IDatabaseCommands databaseCommands, DocumentConvention conventions) { var indexCompilationExceptions = new List<IndexCompilationException>(); try { var tasks = catalogToGetnIndexingTasksFrom .GetExportedValues<AbstractIndexCreationTask>() .ToList(); var indexesToAdd = tasks .Select(x => new IndexToAdd { Definition = x.CreateIndexDefinition(), Name = x.IndexName, Priority = x.Priority ?? IndexingPriority.Normal }) .ToArray(); databaseCommands.PutIndexes(indexesToAdd); foreach (var task in tasks) task.AfterExecute(databaseCommands, conventions); } // For old servers that don't have the new entrypoint for executing multiple indexes catch (Exception) { foreach (var task in catalogToGetnIndexingTasksFrom.GetExportedValues<AbstractIndexCreationTask>()) { try { task.Execute(databaseCommands, conventions); } catch (IndexCompilationException e) { indexCompilationExceptions.Add(new IndexCompilationException("Failed to compile index name = " + task.IndexName, e)); } } } foreach (var task in catalogToGetnIndexingTasksFrom.GetExportedValues<AbstractTransformerCreationTask>()) { task.Execute(databaseCommands, conventions); } if (indexCompilationExceptions.Any()) throw new AggregateException("Failed to create one or more indexes. Please see inner exceptions for more details.", indexCompilationExceptions); }
/// <summary> /// Creates the indexes found in the specified catalog /// </summary> /// <param name="catalogToGetnIndexingTasksFrom">The catalog to getn indexing tasks from.</param> /// <param name="documentStore">The document store.</param> public static Task CreateIndexesAsync(ExportProvider catalogToGetnIndexingTasksFrom, IDocumentStore documentStore) { var tasks = catalogToGetnIndexingTasksFrom.GetExportedValues<AbstractIndexCreationTask>(); Task[] array = tasks.Select(task => task.ExecuteAsync(documentStore)).ToArray(); var indexesAsync = new Task(() => Task.WaitAll(array)); indexesAsync.Start(); return indexesAsync; }
/// <summary> /// Creates the indexes found in the specified catalog /// </summary> public static Task CreateIndexesAsync(ExportProvider catalogToGetnIndexingTasksFrom, IAsyncDatabaseCommands asyncDatabaseCommands, DocumentConvention conventions) { var tasks = catalogToGetnIndexingTasksFrom.GetExportedValues<AbstractIndexCreationTask>(); Task[] array = tasks.Select(task => task.ExecuteAsync(asyncDatabaseCommands, conventions)).ToArray(); var indexesAsync = new Task(() => Task.WaitAll(array)); indexesAsync.Start(); return indexesAsync; }
/// <summary> /// Creates the indexes found in the specified catalog /// </summary> /// <param name="catalogToGetnIndexingTasksFrom">The catalog to get indexing tasks from.</param> /// <param name="documentStore">The document store.</param> public static void CreateIndexes(ExportProvider catalogToGetnIndexingTasksFrom, IDocumentStore documentStore) { var indexCompilationExceptions = new List<IndexCompilationException>(); foreach (var task in catalogToGetnIndexingTasksFrom.GetExportedValues<AbstractIndexCreationTask>()) { try { task.Execute(documentStore); } catch (IndexCompilationException e) { indexCompilationExceptions.Add(new IndexCompilationException("Failed to compile index name = " + task.IndexName, e)); } } foreach (var task in catalogToGetnIndexingTasksFrom.GetExportedValues<AbstractTransformerCreationTask>()) { task.Execute(documentStore); } if (indexCompilationExceptions.Any()) throw new AggregateException("Failed to create one or more indexes. Please see inner exceptions for more details.", indexCompilationExceptions); }
/// <summary> /// Creates the indexes found in the specified catalog /// </summary> public static async Task CreateIndexesAsync(ExportProvider catalogToGetnIndexingTasksFrom, IAsyncDatabaseCommands databaseCommands, DocumentConvention conventions) { var indexCompilationExceptions = new List<IndexCompilationException>(); foreach (var task in catalogToGetnIndexingTasksFrom.GetExportedValues<AbstractIndexCreationTask>()) { try { await task.ExecuteAsync(databaseCommands, conventions); } catch (IndexCompilationException e) { indexCompilationExceptions.Add(new IndexCompilationException("Failed to compile index name = " + task.IndexName, e)); } } foreach (var task in catalogToGetnIndexingTasksFrom.GetExportedValues<AbstractTransformerCreationTask>()) { await task.ExecuteAsync(databaseCommands, conventions); } if (indexCompilationExceptions.Any()) throw new AggregateException("Failed to create one or more indexes. Please see inner exceptions for more details.", indexCompilationExceptions); }
/// <summary> /// This is all the command settings that are related to the file match element. /// </summary> /// <param name="container">The container for all the plugins.</param> /// <param name="project">The project to get all the command settings for.</param> /// <returns>Dictionary of command type/command </returns> private Dictionary<string, List<string>> GetCommandSettings(ExportProvider container, ProjectElement project) { var currentConfigurationElementCollections = container.GetExportedValues<CurrentConfigurationElementCollection>() .Where(x => !_excludedElements.Contains(x.Setting.ElementSettingName)); var commandSettings = new Dictionary<string, List<string>>(); foreach (var configurationElementCollection in currentConfigurationElementCollections) { var collectionSettingName = configurationElementCollection.Setting.ElementCollectionSettingName; var configurationProperty = project.GetConfigurationProperty(collectionSettingName); var commandElementCollection = project.GetElementCollection<CurrentConfigurationElementCollection>(configurationProperty); var conversionType = commandElementCollection.Setting.ConversionType; var commandSettingKeys = new List<string>(); for (var i = 0; i < commandElementCollection.Count; i++) { var commandElement = commandElementCollection[i]; commandSettingKeys.Add(commandElement.Name); } commandSettings.Add(conversionType, commandSettingKeys); } return commandSettings; }
/// <summary> /// Creates the indexes found in the specified catalog /// </summary> public static async Task CreateIndexesAsync(ExportProvider catalogToGetnIndexingTasksFrom, IAsyncDatabaseCommands asyncDatabaseCommands, DocumentConvention conventions) { foreach (var task in catalogToGetnIndexingTasksFrom.GetExportedValues<AbstractIndexCreationTask>()) { await task.ExecuteAsync(asyncDatabaseCommands, conventions); } foreach (var task in catalogToGetnIndexingTasksFrom.GetExportedValues<AbstractTransformerCreationTask>()) { await task.ExecuteAsync(asyncDatabaseCommands, conventions); } }
/// <summary> /// Creates the indexes found in the specified catalog in side-by-side mode. /// </summary> /// <param name="catalogToGetnIndexingTasksFrom">The catalog to get indexing tasks from.</param> /// <param name="documentStore">The document store.</param> public static async Task SideBySideCreateIndexesAsync(ExportProvider catalogToGetnIndexingTasksFrom, IDocumentStore documentStore, Etag minimumEtagBeforeReplace = null, DateTime? replaceTimeUtc = null) { var indexCompilationExceptions = new List<IndexCompilationException>(); foreach (var task in catalogToGetnIndexingTasksFrom.GetExportedValues<AbstractIndexCreationTask>()) { try { await task.SideBySideExecuteAsync(documentStore, minimumEtagBeforeReplace, replaceTimeUtc).ConfigureAwait(false); } catch (IndexCompilationException e) { indexCompilationExceptions.Add(new IndexCompilationException("Failed to compile index name = " + task.IndexName, e)); } } foreach (var task in catalogToGetnIndexingTasksFrom.GetExportedValues<AbstractTransformerCreationTask>()) { await task.ExecuteAsync(documentStore).ConfigureAwait(false); } if (indexCompilationExceptions.Any()) throw new AggregateException("Failed to create one or more indexes. Please see inner exceptions for more details.", indexCompilationExceptions); }
private static async Task CreateTransformersAsync(ExportProvider catalogToGetnIndexingTasksFrom, IDocumentStore documentStore) { foreach (var task in catalogToGetnIndexingTasksFrom.GetExportedValues<AbstractTransformerCreationTask>()) { await task.ExecuteAsync(documentStore).ConfigureAwait(false); } }
/// <summary> /// Creates the indexes found in the specified catalog in side-by-side mode. /// </summary> /// <param name="catalogToGetnIndexingTasksFrom">The catalog to get indexing tasks from.</param> /// <param name="documentStore">The document store.</param> /// <param name="minimumEtagBeforeReplace">Minimum last indexed etag after which index will be replaced (map indexes only)</param> /// <param name="replaceTimeUtc"></param> public static async Task SideBySideCreateIndexesAsync(ExportProvider catalogToGetnIndexingTasksFrom, IDocumentStore documentStore, Etag minimumEtagBeforeReplace = null, DateTime? replaceTimeUtc = null) { var indexCompilationExceptions = new List<IndexCompilationException>(); var failed = false; try { var tasks = catalogToGetnIndexingTasksFrom .GetExportedValues<AbstractIndexCreationTask>() .ToList(); var indexesToAdd = CreateIndexesToAdd(tasks, documentStore.Conventions); await documentStore.AsyncDatabaseCommands.PutSideBySideIndexesAsync(indexesToAdd, minimumEtagBeforeReplace, replaceTimeUtc).ConfigureAwait(false); foreach (var task in tasks) await task.AfterExecuteAsync(documentStore.AsyncDatabaseCommands, documentStore.Conventions).ConfigureAwait(false); } // For old servers that don't have the new endpoint for executing multiple indexes catch (Exception) { failed = true; } if (failed) { foreach (var task in catalogToGetnIndexingTasksFrom.GetExportedValues<AbstractIndexCreationTask>()) { try { await task.SideBySideExecuteAsync(documentStore, minimumEtagBeforeReplace, replaceTimeUtc).ConfigureAwait(false); } catch (IndexCompilationException e) { indexCompilationExceptions.Add(new IndexCompilationException("Failed to compile side by side index name = " + task.IndexName, e)); } } } await CreateTransformersAsync(catalogToGetnIndexingTasksFrom, documentStore).ConfigureAwait(false); if (indexCompilationExceptions.Any()) throw new AggregateException("Failed to create one or more side by side indexes. Please see inner exceptions for more details.", indexCompilationExceptions); }
/// <summary> /// Creates the indexes found in the specified catalog in side-by-side mode. /// </summary> /// <param name="catalogToGetnIndexingTasksFrom">The catalog to get indexing tasks from.</param> /// <param name="documentStore">The document store.</param> /// <param name="minimumEtagBeforeReplace">Minimum last indexed etag after which index will be replaced (map indexes only)</param> /// <param name="replaceTimeUtc"></param> public static void SideBySideCreateIndexes(ExportProvider catalogToGetnIndexingTasksFrom, IDocumentStore documentStore, Etag minimumEtagBeforeReplace = null, DateTime? replaceTimeUtc = null) { var indexCompilationExceptions = new List<IndexCompilationException>(); try { var tasks = catalogToGetnIndexingTasksFrom .GetExportedValues<AbstractIndexCreationTask>() .ToList(); documentStore.SideBySideExecuteIndexes(tasks, minimumEtagBeforeReplace, replaceTimeUtc); } // For old servers that don't have the new endpoint for executing multiple indexes catch (Exception ex) { Log.InfoException("Could not create side by side indexes in one shot (maybe using older version of RavenDB ?)", ex); foreach (var task in catalogToGetnIndexingTasksFrom.GetExportedValues<AbstractIndexCreationTask>()) { try { task.SideBySideExecute(documentStore, minimumEtagBeforeReplace, replaceTimeUtc); } catch (IndexCompilationException e) { indexCompilationExceptions.Add(new IndexCompilationException("Failed to compile side by side index name = " + task.IndexName, e)); } } } CreateTransformers(catalogToGetnIndexingTasksFrom, documentStore); if (indexCompilationExceptions.Any()) throw new AggregateException("Failed to create one or more side by indexes. Please see inner exceptions for more details.", indexCompilationExceptions); }
/// <summary> /// Creates the indexes found in the specified catalog in side-by-side mode. /// </summary> public static void SideBySideCreateIndexes(ExportProvider catalogToGetnIndexingTasksFrom, IDatabaseCommands databaseCommands, DocumentConvention conventions, Etag minimumEtagBeforeReplace = null, DateTime? replaceTimeUtc = null) { var indexCompilationExceptions = new List<IndexCompilationException>(); try { var tasks = catalogToGetnIndexingTasksFrom .GetExportedValues<AbstractIndexCreationTask>() .ToList(); var indexesToAdd = CreateIndexesToAdd(tasks, conventions); databaseCommands.PutSideBySideIndexes(indexesToAdd, minimumEtagBeforeReplace, replaceTimeUtc); foreach (var task in tasks) task.AfterExecute(databaseCommands, conventions); } // For old servers that don't have the new endpoint for executing multiple indexes catch (Exception) { foreach (var task in catalogToGetnIndexingTasksFrom.GetExportedValues<AbstractIndexCreationTask>()) { try { task.SideBySideExecute(databaseCommands, conventions, minimumEtagBeforeReplace, replaceTimeUtc); } catch (IndexCompilationException e) { indexCompilationExceptions.Add(new IndexCompilationException("Failed to compile side by side index name = " + task.IndexName, e)); } } } CreateTransformers(catalogToGetnIndexingTasksFrom, databaseCommands, conventions); if (indexCompilationExceptions.Any()) throw new AggregateException("Failed to create one or more side by side indexes. Please see inner exceptions for more details.", indexCompilationExceptions); }
/// <summary> /// Creates the indexes found in the specified catalog /// </summary> /// <param name="catalogToGetnIndexingTasksFrom">The catalog to get indexing tasks from.</param> /// <param name="documentStore">The document store.</param> public static void CreateIndexes(ExportProvider catalogToGetnIndexingTasksFrom, IDocumentStore documentStore) { var indexCompilationExceptions = new List<IndexCompilationException>(); try { var tasks = catalogToGetnIndexingTasksFrom .GetExportedValues<AbstractIndexCreationTask>() .ToList(); documentStore.ExecuteIndexes(tasks); } // For old servers that don't have the new entrypoint for executing multiple indexes catch (Exception ex) { Log.InfoException("Could not create indexes in one shot (maybe using older version of RavenDB ?)", ex); foreach (var task in catalogToGetnIndexingTasksFrom.GetExportedValues<AbstractIndexCreationTask>()) { try { task.Execute(documentStore); } catch (IndexCompilationException e) { indexCompilationExceptions.Add(new IndexCompilationException("Failed to compile index name = " + task.IndexName, e)); } } } foreach (var task in catalogToGetnIndexingTasksFrom.GetExportedValues<AbstractTransformerCreationTask>()) { task.Execute(documentStore); } if (indexCompilationExceptions.Any()) throw new AggregateException("Failed to create one or more indexes. Please see inner exceptions for more details.", indexCompilationExceptions); }
/// <summary> /// Creates the indexes found in the specified catalog in side-by-side mode. /// </summary> public static void SideBySideCreateIndexes(ExportProvider catalogToGetnIndexingTasksFrom, IDatabaseCommands databaseCommands, DocumentConvention conventions, Etag minimumEtagBeforeReplace = null, DateTime? replaceTimeUtc = null) { var indexCompilationExceptions = new List<IndexCompilationException>(); foreach (var task in catalogToGetnIndexingTasksFrom.GetExportedValues<AbstractIndexCreationTask>()) { try { task.SideBySideExecute(databaseCommands, conventions, minimumEtagBeforeReplace, replaceTimeUtc); } catch (IndexCompilationException e) { indexCompilationExceptions.Add(new IndexCompilationException("Failed to compile index name = " + task.IndexName, e)); } } foreach (var task in catalogToGetnIndexingTasksFrom.GetExportedValues<AbstractTransformerCreationTask>()) { task.Execute(databaseCommands, conventions); } if (indexCompilationExceptions.Any()) throw new AggregateException("Failed to create one or more indexes. Please see inner exceptions for more details.", indexCompilationExceptions); }
private static async Task CreateTransformersAsync(ExportProvider catalogToGetnIndexingTasksFrom, IAsyncDatabaseCommands databaseCommands, DocumentConvention conventions) { foreach (var task in catalogToGetnIndexingTasksFrom.GetExportedValues<AbstractTransformerCreationTask>()) { await task.ExecuteAsync(databaseCommands, conventions).ConfigureAwait(false); } }
/// <summary> /// Creates the indexes found in the specified catalog /// </summary> public static async Task CreateIndexesAsync(ExportProvider catalogToGetnIndexingTasksFrom, IAsyncDatabaseCommands databaseCommands, DocumentConvention conventions) { var indexCompilationExceptions = new List<IndexCompilationException>(); bool failed = false; try { var tasks = catalogToGetnIndexingTasksFrom .GetExportedValues<AbstractIndexCreationTask>() .ToList(); var indexesNames = tasks.Select(x => x.IndexName).ToArray(); var definitions = tasks.Select(x => x.CreateIndexDefinition()).ToArray(); var priorities = tasks.Select(x => x.Priority ?? IndexingPriority.Normal).ToArray(); await databaseCommands.PutIndexesAsync(indexesNames, definitions, priorities).ConfigureAwait(false); foreach (var task in tasks) await task.AfterExecuteAsync(databaseCommands, conventions).ConfigureAwait(false); } // For old servers that don't have the new entrypoint for executing multiple indexes catch (Exception) { failed = true; } if (failed) { foreach (var task in catalogToGetnIndexingTasksFrom.GetExportedValues<AbstractIndexCreationTask>()) { try { await task.ExecuteAsync(databaseCommands, conventions).ConfigureAwait(false); } catch (IndexCompilationException e) { indexCompilationExceptions.Add(new IndexCompilationException("Failed to compile index name = " + task.IndexName, e)); } } } foreach (var task in catalogToGetnIndexingTasksFrom.GetExportedValues<AbstractTransformerCreationTask>()) { await task.ExecuteAsync(databaseCommands, conventions).ConfigureAwait(false); } if (indexCompilationExceptions.Any()) throw new AggregateException("Failed to create one or more indexes. Please see inner exceptions for more details.", indexCompilationExceptions); }
/// <summary> /// Creates the indexes found in the specified catalog /// </summary> public static async Task CreateIndexesAsync(ExportProvider catalogToGetnIndexingTasksFrom, IAsyncDatabaseCommands databaseCommands, DocumentConvention conventions) { var indexCompilationExceptions = new List<IndexCompilationException>(); var failed = false; try { var tasks = catalogToGetnIndexingTasksFrom .GetExportedValues<AbstractIndexCreationTask>() .ToList(); var indexesToAdd = CreateIndexesToAdd(tasks, conventions); await databaseCommands.PutIndexesAsync(indexesToAdd).ConfigureAwait(false); foreach (var task in tasks) await task.AfterExecuteAsync(databaseCommands, conventions).ConfigureAwait(false); } // For old servers that don't have the new endpoint for executing multiple indexes catch (Exception) { failed = true; } if (failed) { foreach (var task in catalogToGetnIndexingTasksFrom.GetExportedValues<AbstractIndexCreationTask>()) { try { await task.ExecuteAsync(databaseCommands, conventions).ConfigureAwait(false); } catch (IndexCompilationException e) { indexCompilationExceptions.Add(new IndexCompilationException("Failed to compile index name = " + task.IndexName, e)); } } } await CreateTransformersAsync(catalogToGetnIndexingTasksFrom, databaseCommands, conventions).ConfigureAwait(false); if (indexCompilationExceptions.Any()) throw new AggregateException("Failed to create one or more indexes. Please see inner exceptions for more details.", indexCompilationExceptions); }