public void Initialize() { HostName = Settings["Raven/HostName"]; var portStr = Settings["Raven/Port"]; Port = portStr != null?int.Parse(portStr) : 8080; RunInMemory = GetConfigurationValue <bool>("Raven/RunInMemory") ?? false; DataDirectory = Settings["Raven/DataDir"] ?? @"~\Data"; WebDir = Settings["Raven/WebDir"] ?? GetDefaultWebDir(); AccessControlAllowOrigin = Settings["Raven/AccessControlAllowOrigin"]; bool httpCompressionTemp; if (bool.TryParse(Settings["Raven/HttpCompression"], out httpCompressionTemp) == false) { httpCompressionTemp = true; } HttpCompression = httpCompressionTemp; VirtualDirectory = Settings["Raven/VirtualDirectory"] ?? "/"; if (VirtualDirectory.EndsWith("/")) { VirtualDirectory = VirtualDirectory.Substring(0, VirtualDirectory.Length - 1); } if (VirtualDirectory.StartsWith("/") == false) { VirtualDirectory = "/" + VirtualDirectory; } PluginsDirectory = Settings["Raven/PluginsDirectory"] ?? @"~\Plugins"; if (PluginsDirectory.StartsWith(@"~\")) { PluginsDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, PluginsDirectory.Substring(2)); } AnonymousUserAccessMode = GetAnonymousUserAccessMode(); }
public void Initialize() { HostName = Settings["Raven/HostName"]; var portStr = Settings["Raven/Port"]; Port = portStr != null?int.Parse(portStr) : 8080; var maxPageSizeStr = Settings["Raven/MaxPageSize"]; var minimumQueryCount = Settings["Raven/TempIndexPromotionMinimumQueryCount"]; var queryThreshold = Settings["Raven/TempIndexPromotionThreshold"]; var cleanupPeriod = Settings["Raven/TempIndexCleanupPeriod"]; var cleanupThreshold = Settings["Raven/TempIndexCleanupThreshold"]; var maxNumberOfItemsToIndexInSingleBatch = Settings["Raven/MaxNumberOfItemsToIndexInSingleBatch"]; var maxNumberOfParallelIndexTasks = Settings["Raven/MaxNumberOfParallelIndexTasks"]; var backgroundTasksPriority = Settings["Raven/BackgroundTasksPriority"]; BackgroundTasksPriority = backgroundTasksPriority == null ? ThreadPriority.Normal : (ThreadPriority)Enum.Parse(typeof(ThreadPriority), backgroundTasksPriority); MaxPageSize = maxPageSizeStr != null?int.Parse(maxPageSizeStr) : 1024; MaxPageSize = Math.Max(MaxPageSize, 10); MaxNumberOfItemsToIndexInSingleBatch = maxNumberOfItemsToIndexInSingleBatch != null?int.Parse(maxNumberOfItemsToIndexInSingleBatch) : 2500; MaxPageSize = Math.Max(MaxNumberOfItemsToIndexInSingleBatch, 128); MaxNumberOfParallelIndexTasks = maxNumberOfParallelIndexTasks != null?int.Parse(maxNumberOfParallelIndexTasks) : Environment.ProcessorCount; MaxNumberOfParallelIndexTasks = Math.Max(1, MaxNumberOfParallelIndexTasks); TempIndexPromotionMinimumQueryCount = minimumQueryCount != null?int.Parse(minimumQueryCount) : 100; TempIndexPromotionThreshold = queryThreshold != null?int.Parse(queryThreshold) : 60000; // once a minute TempIndexCleanupPeriod = cleanupPeriod != null?TimeSpan.FromSeconds(int.Parse(cleanupPeriod)) : TimeSpan.FromMinutes(10); TempIndexCleanupThreshold = cleanupThreshold != null?TimeSpan.FromSeconds(int.Parse(cleanupThreshold)) : TimeSpan.FromMinutes(20); RunInMemory = GetConfigurationValue <bool>("Raven/RunInMemory") ?? false; DataDirectory = Settings["Raven/DataDir"] ?? @"~\Data"; WebDir = Settings["Raven/WebDir"] ?? GetDefaultWebDir(); AccessControlAllowOrigin = Settings["Raven/AccessControlAllowOrigin"]; bool httpCompressionTemp; if (bool.TryParse(Settings["Raven/HttpCompression"], out httpCompressionTemp) == false) { httpCompressionTemp = true; } HttpCompression = httpCompressionTemp; var transactionMode = Settings["Raven/TransactionMode"]; TransactionMode result; if (Enum.TryParse(transactionMode, true, out result) == false) { result = TransactionMode.Safe; } TransactionMode = result; VirtualDirectory = Settings["Raven/VirtualDirectory"] ?? "/"; if (VirtualDirectory.EndsWith("/")) { VirtualDirectory = VirtualDirectory.Substring(0, VirtualDirectory.Length - 1); } if (VirtualDirectory.StartsWith("/") == false) { VirtualDirectory = "/" + VirtualDirectory; } PluginsDirectory = Settings["Raven/PluginsDirectory"] ?? @"~\Plugins"; if (PluginsDirectory.StartsWith(@"~\")) { PluginsDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, PluginsDirectory.Substring(2)); } AnonymousUserAccessMode = GetAnonymousUserAccessMode(); DefaultStorageTypeName = Settings["Raven/StorageTypeName"] ?? Settings["Raven/StorageEngine"] ?? // "esent"; "munin"; }
public void Initialize() { HostName = Settings["Raven/HostName"]; var endpoint = Settings["Raven/SubscriptionPort"]; if (endpoint != null) { SubscriptionPort = int.Parse(endpoint); } else { SubscriptionPort = 8182; } var portStr = Settings["Raven/Port"]; Port = portStr != null?int.Parse(portStr) : 8181; RunInMemory = GetConfigurationValue <bool>("Raven/RunInMemory") ?? false; MaxPageSize = GetConfigurationValue <int>("Raven/MaxPageSize") ?? 1024; DataDirectory = Settings["Raven/DataDir"] ?? @"~\Data"; WebDir = Settings["Raven/WebDir"] ?? GetDefaultWebDir(); AccessControlAllowOrigin = Settings["Raven/AccessControlAllowOrigin"]; bool httpCompressionTemp; if (bool.TryParse(Settings["Raven/HttpCompression"], out httpCompressionTemp) == false) { httpCompressionTemp = true; } HttpCompression = httpCompressionTemp; var transactionMode = Settings["Raven/TransactionMode"]; TransactionMode result; if (Enum.TryParse(transactionMode, true, out result) == false) { result = TransactionMode.Safe; } TransactionMode = result; VirtualDirectory = Settings["Raven/VirtualDirectory"] ?? "/"; if (VirtualDirectory.EndsWith("/")) { VirtualDirectory = VirtualDirectory.Substring(0, VirtualDirectory.Length - 1); } if (VirtualDirectory.StartsWith("/") == false) { VirtualDirectory = "/" + VirtualDirectory; } PluginsDirectory = Settings["Raven/PluginsDirectory"] ?? @"~\Plugins"; if (PluginsDirectory.StartsWith(@"~\")) { PluginsDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, PluginsDirectory.Substring(2)); } AnonymousUserAccessMode = GetAnonymousUserAccessMode(); }
public void Initialize() { // Core settings var maxPageSizeStr = Settings["Raven/MaxPageSize"]; MaxPageSize = maxPageSizeStr != null?int.Parse(maxPageSizeStr) : 1024; MaxPageSize = Math.Max(MaxPageSize, 10); var backgroundTasksPriority = Settings["Raven/BackgroundTasksPriority"]; BackgroundTasksPriority = backgroundTasksPriority == null ? ThreadPriority.Normal : (ThreadPriority)Enum.Parse(typeof(ThreadPriority), backgroundTasksPriority); var cacheMemoryLimitMegabytes = Settings["Raven/MemoryCacheLimitMegabytes"]; MemoryCacheLimitMegabytes = cacheMemoryLimitMegabytes == null ? GetDefaultMemoryCacheLimitMegabytes() : int.Parse(cacheMemoryLimitMegabytes); var memoryCacheLimitPercentage = Settings["Raven/MemoryCacheLimitPercentage"]; MemoryCacheLimitPercentage = memoryCacheLimitPercentage == null ? 0 // auto-size : int.Parse(memoryCacheLimitPercentage); var memoryCacheLimitCheckInterval = Settings["Raven/MemoryCacheLimitCheckInterval"]; MemoryCacheLimitCheckInterval = memoryCacheLimitCheckInterval == null ? MemoryCache.Default.PollingInterval : TimeSpan.Parse(memoryCacheLimitCheckInterval); // Index settings var maxNumberOfItemsToIndexInSingleBatch = Settings["Raven/MaxNumberOfItemsToIndexInSingleBatch"]; MaxNumberOfItemsToIndexInSingleBatch = maxNumberOfItemsToIndexInSingleBatch != null?int.Parse(maxNumberOfItemsToIndexInSingleBatch) : 2500; MaxNumberOfItemsToIndexInSingleBatch = Math.Max(MaxNumberOfItemsToIndexInSingleBatch, 128); var maxNumberOfParallelIndexTasks = Settings["Raven/MaxNumberOfParallelIndexTasks"]; MaxNumberOfParallelIndexTasks = maxNumberOfParallelIndexTasks != null?int.Parse(maxNumberOfParallelIndexTasks) : Environment.ProcessorCount; MaxNumberOfParallelIndexTasks = Math.Max(1, MaxNumberOfParallelIndexTasks); var minimumQueryCount = Settings["Raven/TempIndexPromotionMinimumQueryCount"]; TempIndexPromotionMinimumQueryCount = minimumQueryCount != null?int.Parse(minimumQueryCount) : 100; var queryThreshold = Settings["Raven/TempIndexPromotionThreshold"]; TempIndexPromotionThreshold = queryThreshold != null?int.Parse(queryThreshold) : 60000; // once a minute var cleanupPeriod = Settings["Raven/TempIndexCleanupPeriod"]; TempIndexCleanupPeriod = cleanupPeriod != null?TimeSpan.FromSeconds(int.Parse(cleanupPeriod)) : TimeSpan.FromMinutes(10); var cleanupThreshold = Settings["Raven/TempIndexCleanupThreshold"]; TempIndexCleanupThreshold = cleanupThreshold != null?TimeSpan.FromSeconds(int.Parse(cleanupThreshold)) : TimeSpan.FromMinutes(20); var tempMemoryMaxMb = Settings["Raven/TempIndexInMemoryMaxMB"]; TempIndexInMemoryMaxBytes = tempMemoryMaxMb != null?int.Parse(tempMemoryMaxMb) * 1024000 : 26214400; TempIndexInMemoryMaxBytes = Math.Max(1024000, TempIndexInMemoryMaxBytes); // Data settings RunInMemory = GetConfigurationValue <bool>("Raven/RunInMemory") ?? false; DefaultStorageTypeName = Settings["Raven/StorageTypeName"] ?? Settings["Raven/StorageEngine"] ?? "esent"; var transactionMode = Settings["Raven/TransactionMode"]; TransactionMode result; if (Enum.TryParse(transactionMode, true, out result) == false) { result = TransactionMode.Safe; } TransactionMode = result; DataDirectory = Settings["Raven/DataDir"] ?? @"~\Data"; if (string.IsNullOrEmpty(Settings["Raven/IndexStoragePath"]) == false) { IndexStoragePath = Settings["Raven/IndexStoragePath"]; } // HTTP settings HostName = Settings["Raven/HostName"]; Port = PortUtil.GetPort(Settings["Raven/Port"]); VirtualDirectory = Settings["Raven/VirtualDirectory"] ?? "/"; if (VirtualDirectory.EndsWith("/")) { VirtualDirectory = VirtualDirectory.Substring(0, VirtualDirectory.Length - 1); } if (VirtualDirectory.StartsWith("/") == false) { VirtualDirectory = "/" + VirtualDirectory; } bool httpCompressionTemp; if (bool.TryParse(Settings["Raven/HttpCompression"], out httpCompressionTemp) == false) { httpCompressionTemp = true; } HttpCompression = httpCompressionTemp; AccessControlAllowOrigin = Settings["Raven/AccessControlAllowOrigin"]; AnonymousUserAccessMode = GetAnonymousUserAccessMode(); // Misc settings WebDir = Settings["Raven/WebDir"] ?? GetDefaultWebDir(); PluginsDirectory = Settings["Raven/PluginsDirectory"] ?? @"~\Plugins"; if (PluginsDirectory.StartsWith(@"~\")) { PluginsDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, PluginsDirectory.Substring(2)); } // OAuth AuthenticationMode = Settings["Raven/AuthenticationMode"] ?? "windows"; }
public RavenConfiguration() { Settings = new Dictionary <string, string>(StringComparer.InvariantCultureIgnoreCase); foreach (string setting in ConfigurationManager.AppSettings) { if (setting.StartsWith("Raven/", StringComparison.InvariantCultureIgnoreCase)) { Settings[setting] = ConfigurationManager.AppSettings[setting]; } } Catalog = new AggregateCatalog( new AssemblyCatalog(typeof(DocumentDatabase).Assembly) ); Catalog.Changed += (sender, args) => ResetContainer(); var portStr = ConfigurationManager.AppSettings["Raven/Port"]; Port = portStr != null?int.Parse(portStr) : 8080; var indexBatchSizeStr = ConfigurationManager.AppSettings["Raven/IndexingBatchSize"]; IndexingBatchSize = indexBatchSizeStr != null?int.Parse(indexBatchSizeStr) : 1024; var maxPageSizeStr = ConfigurationManager.AppSettings["Raven/MaxPageSize"]; MaxPageSize = maxPageSizeStr != null?int.Parse(maxPageSizeStr) : 1024; DataDirectory = ConfigurationManager.AppSettings["Raven/DataDir"] ?? @"~\Data"; WebDir = ConfigurationManager.AppSettings["Raven/WebDir"] ?? GetDefaultWebDir(); var transactionMode = ConfigurationManager.AppSettings["Raven/TransactionMode"]; TransactionMode result; if (Enum.TryParse(transactionMode, true, out result) == false) { result = TransactionMode.Safe; } TransactionMode = result; VirtualDirectory = ConfigurationManager.AppSettings["Raven/VirtualDirectory"] ?? "/"; if (VirtualDirectory.EndsWith("/")) { VirtualDirectory = VirtualDirectory.Substring(0, VirtualDirectory.Length - 1); } if (VirtualDirectory.StartsWith("/") == false) { VirtualDirectory = "/" + VirtualDirectory; } PluginsDirectory = ConfigurationManager.AppSettings["Raven/PluginsDirectory"] ?? @"~\Plugins"; if (PluginsDirectory.StartsWith(@"~\")) { PluginsDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, PluginsDirectory.Substring(2)); } AnonymousUserAccessMode = GetAnonymousUserAccessMode(); StorageTypeName = ConfigurationManager.AppSettings["Raven/StorageTypeName"] ?? "Raven.Storage.Esent.TransactionalStorage, Raven.Storage.Esent"; ListenerProtocol listenerProtocol; if (!Enum.TryParse(ConfigurationManager.AppSettings["Raven/ListenerProtocol"] ?? "Http", true, out listenerProtocol)) { listenerProtocol = ListenerProtocol.Http; } ListenerProtocol = listenerProtocol; //StorageTypeName = ConfigurationManager.AppSettings["Raven/StorageTypeName"] ?? // "Raven.Storage.Managed.TransactionalStorage, Raven.Storage.Managed"; }