public void Run(HostArguments args)
        {
            var settings          = new Settings(args.ServiceName);
            var documentStore     = new EmbeddableDocumentStore();
            var markerFileService = new MarkerFileService(new LoggingSettings(settings.ServiceName).LogPath);

            new RavenBootstrapper().StartRaven(documentStore, settings, markerFileService, true);

            if (Environment.UserInteractive)
            {
                Console.Out.WriteLine("RavenDB is now accepting requests on {0}", settings.StorageUrl);
                Console.Out.WriteLine("RavenDB Maintenance Mode - Press Enter to exit");
                while (Console.ReadKey().Key != ConsoleKey.Enter)
                {
                }

                documentStore.Dispose();

                return;
            }

            using (var service = new MaintenanceHost(settings, documentStore))
            {
                service.Run();
            }
        }
Exemple #2
0
 public void Dispose()
 {
     if (documentStore != null)
     {
         documentStore.Dispose();
     }
 }
Exemple #3
0
        public EmbeddableDocumentStore NewDocumentStore(
            bool runInMemory              = true,
            string requestedStorage       = null,
            ComposablePartCatalog catalog = null,
            bool deleteDirectory          = true,
            bool deleteDirectoryOnDispose = true)
        {
            path = Path.GetDirectoryName(Assembly.GetAssembly(typeof(RavenTestBase)).CodeBase);
            path = Path.Combine(path, DataDir).Substring(6);

            var storageType   = GetDefaultStorageType(requestedStorage);
            var documentStore = new EmbeddableDocumentStore
            {
                Configuration =
                {
                    DefaultStorageTypeName = storageType,
                    DataDirectory          = path,
                    RunInUnreliableYetFastModeThatIsNotSuitableForProduction = true,
                    RunInMemory = storageType.Equals("esent", StringComparison.OrdinalIgnoreCase) == false && runInMemory,
                    Port        = 8079
                }
            };

            if (catalog != null)
            {
                documentStore.Configuration.Catalog.Catalogs.Add(catalog);
            }

            try
            {
                ModifyStore(documentStore);
                ModifyConfiguration(documentStore.Configuration);

                if (deleteDirectory)
                {
                    IOExtensions.DeleteDirectory(path);
                }

                documentStore.Initialize();

                CreateDefaultIndexes(documentStore);

                if (deleteDirectoryOnDispose)
                {
                    documentStore.Disposed += ClearDatabaseDirectory;
                }

                return(documentStore);
            }
            catch
            {
                // We must dispose of this object in exceptional cases, otherwise this test will break all the following tests.
                documentStore.Dispose();
                throw;
            }
            finally
            {
                stores.Add(documentStore);
            }
        }
 public static void Cleanup()
 {
     if (instanceDefault != null)
     {
         instanceDefault.Dispose();
         instanceDefault = null;
     }
 }
Exemple #5
0
 public void Stop()
 {
     notifier.Dispose();
     bus?.Dispose();
     timeKeeper.Dispose();
     documentStore.Dispose();
     WebApp?.Dispose();
     container.Dispose();
 }
        public void Dispose()
        {
            ListToDispose
            .Where(documentStore => documentStore != null)
            .ForEach(store => store.Dispose());

            if (Embedded != null)
            {
                Embedded.Dispose();
            }
        }
Exemple #7
0
        public void RunningInEmbeddedMode()
        {
            #region running_in_embedded_mode
            var documentStore = new EmbeddableDocumentStore {
                DataDirectory = "path/to/database/directory"
            };
            documentStore.Initialize();

            #endregion

            documentStore.Dispose();
        }
Exemple #8
0
        public void Dispose()
        {
            foreach (var documentStore in ListToDispose)
            {
                documentStore.Dispose();
            }

            if (Embedded != null)
            {
                Embedded.Dispose();
            }
        }
