Exemple #1
0
        public CountersStorage(DocumentDatabase documentDatabase, Transaction tx)
        {
            _documentDatabase = documentDatabase;
            _documentsStorage = documentDatabase.DocumentsStorage;

            tx.CreateTree(CounterKeysSlice);

            TombstonesSchema.Create(tx, CountersTombstonesSlice, 16);
        }
Exemple #2
0
        public void InitializeFromDatabaseRecord(DatabaseRecord dbRecord)
        {
            try
            {
                var revisions = dbRecord.Revisions;
                if (revisions == null ||
                    (revisions.Default == null && revisions.Collections.Count == 0))
                {
                    Configuration = null;
                    return;
                }

                if (revisions.Equals(Configuration))
                {
                    return;
                }

                Configuration = revisions;

                using (var tx = _database.DocumentsStorage.Environment.WriteTransaction())
                {
                    foreach (var collection in Configuration.Collections)
                    {
                        if (collection.Value.Active == false)
                        {
                            continue;
                        }
                        EnsureRevisionTableCreated(tx, new CollectionName(collection.Key));
                    }

                    tx.CreateTree(RevisionsCountSlice);
                    TombstonesSchema.Create(tx, RevisionsTombstonesSlice, 16);

                    tx.Commit();
                }

                if (_logger.IsInfoEnabled)
                {
                    _logger.Info("Revisions configuration changed");
                }
            }
            catch (Exception e)
            {
                var msg = "Cannot enable revisions for documents as the revisions configuration" +
                          $" in the database record is missing or not valid: {dbRecord}";
                _database.NotificationCenter.Add(AlertRaised.Create($"Revisions error in {_database.Name}", msg,
                                                                    AlertType.RevisionsConfigurationNotValid, NotificationSeverity.Error, _database.Name));
                if (_logger.IsOperationsEnabled)
                {
                    _logger.Operations(msg, e);
                }
            }
        }
Exemple #3
0
 private static void CreateTrees(Transaction tx)
 {
     tx.CreateTree(RevisionsCountSlice);
     TombstonesSchema.Create(tx, RevisionsTombstonesSlice, 16);
 }