Пример #1
0
        protected RavenConfiguration CreateConfiguration(
            string tenantId,
            FileSystemDocument document,
            string folderPropName,
            RavenConfiguration parentConfiguration)
        {
            var config = RavenConfiguration.CreateFrom(parentConfiguration);

            SetupTenantConfiguration(config);

            config.CustomizeValuesForFileSystemTenant(tenantId);

            foreach (var setting in document.Settings)
            {
                config.SetSetting(setting.Key, setting.Value);
            }
            Unprotect(document);

            foreach (var securedSetting in document.SecuredSettings)
            {
                config.SetSetting(securedSetting.Key, securedSetting.Value);
            }

            config.SetSetting(folderPropName, config.GetSetting(folderPropName).ToFullPath(parentConfiguration.FileSystem.DataDirectory));
            config.FileSystemName = tenantId;

            config.Initialize();
            config.CopyParentSettings(parentConfiguration);
            return(config);
        }
Пример #2
0
        protected RavenConfiguration CreateConfiguration(
            string tenantId,
            CounterStorageDocument document,
            string folderPropName,
            RavenConfiguration parentConfiguration)
        {
            var config = RavenConfiguration.CreateFrom(parentConfiguration);

            SetupTenantConfiguration(config);

            config.CustomizeValuesForCounterStorageTenant(tenantId);

            foreach (var setting in document.Settings)
            {
                config.SetSetting(setting.Key, setting.Value);
            }

            Unprotect(document);

            foreach (var securedSetting in document.SecuredSettings)
            {
                config.SetSetting(securedSetting.Key, securedSetting.Value);
            }

            config.SetSetting(folderPropName, config.GetSetting(folderPropName).ToFullPath(parentConfiguration.Counter.DataDirectory));
            config.SetSetting(RavenConfiguration.GetKey(x => x.Storage.JournalsStoragePath), config.GetSetting(RavenConfiguration.GetKey(x => x.Storage.JournalsStoragePath)).ToFullPath(parentConfiguration.Core.DataDirectory));

            config.CounterStorageName = tenantId;

            config.Initialize();
            config.CopyParentSettings(parentConfiguration);
            return(config);
        }
Пример #3
0
        public void Default_database_path_settings()
        {
            var config = new RavenConfiguration("foo", ResourceType.Database, _emptySettingFile);

            config.SetSetting(RavenConfiguration.GetKey(x => x.Core.RunInMemory), "true");

            config.Initialize();

            Assert.Equal(new PathSetting("Databases/foo").FullPath, config.Core.DataDirectory.FullPath);
            Assert.Equal(new PathSetting("Databases/foo/Indexes").FullPath, config.Indexing.StoragePath.FullPath);

            Assert.Null(config.Indexing.TempPath);

            Assert.Null(config.Storage.TempPath);

            // actual configuration is created in the following manner

            config = RavenConfiguration.CreateFrom(new RavenConfiguration(null, ResourceType.Server, _emptySettingFile), "foo",
                                                   ResourceType.Database);

            config.Initialize();

            Assert.Equal(new PathSetting("Databases/foo").FullPath, config.Core.DataDirectory.FullPath);
            Assert.Equal(new PathSetting("Databases/foo/Indexes").FullPath, config.Indexing.StoragePath.FullPath);

            Assert.Null(config.Indexing.TempPath);

            Assert.Null(config.Storage.TempPath);
        }
Пример #4
0
        public void Resource_specific_paths_do_not_require_any_suffixes()
        {
            var server = new RavenConfiguration(null, ResourceType.Server);

            server.SetSetting(RavenConfiguration.GetKey(x => x.Core.RunInMemory), "true");

            server.SetSetting(RavenConfiguration.GetKey(x => x.Core.DataDirectory), $@"{_rootPathString}Deployment");

            server.SetSetting(RavenConfiguration.GetKey(x => x.Storage.TempPath), $@"{_rootPathString}temp");

            server.SetSetting(RavenConfiguration.GetKey(x => x.Indexing.TempPath), $@"{_rootPathString}indexes-temp");

            server.Initialize();

            var database = RavenConfiguration.CreateFrom(server, "Foo", ResourceType.Database);

            database.SetSetting(RavenConfiguration.GetKey(x => x.Core.DataDirectory), $@"{_rootPathString}MyDatabase");

            database.SetSetting(RavenConfiguration.GetKey(x => x.Storage.TempPath), $@"{_rootPathString}my-temp-path");

            database.SetSetting(RavenConfiguration.GetKey(x => x.Indexing.TempPath), $@"{_rootPathString}my-indexes-temp");

            database.Initialize();

            Assert.Equal(new PathSetting($@"{_rootPathString}MyDatabase").FullPath, database.Core.DataDirectory.FullPath);

            Assert.Equal(new PathSetting($@"{_rootPathString}my-temp-path").FullPath, database.Storage.TempPath.FullPath);

            Assert.Equal(new PathSetting($@"{_rootPathString}my-indexes-temp").FullPath, database.Indexing.TempPath.FullPath);
        }