Exemple #9
0
        public EmbeddableDocumentStore NewDocumentStore(
            bool runInMemory              = true,
            string requestedStorage       = null,
            ComposablePartCatalog catalog = null,
            string dataDir            = null,
            bool enableAuthentication = false)
        {
            var storageType   = GetDefaultStorageType(requestedStorage);
            var documentStore = new EmbeddableDocumentStore
            {
                Configuration =
                {
                    DefaultStorageTypeName = storageType,
                    DataDirectory          = dataDir ?? NewDataPath(),
                    RunInUnreliableYetFastModeThatIsNotSuitableForProduction = true,
                    RunInMemory = storageType.Equals("esent", StringComparison.OrdinalIgnoreCase) == false && runInMemory,
                    Port        = 8079
                }
            };

            if (catalog != null)
            {
                documentStore.Configuration.Catalog.Catalogs.Add(catalog);
            }

            try
            {
                ModifyStore(documentStore);
                ModifyConfiguration(documentStore.Configuration);

                documentStore.Initialize();

                if (enableAuthentication)
                {
                    EnableAuthentication(documentStore.DocumentDatabase);
                    ModifyConfiguration(documentStore.Configuration);
                }

                CreateDefaultIndexes(documentStore);

                return(documentStore);
            }
            catch
            {
                // We must dispose of this object in exceptional cases, otherwise this test will break all the following tests.
                documentStore.Dispose();
                throw;
            }
            finally
            {
                stores.Add(documentStore);
            }
        }
Exemple #10
0
 public void TestCleanup()
 {
     if (_session != null)
     {
         _session.Dispose();
         _session = null;
     }
     if (_documentStore != null)
     {
         _documentStore.Dispose();
         _documentStore = null;
     }
 }
Exemple #11
0
        private static void Main()
        {
            // Initialize the database and create indexes
            var documentStore = new EmbeddableDocumentStore {
                UseEmbeddedHttpServer = true,
#if DEBUG
                RunInMemory = true
#endif
            };

            _documentStore = documentStore;
            documentStore.SetStudioConfigToAllowSingleDb();
            documentStore.Configuration.AnonymousUserAccessMode = AnonymousUserAccessMode.All;
            documentStore.Configuration.Settings.Add("Raven/ActiveBundles", "Expiration");
            documentStore.Configuration.Settings.Add("Raven/Expiration/DeleteFrequencySeconds", "10");
            documentStore.Initialize();
            IndexCreation.CreateIndexes(typeof(Program).Assembly, documentStore);

            // Set up some pressure gauge simulators at different starting points and speeds
            AddPressureGauge("Pressure Gague 1", 30, 10);
            AddPressureGauge("Pressure Gague 2", 50, 20);
            AddPressureGauge("Pressure Gague 3", 70, 30);

            // Set up the polling timer to read the gauges periodically
            PollingTimer.Interval = TakeReadingsEvery.TotalMilliseconds;
            PollingTimer.Elapsed += PollingTimerElapsed;
            PollingTimer.Start();

            while (DoMenu())
            {
            }

            PollingTimer.Stop();
            PollingTimer.Dispose();
            foreach (var sensor in Sensors.Values)
            {
                sensor.Dispose();
            }

            documentStore.DocumentDatabase.StopBackgroundWorkers();
            documentStore.Dispose();
        }
Exemple #12
0
 public virtual void Dispose()
 {
     documentStore.Dispose();
 }
 public void Dispose()
 {
     documentStore?.Dispose();
 }
Exemple #14
0
 public override void Dispose()
 {
     documentStore.Dispose();
     base.Dispose();
 }
 protected override void OnStop()
 {
     documentStore?.Dispose();
 }
 void IDisposable.Dispose()
 {
     documentStore.Dispose();
 }
Exemple #17
0
 public void Dispose()
 {
     CloseCurrentSession();
     store.Dispose();
 }
