public HttpServer(InMemoryRavenConfiguration configuration, DocumentDatabase resourceStore) { HttpEndpointRegistration.RegisterHttpEndpointTarget(); DefaultResourceStore = resourceStore; DefaultConfiguration = configuration; int val; if (int.TryParse(configuration.Settings["Raven/Tenants/MaxIdleTimeForTenantDatabase"], out val) == false) { val = 900; } maxTimeDatabaseCanBeIdle = TimeSpan.FromSeconds(val); if (int.TryParse(configuration.Settings["Raven/Tenants/FrequnecyToCheckForIdleDatabases"], out val) == false) { val = 60; } frequnecyToCheckForIdleDatabases = TimeSpan.FromSeconds(val); configuration.Container.SatisfyImportsOnce(this); foreach (var responder in RequestResponders) { responder.Value.Initialize(() => currentDatabase.Value, () => currentConfiguration.Value, () => currentTenantId.Value, this); } switch (configuration.AuthenticationMode.ToLowerInvariant()) { case "windows": requestAuthorizer = new WindowsRequestAuthorizer(); break; case "oauth": requestAuthorizer = new OAuthRequestAuthorizer(); break; default: throw new InvalidOperationException( string.Format("Unknown AuthenticationMode {0}. Options are Windows and OAuth", configuration.AuthenticationMode)); } requestAuthorizer.Initialize(() => currentDatabase.Value, () => currentConfiguration.Value, () => currentTenantId.Value, this); }
public RavenDBOptions(InMemoryRavenConfiguration configuration, DocumentDatabase db = null) { if (configuration == null) { throw new ArgumentNullException("configuration"); } try { HttpEndpointRegistration.RegisterHttpEndpointTarget(); HttpEndpointRegistration.RegisterAdminLogsTarget(); if (db == null) { configuration.UpdateDataDirForLegacySystemDb(); systemDatabase = new DocumentDatabase(configuration); systemDatabase.SpinBackgroundWorkers(); } else { systemDatabase = db; } fileSystemLandlord = new FileSystemsLandlord(systemDatabase); databasesLandlord = new DatabasesLandlord(systemDatabase); countersLandlord = new CountersLandlord(systemDatabase); requestManager = new RequestManager(databasesLandlord); mixedModeRequestAuthorizer = new MixedModeRequestAuthorizer(); webSocketBufferPool = new WebSocketBufferPool(configuration.WebSockets.InitialBufferPoolSize); mixedModeRequestAuthorizer.Initialize(systemDatabase, new RavenServer(databasesLandlord.SystemDatabase, configuration)); } catch { if (systemDatabase != null) { systemDatabase.Dispose(); } throw; } }
public RavenDBOptions(InMemoryRavenConfiguration configuration, DocumentDatabase db = null) { if (configuration == null) { throw new ArgumentNullException("configuration"); } try { HttpEndpointRegistration.RegisterHttpEndpointTarget(); if (db == null) { systemDatabase = new DocumentDatabase(configuration); systemDatabase.SpinBackgroundWorkers(); } else { systemDatabase = db; } var transportState = systemDatabase.TransportState; fileSystemLandlord = new FileSystemsLandlord(systemDatabase, transportState); databasesLandlord = new DatabasesLandlord(systemDatabase); countersLandlord = new CountersLandlord(systemDatabase); requestManager = new RequestManager(databasesLandlord); mixedModeRequestAuthorizer = new MixedModeRequestAuthorizer(); mixedModeRequestAuthorizer.Initialize(systemDatabase, new RavenServer(databasesLandlord.SystemDatabase, configuration)); } catch { if (systemDatabase != null) { systemDatabase.Dispose(); } throw; } }
public RavenDBOptions(InMemoryRavenConfiguration configuration, DocumentDatabase db = null) { if (configuration == null) { throw new ArgumentNullException("configuration"); } try { ThreadPool.SetMinThreads(configuration.MinThreadPoolWorkerThreads, configuration.MinThreadPoolCompletionThreads); HttpEndpointRegistration.RegisterHttpEndpointTarget(); HttpEndpointRegistration.RegisterAdminLogsTarget(); if (db == null) { configuration.UpdateDataDirForLegacySystemDb(); systemDatabase = new DocumentDatabase(configuration, null, null, (sender, exception) => { if (log.IsInfoEnabled) { log.ErrorException( @"Found errors in the system database while loading it for the first time. This is recoverable error, since we will simply ingore transactions after the faulted one.", exception); } }); systemDatabase.SpinBackgroundWorkers(false); } else { systemDatabase = db; } WebSocketBufferPool.Initialize(configuration.WebSockets.InitialBufferPoolSize); fileSystemLandlord = new FileSystemsLandlord(systemDatabase); databasesLandlord = new DatabasesLandlord(systemDatabase); countersLandlord = new CountersLandlord(systemDatabase); timeSeriesLandlord = new TimeSeriesLandlord(systemDatabase); requestManager = new RequestManager(databasesLandlord); systemDatabase.RequestManager = requestManager; ClusterManager = new Reference <ClusterManager>(); systemDatabase.ClusterManager = ClusterManager; mixedModeRequestAuthorizer = new MixedModeRequestAuthorizer(); mixedModeRequestAuthorizer.Initialize(systemDatabase, new RavenServer(databasesLandlord.SystemDatabase, configuration)); serverStartupTasks = configuration.Container.GetExportedValues <IServerStartupTask>(); foreach (var task in serverStartupTasks) { toDispose.Add(task); try { task.Execute(this); } catch (Exception e) { systemDatabase.LogErrorAndAddAlertOnStartupTaskException(task.GetType().FullName, e); } } } catch (Exception e) { if (systemDatabase != null) { systemDatabase.Dispose(); } throw; } }