Esempio n. 1
0
        public DocumentDatabase(InMemroyRavenConfiguration configuration)
        {
            Configuration = configuration;

            configuration.Container.SatisfyImportsOnce(this);

            workContext = new WorkContext
            {
            	IndexUpdateTriggers = IndexUpdateTriggers,
				ReadTriggers = ReadTriggers
            };
            dynamicQueryRunner = new DynamicQueryRunner(this);

            TransactionalStorage = configuration.CreateTransactionalStorage(workContext.HandleWorkNotifications);
            configuration.Container.SatisfyImportsOnce(TransactionalStorage);

            bool newDb;
            try
            {
                newDb = TransactionalStorage.Initialize(this);
            }
            catch (Exception)
            {
                TransactionalStorage.Dispose();
                throw;
            }

            TransactionalStorage.Batch(actions => currentEtagBase = actions.General.GetNextIdentityValue("Raven/Etag"));

            IndexDefinitionStorage = new IndexDefinitionStorage(
                configuration,
                TransactionalStorage,
                configuration.DataDirectory,
                configuration.Container.GetExportedValues<AbstractViewGenerator>(),
                Extensions);
            IndexStorage = new IndexStorage(IndexDefinitionStorage, configuration);

            workContext.IndexStorage = IndexStorage;
            workContext.TransactionaStorage = TransactionalStorage;
            workContext.IndexDefinitionStorage = IndexDefinitionStorage;


            try
            {
                InitializeTriggers();
                ExecuteStartupTasks();
            }
            catch (Exception)
            {
                Dispose();
                throw;
            }
            if (!newDb)
                return;

            OnNewlyCreatedDatabase();
        }
Esempio n. 2
0
        public DocumentDatabase(InMemroyRavenConfiguration configuration)
        {
            Configuration = configuration;

            configuration.Container.SatisfyImportsOnce(this);

            workContext = new WorkContext
            {
            	IndexUpdateTriggers = IndexUpdateTriggers,
				ReadTriggers = ReadTriggers
            };
            dynamicQueryRunner = new DynamicQueryRunner(this);

            TransactionalStorage = configuration.CreateTransactionalStorage(workContext.NotifyAboutWork);
            configuration.Container.SatisfyImportsOnce(TransactionalStorage);

            bool newDb;
            try
            {
                newDb = TransactionalStorage.Initialize();
            }
            catch (Exception)
            {
                TransactionalStorage.Dispose();
                throw;
            }

            IndexDefinitionStorage = new IndexDefinitionStorage(
                configuration,
                TransactionalStorage,
                configuration.DataDirectory,
                configuration.Container.GetExportedValues<AbstractViewGenerator>(),
                Extensions);
            IndexStorage = new IndexStorage(IndexDefinitionStorage, configuration);

            workContext.PerformanceCounters = new PerformanceCounters("Instance @ " + configuration.Port);
            workContext.IndexStorage = IndexStorage;
            workContext.TransactionaStorage = TransactionalStorage;
            workContext.IndexDefinitionStorage = IndexDefinitionStorage;


            try
            {
                InitializeTriggers();
                ExecuteStartupTasks();
            }
            catch (Exception)
            {
                Dispose();
                throw;
            }
            if (!newDb)
                return;

            OnNewlyCreatedDatabase();
        }