Raven.Database.Config.StronglyTypedRavenSettings.Setup C# (CSharp) Method

Setup() public method

public Setup ( int defaultMaxNumberOfItemsToIndexInSingleBatch, int defaultInitialNumberOfItemsToIndexInSingleBatch ) : void
defaultMaxNumberOfItemsToIndexInSingleBatch int
defaultInitialNumberOfItemsToIndexInSingleBatch int
return void
		public void Setup(int defaultMaxNumberOfItemsToIndexInSingleBatch, int defaultInitialNumberOfItemsToIndexInSingleBatch)
		{
			MaxPageSize =
				new IntegerSettingWithMin(settings["Raven/MaxPageSize"], 1024, 10);
			MemoryCacheLimitMegabytes =
				new IntegerSetting(settings["Raven/MemoryCacheLimitMegabytes"], GetDefaultMemoryCacheLimitMegabytes);
			MemoryCacheExpiration =
				new TimeSpanSetting(settings["Raven/MemoryCacheExpiration"], TimeSpan.FromMinutes(5),
				                    TimeSpanArgumentType.FromSeconds);
			MemoryCacheLimitPercentage =
				new IntegerSetting(settings["Raven/MemoryCacheLimitPercentage"], 0 /* auto size */);
			MemoryCacheLimitCheckInterval =
				new TimeSpanSetting(settings["Raven/MemoryCacheLimitCheckInterval"], MemoryCache.Default.PollingInterval,
				                    TimeSpanArgumentType.FromParse);
			MaxIndexingRunLatency =
				new TimeSpanSetting(settings["Raven/MaxIndexingRunLatency"], TimeSpan.FromMinutes(5),
				                    TimeSpanArgumentType.FromParse);
			MaxIndexWritesBeforeRecreate =
				new IntegerSetting(settings["Raven/MaxIndexWritesBeforeRecreate"], 256 * 1024);

			MaxNumberOfItemsToIndexInSingleBatch =
				new IntegerSettingWithMin(settings["Raven/MaxNumberOfItemsToIndexInSingleBatch"],
				                          defaultMaxNumberOfItemsToIndexInSingleBatch, 128);
			AvailableMemoryForRaisingIndexBatchSizeLimit =
				new IntegerSetting(settings["Raven/AvailableMemoryForRaisingIndexBatchSizeLimit"],
				                   Math.Min(768, MemoryStatistics.TotalPhysicalMemory/2));
			MaxNumberOfItemsToReduceInSingleBatch =
				new IntegerSettingWithMin(settings["Raven/MaxNumberOfItemsToReduceInSingleBatch"],
				                          defaultMaxNumberOfItemsToIndexInSingleBatch/2, 128);
			NumberOfItemsToExecuteReduceInSingleStep =
				new IntegerSetting(settings["Raven/NumberOfItemsToExecuteReduceInSingleStep"], 1024);
			MaxNumberOfParallelIndexTasks =
				new IntegerSettingWithMin(settings["Raven/MaxNumberOfParallelIndexTasks"], Environment.ProcessorCount, 1);

			NewIndexInMemoryMaxMb =
				new MultipliedIntegerSetting(new IntegerSettingWithMin(settings["Raven/NewIndexInMemoryMaxMB"], 64, 1), 1024*1024);
			RunInMemory =
				new BooleanSetting(settings["Raven/RunInMemory"], false);
			CreateAutoIndexesForAdHocQueriesIfNeeded =
				new BooleanSetting(settings["Raven/CreateAutoIndexesForAdHocQueriesIfNeeded"], true);
			ResetIndexOnUncleanShutdown =
				new BooleanSetting(settings["Raven/ResetIndexOnUncleanShutdown"], false);
			DataDir =
				new StringSetting(settings["Raven/DataDir"], @"~\Data");
			IndexStoragePath =
				new StringSetting(settings["Raven/IndexStoragePath"], (string) null);
			HostName =
				new StringSetting(settings["Raven/HostName"], (string) null);
			Port =
				new StringSetting(settings["Raven/Port"], (string) null);
			UseSsl = 
				new BooleanSetting(settings["Raven/UseSsl"], false);
			HttpCompression =
				new BooleanSetting(settings["Raven/HttpCompression"], true);
			AccessControlAllowOrigin =
				new StringSetting(settings["Raven/AccessControlAllowOrigin"], (string) null);
			AccessControlMaxAge =
				new StringSetting(settings["Raven/AccessControlMaxAge"], "1728000" /* 20 days */);
			AccessControlAllowMethods =
				new StringSetting(settings["Raven/AccessControlAllowMethods"], "PUT,PATCH,GET,DELETE,POST");
			AccessControlRequestHeaders =
				new StringSetting(settings["Raven/AccessControlRequestHeaders"], (string) null);
			RedirectStudioUrl =
				new StringSetting(settings["Raven/RedirectStudioUrl"], (string) null);
			DisableDocumentPreFetchingForIndexing =
				new BooleanSetting(settings["Raven/DisableDocumentPreFetchingForIndexing"], false);
			MaxNumberOfItemsToPreFetchForIndexing =
				new IntegerSettingWithMin(settings["Raven/MaxNumberOfItemsToPreFetchForIndexing"],
										  defaultMaxNumberOfItemsToIndexInSingleBatch, 128);
			WebDir =
				new StringSetting(settings["Raven/WebDir"], GetDefaultWebDir);
			PluginsDirectory =
				new StringSetting(settings["Raven/PluginsDirectory"], @"~\Plugins");
			CompiledIndexCacheDirectory =
				new StringSetting(settings["Raven/CompiledIndexCacheDirectory"], @"~\Raven\CompiledIndexCache");
			TaskScheduler =
				new StringSetting(settings["Raven/TaskScheduler"], (string) null);
			AllowLocalAccessWithoutAuthorization =
				new BooleanSetting(settings["Raven/AllowLocalAccessWithoutAuthorization"], false);
			MaxIndexCommitPointStoreTimeInterval =
				new TimeSpanSetting(settings["Raven/MaxIndexCommitPointStoreTimeInterval"], TimeSpan.FromMinutes(5),
				                    TimeSpanArgumentType.FromParse);
			MaxNumberOfStoredCommitPoints =
				new IntegerSetting(settings["Raven/MaxNumberOfStoredCommitPoints"], 5);
			MinIndexingTimeIntervalToStoreCommitPoint =
				new TimeSpanSetting(settings["Raven/MinIndexingTimeIntervalToStoreCommitPoint"], TimeSpan.FromMinutes(1),
				                    TimeSpanArgumentType.FromParse);
            
			TimeToWaitBeforeRunningIdleIndexes = new TimeSpanSetting(settings["Raven/TimeToWaitBeforeRunningIdleIndexes"], TimeSpan.FromMinutes(10), TimeSpanArgumentType.FromParse);
            
			TimeToWaitBeforeMarkingAutoIndexAsIdle = new TimeSpanSetting(settings["Raven/TimeToWaitBeforeMarkingAutoIndexAsIdle"], TimeSpan.FromHours(1), TimeSpanArgumentType.FromParse);

			TimeToWaitBeforeMarkingIdleIndexAsAbandoned = new TimeSpanSetting(settings["Raven/TimeToWaitBeforeMarkingIdleIndexAsAbandoned"], TimeSpan.FromHours(72), TimeSpanArgumentType.FromParse);

			TimeToWaitBeforeRunningAbandonedIndexes = new TimeSpanSetting(settings["Raven/TimeToWaitBeforeRunningAbandonedIndexes"], TimeSpan.FromHours(3), TimeSpanArgumentType.FromParse);

			DisableClusterDiscovery = new BooleanSetting(settings["Raven/DisableClusterDiscovery"], false);

			ClusterName = new StringSetting(settings["Raven/ClusterName"], (string)null);
			ServerName = new StringSetting(settings["Raven/ServerName"], (string)null);

			MaxStepsForScript = new IntegerSetting(settings["Raven/MaxStepsForScript"], 10*1000);
			AdditionalStepsForScriptBasedOnDocumentSize = new IntegerSetting(settings["Raven/AdditionalStepsForScriptBasedOnDocumentSize"], 5);
		}

