public DocumentDatabase(string name, RavenConfiguration configuration, ServerStore serverStore) { StartTime = SystemTime.UtcNow; Name = name; ResourceName = "db/" + name; Configuration = configuration; _logger = LoggingSource.Instance.GetLogger <DocumentDatabase>(Name); Notifications = new DocumentsNotifications(); DocumentsStorage = new DocumentsStorage(this); IndexStore = new IndexStore(this); TransformerStore = new TransformerStore(this); SqlReplicationLoader = new SqlReplicationLoader(this); DocumentReplicationLoader = new DocumentReplicationLoader(this); DocumentTombstoneCleaner = new DocumentTombstoneCleaner(this); SubscriptionStorage = new SubscriptionStorage(this); Operations = new DatabaseOperations(this); Metrics = new MetricsCountersManager(); IoMetrics = serverStore?.IoMetrics ?? new IoMetrics(256, 256); Patch = new PatchDocument(this); TxMerger = new TransactionOperationsMerger(this, DatabaseShutdown); HugeDocuments = new HugeDocuments(configuration.Databases.MaxCollectionSizeHugeDocuments, configuration.Databases.MaxWarnSizeHugeDocuments); ConfigurationStorage = new ConfigurationStorage(this, serverStore); DatabaseInfoCache = serverStore?.DatabaseInfoCache; }
private void InitializeInternal() { TxMerger.Start(); _indexStoreTask = IndexStore.InitializeAsync(); _transformerStoreTask = TransformerStore.InitializeAsync(); SqlReplicationLoader.Initialize(); DocumentTombstoneCleaner.Initialize(); BundleLoader = new BundleLoader(this); try { _indexStoreTask.Wait(DatabaseShutdown); } finally { _indexStoreTask = null; } try { _transformerStoreTask.Wait(DatabaseShutdown); } finally { _transformerStoreTask = null; } SubscriptionStorage.Initialize(); //Index Metadata Store shares Voron env and context pool with documents storage, //so replication of both documents and indexes/transformers can be made within one transaction ConfigurationStorage.Initialize(IndexStore, TransformerStore); DocumentReplicationLoader.Initialize(); }
private void DeleteIndexMetadataForRemovedIndexesAndTransformers(Transaction tx, TransactionOperationContext context, IndexStore indexStore, TransformerStore transformerStore) { var toRemove = new List <IndexEntryMetadata>(); var table = tx.OpenTable(IndexesTableSchema, SchemaNameConstants.IndexMetadataTable); foreach (var tvr in table.SeekForwardFrom(IndexesTableSchema.FixedSizeIndexes[EtagIndexName], 0)) { var metadata = TableValueToMetadata(tvr, context, true); if (metadata == null) //noting to do if it is a tombstone { continue; } if (metadata.Type == IndexEntryType.Index && indexStore.GetIndex(metadata.Id) == null) { toRemove.Add(metadata); } if (metadata.Type == IndexEntryType.Transformer && transformerStore.GetTransformer(metadata.Id) == null) { toRemove.Add(metadata); } } foreach (var metadata in toRemove) { WriteEntry(tx, metadata.Name, metadata.Type, -1, context); } }
public DynamicQueryRunner(IndexStore indexStore, TransformerStore transformerStore, DocumentsStorage documents, DocumentsOperationContext context, OperationCancelToken token) { _indexStore = indexStore; _transformerStore = transformerStore; _context = context; _token = token; _documents = documents; }
public void Initialize(IndexStore indexStore, TransformerStore transformerStore) { _contextPool = new TransactionContextPool(Environment); AlertsStorage.Initialize(Environment, _contextPool); IndexesEtagsStorage.Initialize(Environment, _contextPool, indexStore, transformerStore); }
public void Initialize(StorageEnvironment environment, TransactionContextPool contextPool, IndexStore indexStore, TransformerStore transformerStore) { _environment = environment; _contextPool = contextPool; TransactionOperationContext context; using (contextPool.AllocateOperationContext(out context)) using (var tx = context.OpenWriteTransaction()) { IndexesTableSchema.Create(tx.InnerTransaction, SchemaNameConstants.IndexMetadataTable, 16); ConflictsTableSchema.Create(tx.InnerTransaction, SchemaNameConstants.ConflictMetadataTable, 16); tx.InnerTransaction.CreateTree(SchemaNameConstants.GlobalChangeVectorTree); tx.InnerTransaction.CreateTree(SchemaNameConstants.LastReplicatedEtagsTree); DeleteIndexMetadataForRemovedIndexesAndTransformers(tx.InnerTransaction, context, indexStore, transformerStore); tx.Commit(); } IsInitialized = true; }