Exemple #18
0
        public EmbeddableDocumentStore NewDocumentStore(
            bool runInMemory              = true,
            string requestedStorage       = null,
            ComposablePartCatalog catalog = null,
            string dataDir            = null,
            bool enableAuthentication = false,
            string activeBundles      = null,
            int?port = null,
            AnonymousUserAccessMode anonymousUserAccessMode = AnonymousUserAccessMode.Admin,
            Action <EmbeddableDocumentStore> configureStore = null,
            [CallerMemberName] string databaseName          = null)
        {
            databaseName = NormalizeDatabaseName(databaseName);

            var storageType   = GetDefaultStorageType(requestedStorage);
            var dataDirectory = dataDir ?? NewDataPath(databaseName);
            var documentStore = new EmbeddableDocumentStore
            {
                UseEmbeddedHttpServer = port.HasValue,
                Configuration         =
                {
                    DefaultStorageTypeName  = storageType,
                    DataDirectory           = Path.Combine(dataDirectory,                "System"),
                    FileSystemDataDirectory = Path.Combine(dataDirectory,                "FileSystem"),
                    RunInUnreliableYetFastModeThatIsNotSuitableForProduction = true,
                    RunInMemory             = storageType.Equals("esent",                StringComparison.OrdinalIgnoreCase) == false && runInMemory,
                    Port                    = port == null ? 8079 : port.Value,
                    UseFips                 = SettingsHelper.UseFipsEncryptionAlgorithms,
                    AnonymousUserAccessMode = anonymousUserAccessMode,
                }
            };

            if (activeBundles != null)
            {
                documentStore.Configuration.Settings["Raven/ActiveBundles"] = activeBundles;
            }

            if (catalog != null)
            {
                documentStore.Configuration.Catalog.Catalogs.Add(catalog);
            }

            try
            {
                if (configureStore != null)
                {
                    configureStore(documentStore);
                }
                ModifyStore(documentStore);
                ModifyConfiguration(documentStore.Configuration);
                documentStore.Configuration.PostInit();
                documentStore.Initialize();

                if (enableAuthentication)
                {
                    EnableAuthentication(documentStore.DocumentDatabase);
                }

                CreateDefaultIndexes(documentStore);

                return(documentStore);
            }
            catch
            {
                // We must dispose of this object in exceptional cases, otherwise this test will break all the following tests.
                documentStore.Dispose();
                throw;
            }
            finally
            {
                stores.Add(documentStore);
            }
        }
 public void Teardown()
 {
     documentStore.Dispose();
 }