Пример #5
0
        public void Inherits_server_settings_and_appends_resource_specific_suffix_paths()
        {
            var server = new RavenConfiguration(null, ResourceType.Server);

            server.SetSetting(RavenConfiguration.GetKey(x => x.Core.RunInMemory), "true");

            server.SetSetting(RavenConfiguration.GetKey(x => x.Core.DataDirectory), $@"{_rootPathString}Deployment");

            server.SetSetting(RavenConfiguration.GetKey(x => x.Storage.TempPath), $@"{_rootPathString}temp");
            server.SetSetting(RavenConfiguration.GetKey(x => x.Storage.JournalsStoragePath), $@"{_rootPathString}Journals");

            server.SetSetting(RavenConfiguration.GetKey(x => x.Indexing.StoragePath), $@"{_rootPathString}Indexes");
            server.SetSetting(RavenConfiguration.GetKey(x => x.Indexing.TempPath), $@"{_rootPathString}indexes-temp");
            server.SetSetting(RavenConfiguration.GetKey(x => x.Indexing.JournalsStoragePath), $@"{_rootPathString}Indexes-Journals");

            server.Initialize();

            var database = RavenConfiguration.CreateFrom(server, "Foo", ResourceType.Database);

            database.Initialize();

            Assert.Equal(new PathSetting($@"{_rootPathString}Deployment\Databases\Foo").FullPath, database.Core.DataDirectory.FullPath);

            Assert.Equal(new PathSetting($@"{_rootPathString}temp\Databases\Foo").FullPath, database.Storage.TempPath.FullPath);
            Assert.Equal(new PathSetting($@"{_rootPathString}Journals\Databases\Foo").FullPath, database.Storage.JournalsStoragePath.FullPath);

            Assert.Equal(new PathSetting($@"{_rootPathString}Indexes\Databases\Foo").FullPath, database.Indexing.StoragePath.FullPath);
            Assert.Equal(new PathSetting($@"{_rootPathString}indexes-temp\Databases\Foo").FullPath, database.Indexing.TempPath.FullPath);
            Assert.Equal(new PathSetting($@"{_rootPathString}Indexes-Journals\Databases\Foo").FullPath, database.Indexing.JournalsStoragePath.FullPath);
        }
Пример #6
0
        protected RavenConfiguration CreateConfiguration(StringSegment databaseName, DatabaseDocument document, string folderPropName)
        {
            var config = RavenConfiguration.CreateFrom(ServerStore.Configuration);

            foreach (var setting in document.Settings)
            {
                config.SetSetting(setting.Key, setting.Value);
            }
            Unprotect(document);

            foreach (var securedSetting in document.SecuredSettings)
            {
                config.SetSetting(securedSetting.Key, securedSetting.Value);
            }
            var dbsBaseDir = ServerStore.Configuration.Core.DataDirectory;

            config.SetSetting(folderPropName, config.GetSetting(folderPropName).ToFullPath(dbsBaseDir));
            config.SetSetting(RavenConfiguration.GetKey(x => x.Storage.JournalsStoragePath), config.GetSetting(RavenConfiguration.GetKey(x => x.Storage.JournalsStoragePath)).ToFullPath(dbsBaseDir));

            config.DatabaseName = databaseName.ToString();

            config.Initialize();
            config.CopyParentSettings(ServerStore.Configuration);
            return(config);
        }
Пример #7
0
        public void ShouldWork()
        {
            var server = new RavenConfiguration(null, ResourceType.Server);

            server.SetSetting(RavenConfiguration.GetKey(x => x.Storage.ForceUsing32BitsPager), "true");
            server.Initialize(); // should not throw

            Assert.True(server.Storage.ForceUsing32BitsPager);

            var database = RavenConfiguration.CreateFrom(server, "dbName", ResourceType.Database);

            database.SetSetting(RavenConfiguration.GetKey(x => x.Storage.ForceUsing32BitsPager), "true");

            var e = Assert.Throws <InvalidOperationException>(() => database.Initialize());

            Assert.Equal($"Configuration '{RavenConfiguration.GetKey(x => x.Storage.ForceUsing32BitsPager)}' can only be set at server level.", e.Message);
        }
