コード例 #1
0
        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);
                    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)
            {
                if (systemDatabase != null)
                {
                    systemDatabase.Dispose();
                }
                throw;
            }
        }
コード例 #2
0
        public RavenDBOptions(RavenConfiguration configuration, DocumentDatabase db = null)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

            try
            {
                HttpEndpointRegistration.RegisterHttpEndpointTarget();
                HttpEndpointRegistration.RegisterAdminLogsTarget();
                if (db == null)
                {
                    systemDatabase = new DocumentDatabase(configuration, null);
                    systemDatabase.SpinBackgroundWorkers(false);
                }
                else
                {
                    systemDatabase = db;
                }

                WebSocketBufferPool.Initialize((int)configuration.WebSockets.InitialBufferPoolSize.GetValue(SizeUnit.Bytes));
                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>();
                mixedModeRequestAuthorizer    = new MixedModeRequestAuthorizer();
                mixedModeRequestAuthorizer.Initialize(systemDatabase, new RavenServer(databasesLandlord.SystemDatabase, configuration));

                serverStartupTasks = configuration.Container.GetExportedValues <IServerStartupTask>();

                foreach (var task in serverStartupTasks)
                {
                    toDispose.Add(task);
                    task.Execute(this);
                }
            }
            catch (Exception)
            {
                if (systemDatabase != null)
                {
                    systemDatabase.Dispose();
                }
                throw;
            }
        }