コード例 #1
0
ファイル: Queues.cs プロジェクト: yonglehou/ravenmq
 public void Dispose()
 {
     if (transactionalStorage != null)
     {
         transactionalStorage.Dispose();
     }
 }
コード例 #2
0
        public void Dispose()
        {
            workContext.StopWork();
            foreach (var value in ExtensionsState.Values.OfType <IDisposable>())
            {
                value.Dispose();
            }
            TransactionalStorage.Dispose();
            IndexStorage.Dispose();

            if (tasksBackgroundTask != null)
            {
                tasksBackgroundTask.Wait();
            }
            if (indexingBackgroundTask != null)
            {
                indexingBackgroundTask.Wait();
            }
            if (reducingBackgroundTask != null)
            {
                reducingBackgroundTask.Wait();
            }

            var disposable = backgroundTaskScheduler as IDisposable;

            if (disposable != null)
            {
                disposable.Dispose();
            }
        }
コード例 #3
0
 public void Dispose()
 {
     workContext.StopWork();
     TransactionalStorage.Dispose();
     IndexStorage.Dispose();
     foreach (var backgroundWorker in backgroundWorkers)
     {
         backgroundWorker.Join();
     }
 }
コード例 #4
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();
        }
コード例 #5
0
        public DocumentDatabase(InMemoryRavenConfiguration configuration, TransportState transportState = null)
        {
            DocumentLock        = new PutSerialLock();
            Name                = configuration.DatabaseName;
            Configuration       = configuration;
            this.transportState = transportState ?? new TransportState();
            ExtensionsState     = new AtomicDictionary <object>();

            using (LogManager.OpenMappedContext("database", Name ?? Constants.SystemDatabase))
            {
                Log.Debug("Start loading the following database: {0}", Name ?? Constants.SystemDatabase);

                initializer = new DocumentDatabaseInitializer(this, configuration);

                initializer.InitializeEncryption();
                initializer.ValidateLicense();

                initializer.SubscribeToDomainUnloadOrProcessExit();
                initializer.ExecuteAlterConfiguration();
                initializer.SatisfyImportsOnce();

                backgroundTaskScheduler = configuration.CustomTaskScheduler ?? TaskScheduler.Default;


                recentTouches = new SizeLimitedConcurrentDictionary <string, TouchedDocumentInfo>(configuration.MaxRecentTouchesToRemember, StringComparer.OrdinalIgnoreCase);

                configuration.Container.SatisfyImportsOnce(this);

                workContext = new WorkContext
                {
                    Database            = this,
                    DatabaseName        = Name,
                    IndexUpdateTriggers = IndexUpdateTriggers,
                    ReadTriggers        = ReadTriggers,
                    TaskScheduler       = backgroundTaskScheduler,
                    Configuration       = configuration,
                    IndexReaderWarmers  = IndexReaderWarmers
                };

                try
                {
                    uuidGenerator = new SequentialUuidGenerator();
                    initializer.InitializeTransactionalStorage(uuidGenerator);
                    lastCollectionEtags = new LastCollectionEtags(TransactionalStorage, WorkContext);
                }
                catch (Exception)
                {
                    if (TransactionalStorage != null)
                    {
                        TransactionalStorage.Dispose();
                    }
                    throw;
                }

                try
                {
                    TransactionalStorage.Batch(actions => uuidGenerator.EtagBase = actions.General.GetNextIdentityValue("Raven/Etag"));

                    // Index codecs must be initialized before we try to read an index
                    InitializeIndexCodecTriggers();
                    initializer.InitializeIndexStorage();

                    Attachments   = new AttachmentActions(this, recentTouches, uuidGenerator, Log);
                    Documents     = new DocumentActions(this, recentTouches, uuidGenerator, Log);
                    Indexes       = new IndexActions(this, recentTouches, uuidGenerator, Log);
                    Maintenance   = new MaintenanceActions(this, recentTouches, uuidGenerator, Log);
                    Notifications = new NotificationActions(this, recentTouches, uuidGenerator, Log);
                    Patches       = new PatchActions(this, recentTouches, uuidGenerator, Log);
                    Queries       = new QueryActions(this, recentTouches, uuidGenerator, Log);
                    Tasks         = new TaskActions(this, recentTouches, uuidGenerator, Log);
                    Transformers  = new TransformerActions(this, recentTouches, uuidGenerator, Log);

                    inFlightTransactionalState = TransactionalStorage.GetInFlightTransactionalState(Documents.Put, Documents.Delete);

                    CompleteWorkContextSetup();

                    prefetcher       = new Prefetcher(workContext);
                    indexingExecuter = new IndexingExecuter(workContext, prefetcher);

                    RaiseIndexingWiringComplete();

                    InitializeTriggersExceptIndexCodecs();
                    SecondStageInitialization();
                    ExecuteStartupTasks();
                    lastCollectionEtags.Initialize();

                    Log.Debug("Finish loading the following database: {0}", configuration.DatabaseName ?? Constants.SystemDatabase);
                }
                catch (Exception)
                {
                    Dispose();
                    throw;
                }
            }
        }
コード例 #6
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;
            }
        }
コード例 #7
0
ファイル: StorageTest.cs プロジェクト: stvoidmain/ravendb
 public void Dispose()
 {
     transactionalStorage.Dispose();
 }
コード例 #8
0
 public void Dispose()
 {
     storage.Dispose();
 }
コード例 #9
0
        public void Dispose()
        {
            transactionalStorage.Dispose();

            IOExtensions.DeleteDirectory("test");
        }
コード例 #10
0
        public void Dispose()
        {
            storage.Dispose();

            IOExtensions.DeleteDirectory("test");
        }
コード例 #11
0
 public override void Dispose()
 {
     transactionalStorage.Dispose();
     base.Dispose();
 }