Пример #8
0
        public void Should_create_data_in_directory_specified_at_server_level()
        {
            var server = new RavenConfiguration(null, ResourceType.Server);

            server.SetSetting(RavenConfiguration.GetKey(x => x.Core.RunInMemory), "true");

            server.SetSetting(RavenConfiguration.GetKey(x => x.Core.DataDirectory), $@"{_rootPathString}RavenData");

            server.Initialize();

            var database = RavenConfiguration.CreateFrom(server, "Foo", ResourceType.Database);

            database.SetSetting(RavenConfiguration.GetKey(x => x.Core.DataDirectory), @"Items");

            database.Initialize();

            Assert.Equal(new PathSetting($@"{_rootPathString}RavenData\Items").FullPath, database.Core.DataDirectory.FullPath);
        }
Пример #9
0
        protected RavenConfiguration CreateConfiguration(
            string tenantId,
            DatabaseDocument document,
            string folderPropName,
            RavenConfiguration parentConfiguration)
        {
            var config = RavenConfiguration.CreateFrom(parentConfiguration);

            if (config.GetSetting(RavenConfiguration.GetKey(x => x.Core.CompiledIndexCacheDirectory)) == null)
            {
                var compiledIndexCacheDirectory = parentConfiguration.Core.CompiledIndexCacheDirectory;
                config.SetSetting(RavenConfiguration.GetKey(x => x.Core.CompiledIndexCacheDirectory), compiledIndexCacheDirectory);
            }

            if (config.GetSetting(RavenConfiguration.GetKey(x => x.Core.TempPath)) == null)
            {
                config.SetSetting(RavenConfiguration.GetKey(x => x.Core.TempPath), parentConfiguration.Core.TempPath);
            }

            SetupTenantConfiguration(config);

            config.CustomizeValuesForDatabaseTenant(tenantId);

            foreach (var setting in document.Settings)
            {
                config.SetSetting(setting.Key, setting.Value);
            }
            Unprotect(document);

            foreach (var securedSetting in document.SecuredSettings)
            {
                config.SetSetting(securedSetting.Key, securedSetting.Value);
            }

            config.SetSetting(folderPropName, config.GetSetting(folderPropName).ToFullPath(parentConfiguration.Core.DataDirectory));
            config.SetSetting(RavenConfiguration.GetKey(x => x.Storage.JournalsStoragePath), config.GetSetting(RavenConfiguration.GetKey(x => x.Storage.JournalsStoragePath)).ToFullPath(parentConfiguration.Core.DataDirectory));

            config.DatabaseName     = tenantId;
            config.IsTenantDatabase = true;

            config.Initialize();
            config.CopyParentSettings(parentConfiguration);
            return(config);
        }
Пример #10
0
        public void Database_creation_using_relative_path_creates_directories_incorrectly()
        {
            var server = new RavenConfiguration(null, ResourceType.Server);

            server.SetSetting(RavenConfiguration.GetKey(x => x.Core.RunInMemory), "true");
            server.SetSetting(RavenConfiguration.GetKey(x => x.Core.DataDirectory), "RavenData");

            server.Initialize();

            var database = RavenConfiguration.CreateFrom(server, "foo", ResourceType.Database);

            database.SetSetting(RavenConfiguration.GetKey(x => x.Core.RunInMemory), "true");
            database.SetSetting(RavenConfiguration.GetKey(x => x.Core.DataDirectory), @"MyWork\MyDatabaseFolder");

            database.Initialize();

            Assert.Equal(new PathSetting("RavenData/MyWork/MyDatabaseFolder").FullPath, database.Core.DataDirectory.FullPath);
            Assert.Equal(new PathSetting("RavenData/MyWork/MyDatabaseFolder/Indexes").FullPath, database.Indexing.StoragePath.FullPath);
        }
Пример #11
0
        public void Should_handle_APPDRIVE_properly_if_specified()
        {
            var server = new RavenConfiguration(null, ResourceType.Server);

            server.SetSetting(RavenConfiguration.GetKey(x => x.Core.RunInMemory), "true");

            server.SetSetting(RavenConfiguration.GetKey(x => x.Core.DataDirectory), @"APPDRIVE:\RavenData");

            server.Initialize();

            var rootPath = Path.GetPathRoot(AppContext.BaseDirectory);

            Assert.Equal(new PathSetting($@"{rootPath}RavenData").FullPath, server.Core.DataDirectory.FullPath);

            var database = RavenConfiguration.CreateFrom(server, "Foo", ResourceType.Database);

            database.Initialize();

            Assert.Equal(new PathSetting($@"{rootPath}RavenData\Databases\Foo").FullPath, database.Core.DataDirectory.FullPath);
            Assert.Equal(new PathSetting($@"{rootPath}RavenData\Databases\Foo\Indexes").FullPath, database.Indexing.StoragePath.FullPath);
        }