public void Initialize() { _shutdownNotification = new CancellationTokenSource(); AbstractLowMemoryNotification.Initialize(ServerShutdown, Configuration); if (_logger.IsInfoEnabled) { _logger.Info("Starting to open server store for " + (Configuration.Core.RunInMemory ? "<memory>" : Configuration.Core.DataDirectory)); } var options = Configuration.Core.RunInMemory ? StorageEnvironmentOptions.CreateMemoryOnly(Configuration.Core.DataDirectory) : StorageEnvironmentOptions.ForPath(System.IO.Path.Combine(Configuration.Core.DataDirectory, "System")); options.SchemaVersion = 2; try { StorageEnvironment.MaxConcurrentFlushes = Configuration.Storage.MaxConcurrentFlushes; _env = new StorageEnvironment(options); using (var tx = _env.WriteTransaction()) { tx.DeleteTree("items");// note the different casing, we remove the old items tree _itemsSchema.Create(tx, "Items", 16); tx.Commit(); } using (var tx = _env.ReadTransaction()) { var table = tx.OpenTable(_itemsSchema, "Items"); var itemsFromBackwards = table.SeekBackwardFrom(_itemsSchema.FixedSizeIndexes[EtagIndexName], long.MaxValue); var reader = itemsFromBackwards.FirstOrDefault(); if (reader == null) { _lastEtag = 0; } else { int size; _lastEtag = Bits.SwapBytes(*(long *)reader.Read(3, out size)); } } } catch (Exception e) { if (_logger.IsOperationsEnabled) { _logger.Operations( "Could not open server store for " + (Configuration.Core.RunInMemory ? "<memory>" : Configuration.Core.DataDirectory), e); } options.Dispose(); throw; } ContextPool = new TransactionContextPool(_env); _timer = new Timer(IdleOperations, null, _frequencyToCheckForIdleDatabases, TimeSpan.FromDays(7)); Alerts.Initialize(_env, ContextPool); DatabaseInfoCache.Initialize(_env, ContextPool); LicenseStorage.Initialize(_env, ContextPool); }
public void Initialize(IndexStore indexStore, TransformerStore transformerStore) { _contextPool = new TransactionContextPool(Environment); AlertsStorage.Initialize(Environment, _contextPool); IndexesEtagsStorage.Initialize(Environment, _contextPool, indexStore, transformerStore); }