public RavenDB_1594() { path = NewDataPath(); pathsToDelete.Add("~/Databases"); Raven.Database.Extensions.IOExtensions.DeleteDirectory(path); var config = new Raven.Database.Config.RavenConfiguration { Port = 8079, RunInUnreliableYetFastModeThatIsNotSuitableForProduction = true, DataDirectory = path, Settings = { { "Raven/ActiveBundles", "PeriodicBackup" } }, }; config.PostInit(); ravenDbServer = new RavenDbServer(config) { UseEmbeddedHttpServer = true }; ravenDbServer.Initialize(); documentStore = new DocumentStore { Url = "http://localhost:8079" }; documentStore.Initialize(); }
public void StartDatabase(int index) { var previousServer = servers[index]; NonAdminHttp.EnsureCanListenToWhenInNonAdminContext(previousServer.SystemDatabase.Configuration.Port); var serverConfiguration = new RavenConfiguration { Settings = { { "Raven/ActiveBundles", "replication" } }, AnonymousUserAccessMode = AnonymousUserAccessMode.Admin, DataDirectory = previousServer.SystemDatabase.Configuration.DataDirectory, RunInUnreliableYetFastModeThatIsNotSuitableForProduction = true, RunInMemory = previousServer.SystemDatabase.Configuration.RunInMemory, Port = previousServer.SystemDatabase.Configuration.Port, DefaultStorageTypeName = GetDefaultStorageType() }; serverConfiguration.Encryption.UseFips = SettingsHelper.UseFipsEncryptionAlgorithms; ModifyConfiguration(serverConfiguration); serverConfiguration.PostInit(); var ravenDbServer = new RavenDbServer(serverConfiguration) { UseEmbeddedHttpServer = true }; ravenDbServer.Initialize(ConfigureServer); servers[index] = ravenDbServer; }
protected CompressionAndEncryption() { path = Path.GetDirectoryName(Assembly.GetAssembly(typeof(Versioning.Versioning)).CodeBase); path = Path.Combine(path, "TestDb").Substring(6); Raven.Database.Extensions.IOExtensions.DeleteDirectory(path); settings = new Raven.Database.Config.RavenConfiguration { Port = 8079, RunInUnreliableYetFastModeThatIsNotSuitableForProduction = true, MaxSecondsForTaskToWaitForDatabaseToLoad = 20, DataDirectory = path, Settings = { { "Raven/Encryption/Key", "3w17MIVIBLSWZpzH0YarqRlR2+yHiv1Zq3TCWXLEMI8=" }, { "Raven/ActiveBundles", "Compression;Encryption" } } }; ConfigureServer(settings); settings.PostInit(); ravenDbServer = new RavenDbServer(settings) { UseEmbeddedHttpServer = true }; ravenDbServer.Initialize(); documentStore = new DocumentStore { Url = "http://localhost:8079" }; documentStore.Initialize(); }
private static RavenDbServer CreateNewServer(InMemoryRavenConfiguration configuration, bool deleteData) { var port = configuration.Port.ToString(CultureInfo.InvariantCulture); configuration.DataDirectory = Path.Combine(Context.DataDir, port, "System"); configuration.FileSystem.DataDirectory = Path.Combine(Context.DataDir, port, "FileSystem"); configuration.AccessControlAllowOrigin = new HashSet <string> { "*" }; if (configuration.RunInMemory == false && deleteData) { var pathToDelete = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Context.DataDir, port); Context.DeleteDirectory(pathToDelete); } NonAdminHttp.EnsureCanListenToWhenInNonAdminContext(configuration.Port); var server = new RavenDbServer(configuration) { UseEmbeddedHttpServer = true }; server.Initialize(); Context.Servers.Add(configuration.Port, server); Console.WriteLine("Created a server (Port: {0}, RunInMemory: {1})", configuration.Port, configuration.RunInMemory); return(server); }
private RavenDbServer CreateServer(int port, string dataDirectory, bool removeDataDirectory = true) { Database.Server.NonAdminHttp.EnsureCanListenToWhenInNonAdminContext(port); var serverConfiguration = new Database.Config.RavenConfiguration { AnonymousUserAccessMode = Database.Server.AnonymousUserAccessMode.Admin, DataDirectory = dataDirectory, RunInUnreliableYetFastModeThatIsNotSuitableForProduction = true, RunInMemory = false, Port = port, DefaultStorageTypeName = "esent", MaxSecondsForTaskToWaitForDatabaseToLoad = 20 }; if (removeDataDirectory) { IOExtensions.DeleteDirectory(serverConfiguration.DataDirectory); } var server = new RavenDbServer(serverConfiguration) { UseEmbeddedHttpServer = true }; server.Initialize(); serverConfiguration.PostInit(); return(server); }
/// <summary> /// Creates the RavenDB server. /// </summary> private RavenDbServer CreateRavenDbServer() { var config = new RavenConfiguration { Port = Config.RavenHttpServerPort.GetValue(), AssembliesDirectory = Path.Combine(".", "Database", "Assemblies"), EmbeddedFilesDirectory = Path.Combine(".", "Database", "Files"), DataDirectory = Path.Combine(".", "Database", "Data"), CompiledIndexCacheDirectory = Path.Combine(".", "Database", "Raven", "CompiledIndexCache"), PluginsDirectory = Path.Combine(".", "Database", "Plugins"), MaxSecondsForTaskToWaitForDatabaseToLoad = 20, }; config.Settings.Add("Raven/CompiledIndexCacheDirectory", config.CompiledIndexCacheDirectory); var ravenDbServer = new RavenDbServer(config); ravenDbServer.Initialize(); ravenDbServer.DocumentStore.DefaultDatabase = Config.RavenName.GetValue(); ravenDbServer.DocumentStore.DatabaseCommands.GlobalAdmin.EnsureDatabaseExists(ravenDbServer.DocumentStore.DefaultDatabase); ravenDbServer.FilesStore.DefaultFileSystem = Config.RavenName.GetValue(); ravenDbServer.FilesStore.AsyncFilesCommands.Admin.EnsureFileSystemExistsAsync(ravenDbServer.FilesStore.DefaultFileSystem).Wait(); if (Config.EnableRavenHttpServer.GetValue()) { ravenDbServer.EnableHttpServer(); } this.CustomizeRavenDocumentStore(ravenDbServer.DocumentStore); return(ravenDbServer); }
protected void RecycleServer() { ravenDbServer.Dispose(); ravenDbServer = new RavenDbServer(settings) { UseEmbeddedHttpServer = true }; ravenDbServer.Initialize(); }
protected RavenDbServer CreateRavenDbServer(int port, string dataDirectory = null, bool runInMemory = true, string requestedStorage = null, bool enableAuthentication = false, string fileSystemName = null, Action <RavenConfiguration> customConfig = null) { NonAdminHttp.EnsureCanListenToWhenInNonAdminContext(port); var storageType = GetDefaultStorageType(requestedStorage); var directory = dataDirectory ?? NewDataPath(fileSystemName + "_" + port); var ravenConfiguration = new RavenConfiguration() { Port = port, DataDirectory = directory, RunInMemory = storageType.Equals("esent", StringComparison.OrdinalIgnoreCase) == false && runInMemory, #if DEBUG RunInUnreliableYetFastModeThatIsNotSuitableForProduction = runInMemory, #endif DefaultStorageTypeName = storageType, AnonymousUserAccessMode = enableAuthentication ? AnonymousUserAccessMode.None : AnonymousUserAccessMode.Admin, }; ravenConfiguration.Encryption.UseFips = SettingsHelper.UseFipsEncryptionAlgorithms; ravenConfiguration.FileSystem.MaximumSynchronizationInterval = this.SynchronizationInterval; ravenConfiguration.FileSystem.DataDirectory = Path.Combine(directory, "FileSystem"); ravenConfiguration.FileSystem.DefaultStorageTypeName = storageType; if (customConfig != null) { customConfig(ravenConfiguration); } if (enableAuthentication) { Authentication.EnableOnce(); } var ravenDbServer = new RavenDbServer(ravenConfiguration) { UseEmbeddedHttpServer = true }; ravenDbServer.Initialize(); servers.Add(ravenDbServer); if (enableAuthentication) { EnableAuthentication(ravenDbServer.SystemDatabase); } ConfigureServer(ravenDbServer, fileSystemName); return(ravenDbServer); }
static void Main(string[] args) { var ravenDbServer = new RavenDbServer(new RavenConfiguration { RunInMemory = true }); ravenDbServer.Initialize(); WorkWithDocumentStore(ravenDbServer.DocumentStore).Wait(); }
protected RavenDbServer GetNewServer(int port) { RavenDbServer ravenDbServer = new RavenDbServer(new RavenConfiguration { Port = port, RunInMemory = true, DataDirectory = "Data", AnonymousUserAccessMode = AnonymousUserAccessMode.Admin }) { UseEmbeddedHttpServer = true }; ravenDbServer.Initialize(); return(ravenDbServer); }
private void CreateServer() { IOExtensions.DeleteDirectory("HiLoData"); if (server != null) { server.Dispose(); } server = new RavenDbServer(new RavenConfiguration { Port = 8079, DataDirectory = "HiLoData", RunInUnreliableYetFastModeThatIsNotSuitableForProduction = true, AnonymousUserAccessMode = AnonymousUserAccessMode.Admin }) { UseEmbeddedHttpServer = true }; server.Initialize(); }
protected RavenDbServer GetNewServer(int port) { var dataDirectory = Path.Combine(NewDataPath(), "System"); var configuration = new RavenConfiguration { Port = port, DataDirectory = dataDirectory, AnonymousUserAccessMode = AnonymousUserAccessMode.Admin }; configuration.RunInMemory = configuration.DefaultStorageTypeName == InMemoryRavenConfiguration.VoronTypeName; var ravenDbServer = new RavenDbServer(configuration) { UseEmbeddedHttpServer = true }; ravenDbServer.Initialize(); return(ravenDbServer); }
/// <summary> /// Initializes this instance. /// </summary> /// <returns></returns> public IDocumentStore Initialize() { server.Initialize(); return(this); }
protected RavenDbServer CreateServer(int port, string dataDirectory = null, bool runInMemory = true, string requestedStorage = null, bool enableAuthentication = false, string fileSystemName = null, string activeBundles = null, Action <RavenConfiguration> customConfig = null) { NonAdminHttp.EnsureCanListenToWhenInNonAdminContext(port); var storageType = GetDefaultStorageType(requestedStorage); var directory = dataDirectory ?? NewDataPath(fileSystemName + "_" + port); var ravenConfiguration = new RavenConfiguration(); if (customConfig != null) { customConfig(ravenConfiguration); } ravenConfiguration.Port = port; ravenConfiguration.DataDirectory = directory; ravenConfiguration.RunInMemory = runInMemory; #if DEBUG ravenConfiguration.RunInUnreliableYetFastModeThatIsNotSuitableForProduction = runInMemory; #endif ravenConfiguration.DefaultStorageTypeName = storageType; ravenConfiguration.AnonymousUserAccessMode = enableAuthentication ? AnonymousUserAccessMode.None : AnonymousUserAccessMode.Admin; ravenConfiguration.Encryption.UseFips = ConfigurationHelper.UseFipsEncryptionAlgorithms; ravenConfiguration.MaxSecondsForTaskToWaitForDatabaseToLoad = 20; ravenConfiguration.FileSystem.MaximumSynchronizationInterval = SynchronizationInterval; ravenConfiguration.FileSystem.DataDirectory = Path.Combine(directory, "FileSystems"); ravenConfiguration.FileSystem.DefaultStorageTypeName = storageType; if (activeBundles != null) { ravenConfiguration.Settings[Constants.ActiveBundles] = activeBundles; } if (enableAuthentication) { Authentication.EnableOnce(); } var ravenDbServer = new RavenDbServer(ravenConfiguration) { UseEmbeddedHttpServer = true, }; ravenDbServer.Initialize(); servers.Add(ravenDbServer); if (enableAuthentication) { EnableAuthentication(ravenDbServer.SystemDatabase); } ConfigureServer(ravenDbServer, fileSystemName); return(ravenDbServer); }
protected RavenDbServer GetNewServer(int port = 8079, string dataDirectory = null, bool runInMemory = true, string requestedStorage = null, bool enableAuthentication = false, string activeBundles = null, Action <RavenDBOptions> configureServer = null, Action <InMemoryRavenConfiguration> configureConfig = null, [CallerMemberName] string databaseName = null) { databaseName = NormalizeDatabaseName(databaseName != Constants.SystemDatabase ? databaseName : null); checkPorts = true; if (dataDirectory != null) { pathsToDelete.Add(dataDirectory); } var storageType = GetDefaultStorageType(requestedStorage); var directory = dataDirectory ?? NewDataPath(databaseName == Constants.SystemDatabase ? null : databaseName); var ravenConfiguration = new RavenConfiguration(); ConfigurationHelper.ApplySettingsToConfiguration(ravenConfiguration); ravenConfiguration.Port = port; ravenConfiguration.DataDirectory = Path.Combine(directory, "System"); ravenConfiguration.RunInMemory = runInMemory; #if DEBUG ravenConfiguration.RunInUnreliableYetFastModeThatIsNotSuitableForProduction = runInMemory; #endif ravenConfiguration.DefaultStorageTypeName = storageType; ravenConfiguration.AnonymousUserAccessMode = enableAuthentication ? AnonymousUserAccessMode.None : AnonymousUserAccessMode.Admin; ravenConfiguration.FileSystem.DataDirectory = Path.Combine(directory, "FileSystem"); ravenConfiguration.Encryption.UseFips = ConfigurationHelper.UseFipsEncryptionAlgorithms; ravenConfiguration.Settings["Raven/StorageTypeName"] = ravenConfiguration.DefaultStorageTypeName; if (activeBundles != null) { ravenConfiguration.Settings["Raven/ActiveBundles"] = activeBundles; } if (configureConfig != null) { configureConfig(ravenConfiguration); } ModifyConfiguration(ravenConfiguration); ravenConfiguration.PostInit(); NonAdminHttp.EnsureCanListenToWhenInNonAdminContext(ravenConfiguration.Port); var ravenDbServer = new RavenDbServer(ravenConfiguration) { UseEmbeddedHttpServer = true, }; ravenDbServer.Initialize(configureServer); servers.Add(ravenDbServer); try { using (var documentStore = new DocumentStore { Url = "http://localhost:" + port, Conventions = { FailoverBehavior = FailoverBehavior.FailImmediately }, DefaultDatabase = databaseName }.Initialize()) { CreateDefaultIndexes(documentStore); } } catch { ravenDbServer.Dispose(); throw; } if (enableAuthentication) { EnableAuthentication(ravenDbServer.SystemDatabase); ModifyConfiguration(ravenConfiguration); ravenConfiguration.PostInit(); } return(ravenDbServer); }
/// <summary> /// Initializes this instance. /// </summary> /// <returns></returns> public IDocumentStore Initialize() { server.Initialize(); JsonRequestFactory.DisableRequestCompression = true; return(this); }