Usage Example

        public void Initialize()
        {
            int defaultMaxNumberOfItemsToIndexInSingleBatch     = Environment.Is64BitProcess ? 128 * 1024 : 16 * 1024;
            int defaultInitialNumberOfItemsToIndexInSingleBatch = Environment.Is64BitProcess ? 512 : 256;

            var ravenSettings = new StronglyTypedRavenSettings(Settings);

            ravenSettings.Setup(defaultMaxNumberOfItemsToIndexInSingleBatch, defaultInitialNumberOfItemsToIndexInSingleBatch);

            // Important! this value is synchronized with the max sessions number in esent
            // since we cannot have more requests in the system than we have sessions for them
            // and we also need to allow sessions for background operations and for multi get requests
            MaxConcurrentServerRequests = ravenSettings.MaxConcurrentServerRequests.Value;

            MaxConcurrentMultiGetRequests = ravenSettings.MaxConcurrentMultiGetRequests.Value;
            if (ConcurrentMultiGetRequests == null)
            {
                ConcurrentMultiGetRequests = new SemaphoreSlim(MaxConcurrentMultiGetRequests);
            }

            MemoryLimitForIndexingInMB = ravenSettings.MemoryLimitForIndexing.Value;

            EncryptionKeyBitsPreference = ravenSettings.EncryptionKeyBitsPreference.Value;
            // Core settings
            MaxPageSize = ravenSettings.MaxPageSize.Value;

            MemoryCacheLimitMegabytes = ravenSettings.MemoryCacheLimitMegabytes.Value;

            MemoryCacheExpiration = ravenSettings.MemoryCacheExpiration.Value;

            MemoryCacheLimitPercentage = ravenSettings.MemoryCacheLimitPercentage.Value;

            MemoryCacheLimitCheckInterval = ravenSettings.MemoryCacheLimitCheckInterval.Value;

            // Discovery
            DisableClusterDiscovery = ravenSettings.DisableClusterDiscovery.Value;

            // TODO: Validate the cluster name. Valid names are only valid chars in documents IDs.
            ClusterName = ravenSettings.ClusterName.Value;

            ServerName = ravenSettings.ServerName.Value;

            MaxStepsForScript = ravenSettings.MaxStepsForScript.Value;
            AdditionalStepsForScriptBasedOnDocumentSize = ravenSettings.AdditionalStepsForScriptBasedOnDocumentSize.Value;

            // Index settings
            MaxIndexingRunLatency        = ravenSettings.MaxIndexingRunLatency.Value;
            MaxIndexWritesBeforeRecreate = ravenSettings.MaxIndexWritesBeforeRecreate.Value;

            PreventAutomaticSuggestionCreation = ravenSettings.PreventAutomaticSuggestionCreation.Value;

            DisablePerformanceCounters = ravenSettings.DisablePerformanceCounters.Value;

            PrewarmFacetsOnIndexingMaxAge   = ravenSettings.PrewarmFacetsOnIndexingMaxAge.Value;
            PrewarmFacetsSyncronousWaitTime = ravenSettings.PrewarmFacetsSyncronousWaitTime.Value;

            MaxNumberOfItemsToIndexInSingleBatch = ravenSettings.MaxNumberOfItemsToIndexInSingleBatch.Value;
            FlushIndexToDiskSizeInMb             = ravenSettings.FlushIndexToDiskSizeInMb.Value;

            var initialNumberOfItemsToIndexInSingleBatch = Settings["Raven/InitialNumberOfItemsToIndexInSingleBatch"];

            if (initialNumberOfItemsToIndexInSingleBatch != null)
            {
                InitialNumberOfItemsToIndexInSingleBatch = Math.Min(int.Parse(initialNumberOfItemsToIndexInSingleBatch),
                                                                    MaxNumberOfItemsToIndexInSingleBatch);
            }
            else
            {
                InitialNumberOfItemsToIndexInSingleBatch = MaxNumberOfItemsToIndexInSingleBatch == ravenSettings.MaxNumberOfItemsToIndexInSingleBatch.Default ?
                                                           defaultInitialNumberOfItemsToIndexInSingleBatch :
                                                           Math.Max(16, Math.Min(MaxNumberOfItemsToIndexInSingleBatch / 256, defaultInitialNumberOfItemsToIndexInSingleBatch));
            }
            AvailableMemoryForRaisingIndexBatchSizeLimit = ravenSettings.AvailableMemoryForRaisingIndexBatchSizeLimit.Value;

            MaxNumberOfItemsToReduceInSingleBatch     = ravenSettings.MaxNumberOfItemsToReduceInSingleBatch.Value;
            InitialNumberOfItemsToReduceInSingleBatch = MaxNumberOfItemsToReduceInSingleBatch == ravenSettings.MaxNumberOfItemsToReduceInSingleBatch.Default ?
                                                        defaultInitialNumberOfItemsToIndexInSingleBatch / 2 :
                                                        Math.Max(16, Math.Min(MaxNumberOfItemsToIndexInSingleBatch / 256, defaultInitialNumberOfItemsToIndexInSingleBatch / 2));

            NumberOfItemsToExecuteReduceInSingleStep = ravenSettings.NumberOfItemsToExecuteReduceInSingleStep.Value;

            var initialNumberOfItemsToReduceInSingleBatch = Settings["Raven/InitialNumberOfItemsToReduceInSingleBatch"];

            if (initialNumberOfItemsToReduceInSingleBatch != null)
            {
                InitialNumberOfItemsToReduceInSingleBatch = Math.Min(int.Parse(initialNumberOfItemsToReduceInSingleBatch),
                                                                     MaxNumberOfItemsToReduceInSingleBatch);
            }

            MaxNumberOfParallelIndexTasks = ravenSettings.MaxNumberOfParallelIndexTasks.Value;

            NewIndexInMemoryMaxBytes = ravenSettings.NewIndexInMemoryMaxMb.Value;

            MaxIndexCommitPointStoreTimeInterval = ravenSettings.MaxIndexCommitPointStoreTimeInterval.Value;

            MinIndexingTimeIntervalToStoreCommitPoint = ravenSettings.MinIndexingTimeIntervalToStoreCommitPoint.Value;

            MaxNumberOfStoredCommitPoints = ravenSettings.MaxNumberOfStoredCommitPoints.Value;

            // Data settings
            RunInMemory = ravenSettings.RunInMemory.Value;

            if (string.IsNullOrEmpty(DefaultStorageTypeName))
            {
                DefaultStorageTypeName = Settings["Raven/StorageTypeName"] ?? Settings["Raven/StorageEngine"] ?? "esent";
            }

            CreateAutoIndexesForAdHocQueriesIfNeeded = ravenSettings.CreateAutoIndexesForAdHocQueriesIfNeeded.Value;

            DatbaseOperationTimeout = ravenSettings.DatbaseOperationTimeout.Value;

            TimeToWaitBeforeRunningIdleIndexes     = ravenSettings.TimeToWaitBeforeRunningIdleIndexes.Value;
            TimeToWaitBeforeMarkingAutoIndexAsIdle = ravenSettings.TimeToWaitBeforeMarkingAutoIndexAsIdle.Value;

            TimeToWaitBeforeMarkingIdleIndexAsAbandoned = ravenSettings.TimeToWaitBeforeMarkingIdleIndexAsAbandoned.Value;
            TimeToWaitBeforeRunningAbandonedIndexes     = ravenSettings.TimeToWaitBeforeRunningAbandonedIndexes.Value;

            ResetIndexOnUncleanShutdown = ravenSettings.ResetIndexOnUncleanShutdown.Value;
            DisableInMemoryIndexing     = ravenSettings.DisableInMemoryIndexing.Value;

            SetupTransactionMode();

            DataDirectory = ravenSettings.DataDir.Value;

            var indexStoragePathSettingValue = ravenSettings.IndexStoragePath.Value;

            if (string.IsNullOrEmpty(indexStoragePathSettingValue) == false)
            {
                IndexStoragePath = indexStoragePathSettingValue;
            }

            MaxRecentTouchesToRemember = ravenSettings.MaxRecentTouchesToRemember.Value;

            // HTTP settings
            HostName = ravenSettings.HostName.Value;

            if (string.IsNullOrEmpty(DatabaseName))             // we only use this for root database
            {
                Port   = PortUtil.GetPort(ravenSettings.Port.Value);
                UseSsl = ravenSettings.UseSsl.Value;
            }

            SetVirtualDirectory();

            HttpCompression = ravenSettings.HttpCompression.Value;

            AccessControlAllowOrigin    = ravenSettings.AccessControlAllowOrigin.Value;
            AccessControlMaxAge         = ravenSettings.AccessControlMaxAge.Value;
            AccessControlAllowMethods   = ravenSettings.AccessControlAllowMethods.Value;
            AccessControlRequestHeaders = ravenSettings.AccessControlRequestHeaders.Value;

            AnonymousUserAccessMode = GetAnonymousUserAccessMode();

            RedirectStudioUrl = ravenSettings.RedirectStudioUrl.Value;

            DisableDocumentPreFetchingForIndexing = ravenSettings.DisableDocumentPreFetchingForIndexing.Value;

            MaxNumberOfItemsToPreFetchForIndexing = ravenSettings.MaxNumberOfItemsToPreFetchForIndexing.Value;

            // Misc settings
            WebDir = ravenSettings.WebDir.Value;

            PluginsDirectory = ravenSettings.PluginsDirectory.Value.ToFullPath();

            CompiledIndexCacheDirectory = ravenSettings.CompiledIndexCacheDirectory.Value.ToFullPath();

            var taskSchedulerType = ravenSettings.TaskScheduler.Value;

            if (taskSchedulerType != null)
            {
                var type = Type.GetType(taskSchedulerType);
                CustomTaskScheduler = (TaskScheduler)Activator.CreateInstance(type);
            }

            AllowLocalAccessWithoutAuthorization = ravenSettings.AllowLocalAccessWithoutAuthorization.Value;

            FetchingDocumentsFromDiskTimeoutInSeconds = ravenSettings.FetchingDocumentsFromDiskTimeoutInSeconds.Value;
            MaximumSizeAllowedToFetchFromStorageInMb  = ravenSettings.MaximumSizeAllowedToFetchFromStorageInMb.Value;

            PostInit();
        }
All Usage Examples Of Raven.Database.Config.StronglyTypedRavenSettings::Setup