Esempio n. 1
0
 public ITransactionalStorage NewTransactionalStorage()
 {
     var newTransactionalStorage = new TransactionalStorage(new RavenConfiguration
     {
         DataDirectory = "test",
     }, () => { });
     newTransactionalStorage.Initialize();
     return newTransactionalStorage;
 }
Esempio n. 2
0
 public ViewStorage()
 {
     transactionalStorage = new TransactionalStorage(new RavenConfiguration
     {
         DataDirectory = "raven.db.test.esent",
         RunInUnreliableYetFastModeThatIsNotSuitableForProduction = true
     }, () => { });
     transactionalStorage.Initialize();
 }
Esempio n. 3
0
        public StorageTest()
        {
            var configuration = new InMemoryRavenConfiguration
            {
                FileSystemDataDirectory = "test",
                Settings = new NameValueCollection()
            };

            IOExtensions.DeleteDirectory("test");
            transactionalStorage = new TransactionalStorage(configuration);
            transactionalStorage.Initialize();
        }
Esempio n. 4
0
 public ITransactionalStorage NewTransactionalStorage()
 {
     var newTransactionalStorage = new TransactionalStorage(new RavenConfiguration
     {
         DataDirectory = "test",
     }, () => { })
     {
         DocumentCodecs = new AbstractDocumentCodec[0]
     };
     newTransactionalStorage.Initialize(new DummyUuidGenerator());
     return newTransactionalStorage;
 }
Esempio n. 5
0
        public ITransactionalStorage NewTransactionalStorage()
        {
            var newTransactionalStorage = new TransactionalStorage(new RavenConfiguration
            {
                DataDirectory = "test",
            }, () => { })
            {
                DocumentCodecs = new OrderedPartCollection <AbstractDocumentCodec>()
            };

            newTransactionalStorage.Initialize(new DummyUuidGenerator());
            return(newTransactionalStorage);
        }
Esempio n. 6
0
        protected PrefetcherWithContext CreatePrefetcher(
            Action <InMemoryRavenConfiguration> modifyConfiguration = null,
            Action <WorkContext> modifyWorkContext = null,
            HashSet <string> entityNames           = null)
        {
            var configuration = new InMemoryRavenConfiguration
            {
                RunInMemory = true
            };

            configuration.Initialize();

            if (modifyConfiguration != null)
            {
                modifyConfiguration(configuration);
            }

            var transactionalStorage = new TransactionalStorage(configuration, () => { }, () => { }, () => { }, () => { });

            transactionalStorage.Initialize(new SequentialUuidGenerator {
                EtagBase = 0
            }, new OrderedPartCollection <AbstractDocumentCodec>());

            var workContext = new WorkContext
            {
                Configuration        = configuration,
                TransactionalStorage = transactionalStorage
            };

            if (modifyWorkContext != null)
            {
                modifyWorkContext(workContext);
            }

            var autoTuner = new IndexBatchSizeAutoTuner(workContext);

            var prefetchingBehavior = new PrefetchingBehavior(PrefetchingUser.Indexer, workContext, autoTuner, string.Empty, entityNames);

            var prefetcherWithContext = new PrefetcherWithContext
            {
                AutoTuner            = autoTuner,
                Configuration        = configuration,
                PrefetchingBehavior  = prefetchingBehavior,
                TransactionalStorage = transactionalStorage,
                WorkContext          = workContext
            };

            createdPrefetchers.Add(prefetcherWithContext);

            return(prefetcherWithContext);
        }
Esempio n. 7
0
        public StorageTest()
        {
            var configuration = new InMemoryRavenConfiguration
            {
                Settings   = new NameValueCollection(),
                FileSystem =
                {
                    DataDirectory = "test"
                }
            };

            IOExtensions.DeleteDirectory("test");
            transactionalStorage = new TransactionalStorage(configuration);
            transactionalStorage.Initialize(new UuidGenerator(), new OrderedPartCollection <AbstractFileCodec>());
        }
Esempio n. 8
0
        public PagesTests()
        {
            var configuration = new InMemoryRavenConfiguration
            {
                FileSystemDataDirectory = "test",
                Settings = new NameValueCollection
                {
                    { "ETag", Guid.Empty.ToString() }
                }
            };

            IOExtensions.DeleteDirectory("test");
            storage = new TransactionalStorage(configuration);
            storage.Initialize();
        }
