/
IndexingConfiguration.cs
120 lines (100 loc) · 6.05 KB
/
IndexingConfiguration.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
using System;
using System.ComponentModel;
using System.Reflection;
using Raven.Server.Config.Attributes;
using Raven.Server.Config.Settings;
using Raven.Server.Documents.Indexes.Configuration;
using Raven.Server.ServerWide;
namespace Raven.Server.Config.Categories
{
public class IndexingConfiguration : ConfigurationCategory
{
private bool? _runInMemory;
private readonly RavenConfiguration _root;
private PathSetting _indexStoragePath;
public IndexingConfiguration(RavenConfiguration root)
{
_root = root;
}
[Description("Whether the indexes should run purely in memory. When running in memory, nothing is written to disk and if the server is restarted all data will be lost. This is mostly useful for testing.")]
[IndexUpdateType(IndexUpdateType.Reset)]
[ConfigurationEntry("Indexing.RunInMemory", ConfigurationEntryScope.ServerWideOrPerDatabase, setDefaultValueIfNeeded: false)]
public virtual bool RunInMemory
{
get
{
if (_runInMemory == null)
_runInMemory = _root.Core.RunInMemory;
return _runInMemory.Value;
}
protected set => _runInMemory = value;
}
[DefaultValue(false)]
[IndexUpdateType(IndexUpdateType.None)]
[ConfigurationEntry("Indexing.Disable", ConfigurationEntryScope.ServerWideOrPerDatabase)]
public virtual bool Disabled { get; protected set; }
[ReadOnlyPath]
public virtual PathSetting StoragePath => _indexStoragePath ?? (_indexStoragePath = _root.ResourceType == ResourceType.Server ? null : _root.Core.DataDirectory.Combine("Indexes"));
[DefaultValue(null)]
[IndexUpdateType(IndexUpdateType.Reset)]
[ConfigurationEntry("Indexing.TempPath", ConfigurationEntryScope.ServerWideOrPerDatabase)]
public virtual PathSetting TempPath { get; protected set; }
[Description("How long indexing will keep document transaction open when indexing. After this the transaction will be reopened.")]
[DefaultValue(15)]
[TimeUnit(TimeUnit.Seconds)]
[IndexUpdateType(IndexUpdateType.Refresh)]
[ConfigurationEntry("Indexing.MaxTimeForDocumentTransactionToRemainOpenInSec", ConfigurationEntryScope.ServerWideOrPerDatabase)]
public TimeSetting MaxTimeForDocumentTransactionToRemainOpen { get; protected set; }
[Description("How long should we keep a superseded auto index?")]
[DefaultValue(15)]
[TimeUnit(TimeUnit.Seconds)]
[IndexUpdateType(IndexUpdateType.None)]
[ConfigurationEntry("Indexing.TimeBeforeDeletionOfSupersededAutoIndexInSec", ConfigurationEntryScope.ServerWideOrPerDatabase)]
public TimeSetting TimeBeforeDeletionOfSupersededAutoIndex { get; protected set; }
[Description("How long the database should wait before marking an auto index with the idle flag")]
[DefaultValue(30)]
[TimeUnit(TimeUnit.Minutes)]
[IndexUpdateType(IndexUpdateType.None)]
[ConfigurationEntry("Indexing.TimeToWaitBeforeMarkingAutoIndexAsIdleInMin", ConfigurationEntryScope.ServerWideOrPerDatabase)]
public TimeSetting TimeToWaitBeforeMarkingAutoIndexAsIdle { get; protected set; }
[Description("EXPERT ONLY")]
[DefaultValue(false)]
[IndexUpdateType(IndexUpdateType.None)]
[ConfigurationEntry("Indexing.DisableQueryOptimizerGeneratedIndexes", ConfigurationEntryScope.ServerWideOrPerDatabase)]
public bool DisableQueryOptimizerGeneratedIndexes { get; protected set; }
[Description("How long the database should wait before deleting an auto index with the idle flag")]
[DefaultValue(72)]
[TimeUnit(TimeUnit.Hours)]
[IndexUpdateType(IndexUpdateType.None)]
[ConfigurationEntry("Indexing.TimeToWaitBeforeDeletingAutoIndexMarkedAsIdleInHrs", ConfigurationEntryScope.ServerWideOrPerDatabase)]
public TimeSetting TimeToWaitBeforeDeletingAutoIndexMarkedAsIdle { get; protected set; }
[Description("EXPERT ONLY")]
[DefaultValue(512)]
[IndexUpdateType(IndexUpdateType.Refresh)]
[ConfigurationEntry("Indexing.MinNumberOfMapAttemptsAfterWhichBatchWillBeCanceledIfRunningLowOnMemory", ConfigurationEntryScope.ServerWideOrPerDatabase)]
public int MinNumberOfMapAttemptsAfterWhichBatchWillBeCanceledIfRunningLowOnMemory { get; protected set; }
[Description("EXPERT ONLY")]
[DefaultValue(2)]
[IndexUpdateType(IndexUpdateType.None)]
[ConfigurationEntry("Indexing.NumberOfConcurrentStoppedBatchesIfRunningLowOnMemory", ConfigurationEntryScope.ServerWideOrPerDatabase)]
public int NumberOfConcurrentStoppedBatchesIfRunningLowOnMemory { get; protected set; }
[Description("Number of seconds after which mapping will end even if there is more to map. By default we will map everything we can in single batch.")]
[DefaultValue(-1)]
[TimeUnit(TimeUnit.Seconds)]
[IndexUpdateType(IndexUpdateType.Refresh)]
[ConfigurationEntry("Indexing.MapTimeoutInSec", ConfigurationEntryScope.ServerWideOrPerDatabase)]
public TimeSetting MapTimeout { get; protected set; }
[Description("Number of minutes after which mapping will end even if there is more to map. This will only be applied if we pass the last etag in collection that we saw when batch was started.")]
[DefaultValue(15)]
[TimeUnit(TimeUnit.Minutes)]
[IndexUpdateType(IndexUpdateType.Refresh)]
[ConfigurationEntry("Indexing.MapTimeoutAfterEtagReachedInMin", ConfigurationEntryScope.ServerWideOrPerDatabase)]
public TimeSetting MapTimeoutAfterEtagReached { get; protected set; }
protected override void ValidateProperty(PropertyInfo property)
{
var updateTypeAttribute = property.GetCustomAttribute<IndexUpdateTypeAttribute>();
if (updateTypeAttribute == null)
throw new InvalidOperationException($"No {nameof(IndexUpdateTypeAttribute)} available for '{property.Name}' property.");
}
}
}