Exemple #20
0
        /// <summary>
        /// Creates a new Embeddable document store.
        /// </summary>
        /// <param name="runInMemory">Whatever the database should run purely in memory. When running in memory, nothing is written to disk and if the server is restarted all data will be lost.<br/>Default: <b>true</b></param>
        /// <param name="requestedStorage">What storage type to use (see: RavenDB Storage engines).<br/>Allowed values: <b>vornon</b>, <b>esent</b>.<br/>Default: <b>voron</b></param>
        /// <param name="catalog">Custom bundles that are not provided by RavenDb.</param>
        /// <param name="dataDir">The path for the database directory. Can use ~\ as the root, in which case the path will start from the server base directory. <br/>Default: <b>~\Databases\System</b></param>
        /// <param name="enableAuthentication"></param>
        /// <param name="activeBundles">Semicolon separated list of bundles names, such as: 'Replication;Versioning'.<br/>Default: no bundles turned on.</param>
        /// <param name="port">The port to use when creating the http listener. Allowed: 1 - 65,536 or * (find first available port from 8079 and upward).<br/>Default: <b>8079</b></param>
        /// <param name="anonymousUserAccessMode">Determines what actions an anonymous user can do. Get - read only, All - read & write, None - allows access to only authenticated users, Admin - all (including administrative actions).<br/>Default: <b>Get</b></param>
        /// <param name="configureStore">An action delegate which allows you to configure the document store instance that is returned. eg. <code>configureStore: store => store.DefaultDatabase = "MasterDb"</code></param>
        /// <param name="databaseName">Name of the server that will show up on /admin/stats endpoint.</param>
        /// <param name="indexes">A collection of indexes to execute.</param>
        /// <param name="transformers">A collection of transformers to execute.</param>
        /// <param name="seedData">A collection of some fake data that will be automatically stored into the document store.</param>
        /// <param name="noStaleQueries">When you query an index, the query will wait for the index to complete it's indexing and not be stale -before- the query is executed.</param>
        /// <param name="conventions">The conventions to be used when creating a new embeddable document store</param>
        /// <remarks>Besides the document store being instantiated, it is also Initialized.<br/>Also, if you provide some indexes to be used, make sure you understand that they might be stale when you query them. To make sure you're querying against indexes that have completed their indexing (ie. index is not stale), use the <code>noStaleQueries</code> parameter to determine if you wish to query against a stale or not-stale query.</remarks>
        /// <returns>A new instance of an EmbeddableDocumentStore.</returns>
        public EmbeddableDocumentStore NewDocumentStore(
            bool runInMemory              = true,
            string requestedStorage       = null,
            ComposablePartCatalog catalog = null,
            string dataDir            = null,
            bool enableAuthentication = false,
            string activeBundles      = null,
            int?port = null,
            AnonymousUserAccessMode anonymousUserAccessMode            = AnonymousUserAccessMode.Admin,
            Action <EmbeddableDocumentStore> configureStore            = null,
            [CallerMemberName] string databaseName                     = null,
            IEnumerable <AbstractIndexCreationTask> indexes            = null,
            IEnumerable <AbstractTransformerCreationTask> transformers = null,
            IEnumerable <IEnumerable> seedData = null,
            bool noStaleQueries            = false,
            DocumentConvention conventions = null)
        {
            databaseName = NormalizeDatabaseName(databaseName);

            var storageType   = GetDefaultStorageType(requestedStorage);
            var dataDirectory = dataDir ?? NewDataPath(databaseName);
            var documentStore = new EmbeddableDocumentStore
            {
                UseEmbeddedHttpServer = port.HasValue,
                Conventions           = conventions ?? new DocumentConvention()
            };

            ConfigurationHelper.ApplySettingsToConfiguration(documentStore.Configuration);

            documentStore.Configuration.DefaultStorageTypeName = storageType;
            documentStore.Configuration.DataDirectory          = Path.Combine(dataDirectory, "System");
            documentStore.Configuration.RunInUnreliableYetFastModeThatIsNotSuitableForProduction = true;
            documentStore.Configuration.RunInMemory             = storageType.Equals("esent", StringComparison.OrdinalIgnoreCase) == false && runInMemory;
            documentStore.Configuration.Port                    = port ?? 8079;
            documentStore.Configuration.AnonymousUserAccessMode = anonymousUserAccessMode;

            documentStore.Configuration.FileSystem.DataDirectory = Path.Combine(dataDirectory, "FileSystem");
            documentStore.Configuration.Encryption.UseFips       = ConfigurationHelper.UseFipsEncryptionAlgorithms;

            if (activeBundles != null)
            {
                documentStore.Configuration.Settings["Raven/ActiveBundles"] = activeBundles;
            }

            if (catalog != null)
            {
                documentStore.Configuration.Catalog.Catalogs.Add(catalog);
            }

            try
            {
                if (configureStore != null)
                {
                    configureStore(documentStore);
                }

                ModifyStore(documentStore);
                ModifyConfiguration(documentStore.Configuration);
                documentStore.Configuration.PostInit();
                documentStore.Initialize();

                if (enableAuthentication)
                {
                    EnableAuthentication(documentStore.SystemDatabase);
                }

                CreateDefaultIndexes(documentStore);

                if (indexes != null)
                {
                    ExecuteIndexes(indexes, documentStore);
                }

                if (noStaleQueries)
                {
                    documentStore.Listeners.RegisterListener(new NoStaleQueriesListener());
                }

                if (transformers != null)
                {
                    ExecuteTransformers(transformers, documentStore);
                }

                if (seedData != null)
                {
                    StoreSeedData(seedData, documentStore);
                }

                return(documentStore);
            }
            catch
            {
                // We must dispose of this object in exceptional cases, otherwise this test will break all the following tests.
                documentStore.Dispose();
                throw;
            }
            finally
            {
                stores.Add(documentStore);
            }
        }
Exemple #21
0
 public void TearDown()
 {
     _session.Dispose();
     _store.Dispose();
 }
 public void TearDown()
 {
     DocumentStore.Dispose();
 }
 public void Dispose()
 {
     _documentStore.Dispose();
 }
 /// <summary>
 /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
 /// </summary>
 /// <filterpriority>2</filterpriority>
 public void Dispose()
 {
     _session.Dispose();
     _documentStore.Dispose();
 }
 public void RavenDbWorkflowStoreTest_OneTimeTearDown()
 {
     _documentStore.Dispose();
 }
 public void CleanUp()
 {
     _documentStore.Dispose();
 }
Exemple #27
0
 public override void Dispose()
 {
     store.Dispose();
     base.Dispose();
     prefetchingBehavior.Dispose();
 }
 public void Dispose()
 {
     documentStore.Dispose();
     IOExtensions.DeleteDirectory(path);
 }
 public override void Dispose()
 {
     store.Dispose();
     base.Dispose();
 }
Exemple #30
0
 public void Cleanup()
 {
     _documentStore.Dispose();
     _documentStore = null;
 }