Esempio n. 9
0
        public DocumentDatabase(RavenConfiguration configuration)
        {
            Configuration = configuration;

            configuration.Container.SatisfyImportsOnce(this);

            workContext = new WorkContext {
                IndexUpdateTriggers = IndexUpdateTriggers
            };

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

            bool newDb;

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

            IndexDefinitionStorage = new IndexDefinitionStorage(
                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;


            InitializeTriggers();
            ExecuteStartupTasks();

            if (!newDb)
            {
                return;
            }

            OnNewlyCreatedDatabase();
        }
Esempio n. 10
0
        public static void ReportOn(string path, string tableName)
        {
            using (var transactionalStorage = new TransactionalStorage(new RavenConfiguration
            {
                DataDirectory = path,
                Settings =
                {
                    { "Raven/Esent/LogFileSize", "1" }
                }
            }, () => { }, () => { }))
            {
                transactionalStorage.Initialize(new DummyUuidGenerator(), new OrderedPartCollection <AbstractDocumentCodec>());

                ReportOn(transactionalStorage, tableName, path);
            }
        }
Esempio n. 11
0
        public static List <string> ReportOn(string path)
        {
            using (var transactionalStorage = new TransactionalStorage(new RavenConfiguration
            {
                DataDirectory = path,
                Settings =
                {
                    { Constants.Esent.LogFileSize, "1" }
                }
            }, () => { }, () => { }))
            {
                transactionalStorage.Initialize(new DummyUuidGenerator(), new OrderedPartCollection <AbstractDocumentCodec>());

                return(ReportOn(transactionalStorage));
            }
        }
Esempio n. 12
0
        public PagesTests()
        {
            var configuration = new InMemoryRavenConfiguration
            {
                FileSystem =
                {
                    DataDirectory = "test"
                },
                Settings = new NameValueCollection
                {
                    { Constants.MetadataEtagField, Guid.Empty.ToString() }
                }
            };

            IOExtensions.DeleteDirectory("test");
            storage = new TransactionalStorage(configuration);
            storage.Initialize(new UuidGenerator(), new OrderedPartCollection <AbstractFileCodec>());
        }
Esempio n. 13
0
        public Queues(InMemoryRavenConfiguration configuration)
        {
            this.configuration   = configuration;
            transactionalStorage = new TransactionalStorage(configuration);
            try
            {
                transactionalStorage.Initialize(this);
            }
            catch (Exception)
            {
                Dispose();
                throw;
            }
            transactionalStorage.Batch(actions => currentEtagBase = actions.General.GetNextIdentityValue("Raven/Etag"));

            Subscriptions = new SubscriptionsSource();

            configuration.Container.SatisfyImportsOnce(this);

            MessageEnqueuedTriggers.Apply(x => x.Initialize(this));
        }
Esempio n. 14
0
        public DocumentDatabase(InMemoryRavenConfiguration configuration)
        {
            ExternalState = new ConcurrentDictionary <string, object>();

            if (configuration.BackgroundTasksPriority != ThreadPriority.Normal)
            {
                backgroundTaskScheduler = new TaskSchedulerWithCustomPriority(
                    // we need a minimum of three task threads - one for indexing dispatch, one for tasks, one for indexing ops
                    Math.Max(3, configuration.MaxNumberOfParallelIndexTasks + 2),
                    configuration.BackgroundTasksPriority);
            }
            else
            {
                backgroundTaskScheduler = TaskScheduler.Current;
            }

            ExtensionsState = new ConcurrentDictionary <object, object>();
            Configuration   = configuration;

            configuration.Container.SatisfyImportsOnce(this);

            workContext = new WorkContext
            {
                IndexUpdateTriggers = IndexUpdateTriggers,
                ReadTriggers        = ReadTriggers
            };

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

            try
            {
                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.Configuration          = configuration;
            workContext.IndexStorage           = IndexStorage;
            workContext.TransactionaStorage    = TransactionalStorage;
            workContext.IndexDefinitionStorage = IndexDefinitionStorage;


            try
            {
                InitializeTriggers();
                ExecuteStartupTasks();
            }
            catch (Exception)
            {
                Dispose();
                throw;
            }
        }