public virtual void LoadPlugins(PluginProviderLogErrorDelegate logError) { var toScan = new List <Assembly>(); foreach (var PluginsDirectory in PluginDirectories) { if (PluginsDirectory.Exists) { foreach (var file in PluginsDirectory.GetFiles(PluginsNameMask)) { String name = Path.GetFileNameWithoutExtension(file.Name); try { toScan.Add(Assembly.LoadFrom(file.FullName)); } catch (Exception ex) { logError(ex, "Error loading plugin :" + name); } } } } foreach (var asm in toScan) { try { var typesDiscovered = DiscoverTypesInAssembly(asm); OnAfterTypesDiscoveredInAssembly(typesDiscovered); } catch (ReflectionTypeLoadException rtle) { rtle.LoaderExceptions.Apply(e => logError(e, "Error loading types from plugin:" + asm.GetName())); } catch (Exception e) { logError(e, "Error loading types from plugin:" + asm.GetName()); } } AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve); }
public ExtensionsFromPluginProvider(Lifetime lifetime, ExtensionLocations extensionLocations, PluginsDirectory pluginsDirectory) { this.lifetime = lifetime; this.extensionLocations = extensionLocations; this.pluginsDirectory = pluginsDirectory; extensions = new CollectionEvents <IExtension>(lifetime, "ExtensionsFromPluginProvider"); }
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"; }
public void Validate(ILogger logger) { if (SolutionFile != null) { SolutionFile = SolutionFile.Trim(); if (SolutionFile.Length == 0) { SolutionFile = null; } if (SolutionFile != null && !File.Exists(SolutionFile)) { throw new FileNotFoundException("The SolutionFile '" + SolutionFile + "' does not exist."); } } else { logger.Msg("SolutionFile is not specified (which is probably OK, you should base things off the project anyway)."); } if (String.IsNullOrWhiteSpace(ProjectFile)) { throw new ArgumentException("ProjectFile must be set."); } ProjectFile = ProjectFile.Trim(); if (!File.Exists(ProjectFile)) { throw new FileNotFoundException("The ProjectFile '" + ProjectFile + "' does not exist."); } if (String.IsNullOrWhiteSpace(OutputDirectory)) { throw new ArgumentException("The OutputDirectory is not set."); } if (Configuration != null) { Configuration = Configuration.Trim(); } if (PluginsDirectory != null) { PluginsDirectory = PluginsDirectory.Trim(); if (PluginsDirectory.Length == 0) { PluginsDirectory = null; } if (PluginsDirectory != null) { if (!Directory.Exists(PluginsDirectory)) { logger.Msg("The PluginsDirectory '{0}' that you specified does not exist - ignoring.", PluginsDirectory); PluginsDirectory = null; } else { string[] files = Directory.GetFiles(PluginsDirectory, "*.dll", SearchOption.TopDirectoryOnly); if (files == null || files.Length == 0) { logger.Msg("The PluginsDirectory '{0}' exists, but contains no DLLs. Only built-in Lithogen types will be used.", PluginsDirectory); } else { logger.Msg("The PluginsDirectory '{0}' exists and contains {1} file(s) matching the filter *.dll. They will be searched for plugin types later.", PluginsDirectory, files.Length); } } } } else { logger.Msg("The PluginsDirectory is not specified, only built-in Lithogen types will be used."); } }