aboutsummaryrefslogtreecommitdiffstats
path: root/storage/src/vespa/storage/config/distributorconfiguration.h
blob: 3cb8494350867b5a6e5d5d68b9cac19212d37e63 (plain) (blame)
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once

#include <vespa/storage/config/config-stor-distributormanager.h>
#include <vespa/storage/config/config-stor-visitordispatcher.h>
#include <vespa/vespalib/stllike/hash_set.h>
#include <vespa/storage/common/storagecomponent.h>
#include <chrono>

namespace storage {

namespace distributor {
struct DistributorTest;
}

class DistributorConfiguration {
public: 
    explicit DistributorConfiguration(StorageComponent& component);
    ~DistributorConfiguration();

    struct MaintenancePriorities
    {
        // Defaults for these are chosen as those used as the current (non-
        // configurable) values at the time of implementation.
        uint8_t mergeMoveToIdealNode {120};
        uint8_t mergeOutOfSyncCopies {120};
        uint8_t mergeTooFewCopies {120};
        uint8_t activateNoExistingActive {100};
        uint8_t activateWithExistingActive {100};
        uint8_t deleteBucketCopy {100};
        uint8_t joinBuckets {155};
        uint8_t splitDistributionBits {200};
        uint8_t splitLargeBucket {175};
        uint8_t splitInconsistentBucket {110};
        uint8_t garbageCollection {200};
    };

    using DistrConfig = vespa::config::content::core::StorDistributormanagerConfig;
    
    void configure(const DistrConfig& config);

    void configure(const vespa::config::content::core::StorVisitordispatcherConfig& config);
        
    void setIdealStateChunkSize(uint32_t chunkSize) {
        _idealStateChunkSize = chunkSize;
    }
    
    uint32_t getIdealStateChunkSize() { 
        return _idealStateChunkSize;
    }

    uint32_t lastGarbageCollectionChangeTime() const {
        return _lastGarbageCollectionChange;
    }

    const std::string& getGarbageCollectionSelection() const {
        return _garbageCollectionSelection;
    }

    uint32_t getGarbageCollectionInterval() const {
        return _garbageCollectionInterval;
    }

    void setGarbageCollection(const std::string& selection, uint32_t interval) {
        _garbageCollectionSelection = selection;
        _garbageCollectionInterval = interval;
    }

    void setLastGarbageCollectionChangeTime(uint32_t lastChangeTime) {
        _lastGarbageCollectionChange = lastChangeTime;
    }

    bool stateCheckerIsActive(vespalib::stringref stateCheckerName) const {
        return _blockedStateCheckers.find(stateCheckerName) == _blockedStateCheckers.end();
    }

    void disableStateChecker(vespalib::stringref stateCheckerName) {
        _blockedStateCheckers.insert(stateCheckerName);
    }

    void setDoInlineSplit(bool value) {
        _doInlineSplit = value;
    }
    
    bool doInlineSplit() const {
        return _doInlineSplit;
    }

    /**
       Sets the number of documents needed for a bucket to be split.

       @param count The minimum number of documents a bucket needs to have to be split.
    */
    void setSplitCount(uint32_t count) { _docCountSplitLimit = count; }

    /**
       Sets the number of bytes needed for a bucket to be split.

       @param sz The minimum size (in bytes) a bucket needs to have in order to be split.
    */
    void setSplitSize(uint32_t sz) { _byteCountSplitLimit = sz; }

    /**
       Sets the maximum number of documents two buckets can have in order to be joined. The sum
       of the documents in the two buckets need to be below this limit for join to occur.

       @param count The maximum number of documents two buckets need to have in order to be joined.
    */
    void setJoinCount(uint32_t count) { _docCountJoinLimit = count; }

    /**
       Sets the maximum number of stored bytes two buckets can have in order to be joined. The sum
       of the sizes of the two buckets need to be below this limit for join to occur.

       @param count The maximum size the two buckets need to have in order to be joined.
    */
    void setJoinSize(uint32_t sz) { _byteCountJoinLimit = sz; }

    /**
       Sets the minimal bucket split level we want buckets to have. Buckets that have fewer used bits
       than this are automatically split.

       @param splitBits The minimal bucket split level.
    */
    void setMinimalBucketSplit(int splitBits) { _minimalBucketSplit = splitBits; };

    /**
       Sets the maximum number of ideal state operations a distributor should
       schedule to each storage node.

       @param numOps The number of operations to schedule.
    */
    void setMaxIdealStateOperations(uint32_t numOps) { 
        _maxIdealStateOperations = numOps; 
    };

    uint32_t getMaxIdealStateOperations() {
        return _maxIdealStateOperations;
    }

    void setMaintenancePriorities(const MaintenancePriorities& mp) {
        _maintenancePriorities = mp;
    }

    const MaintenancePriorities& getMaintenancePriorities() const {
        return _maintenancePriorities;
    }
    
    /**
       @see setSplitCount
    */
    uint32_t getSplitCount() const { return _docCountSplitLimit; }

    /**
       @see setSplitSize
    */
    uint32_t getSplitSize() const { return _byteCountSplitLimit; }

    /**
       @see setJoinCount
    */
    uint32_t getJoinCount() const { return _docCountJoinLimit; }

    /**
       @see setJoinSize
    */
    uint32_t getJoinSize() const { return _byteCountJoinLimit; }

    /**
       @see setMinimalBucketSplit
    */
    uint32_t getMinimalBucketSplit() const { return _minimalBucketSplit; };

    uint32_t getMinPendingMaintenanceOps() const {
        return _minPendingMaintenanceOps;
    }
    void setMinPendingMaintenanceOps(uint32_t minPendingMaintenanceOps) {
        _minPendingMaintenanceOps = minPendingMaintenanceOps;
    }
    uint32_t getMaxPendingMaintenanceOps() const {
        return _maxPendingMaintenanceOps;
    }
    void setMaxPendingMaintenanceOps(uint32_t maxPendingMaintenanceOps) {
        _maxPendingMaintenanceOps = maxPendingMaintenanceOps;
    }

    uint32_t getMaxVisitorsPerNodePerClientVisitor() const {
        return _maxVisitorsPerNodePerClientVisitor;
    }
    uint32_t getMinBucketsPerVisitor() const {
        return _minBucketsPerVisitor;
    }

    void setMaxVisitorsPerNodePerClientVisitor(uint32_t n) {
        _maxVisitorsPerNodePerClientVisitor = n;
    }
    void setMinBucketsPerVisitor(uint32_t n) {
        _minBucketsPerVisitor = n;
    }

    uint32_t getMaxNodesPerMerge() const {
        return _maxNodesPerMerge;
    }
    bool getEnableJoinForSiblingLessBuckets() const {
        return _enableJoinForSiblingLessBuckets;
    }
    bool getEnableInconsistentJoin() const noexcept {
        return _enableInconsistentJoin;
    }

    bool getEnableHostInfoReporting() const noexcept {
        return _enableHostInfoReporting;
    }

    using ReplicaCountingMode = DistrConfig::MinimumReplicaCountingMode;
    void setMinimumReplicaCountingMode(ReplicaCountingMode mode) noexcept {
        _minimumReplicaCountingMode = mode;
    }
    ReplicaCountingMode getMinimumReplicaCountingMode() const noexcept {
        return _minimumReplicaCountingMode;
    }
    bool isBucketActivationDisabled() const noexcept {
        return _disableBucketActivation;
    }
    std::chrono::seconds getMaxClusterClockSkew() const noexcept {
        return _maxClusterClockSkew;
    }
    std::chrono::seconds getInhibitMergesOnBusyNodeDuration() const noexcept {
        return _inhibitMergeSendingOnBusyNodeDuration;
    }

    std::chrono::milliseconds simulated_db_pruning_latency() const noexcept {
        return _simulated_db_pruning_latency;
    }
    std::chrono::milliseconds simulated_db_merging_latency() const noexcept {
        return _simulated_db_merging_latency;
    }

    bool getSequenceMutatingOperations() const noexcept {
        return _sequenceMutatingOperations;
    }
    void setSequenceMutatingOperations(bool sequenceMutations) noexcept {
        _sequenceMutatingOperations = sequenceMutations;
    }

    bool allowStaleReadsDuringClusterStateTransitions() const noexcept {
        return _allowStaleReadsDuringClusterStateTransitions;
    }
    void setAllowStaleReadsDuringClusterStateTransitions(bool allow) noexcept {
        _allowStaleReadsDuringClusterStateTransitions = allow;
    }

    bool update_fast_path_restart_enabled() const noexcept {
        return _update_fast_path_restart_enabled;
    }
    void set_update_fast_path_restart_enabled(bool enabled) noexcept {
        _update_fast_path_restart_enabled = enabled;
    }

    bool containsTimeStatement(const std::string& documentSelection) const;
    
private:
    DistributorConfiguration(const DistributorConfiguration& other);
    DistributorConfiguration& operator=(const DistributorConfiguration& other);
    
    StorageComponent& _component;
    
    uint32_t _byteCountSplitLimit;
    uint32_t _docCountSplitLimit;
    uint32_t _byteCountJoinLimit;
    uint32_t _docCountJoinLimit;
    uint32_t _minimalBucketSplit;
    uint32_t _maxIdealStateOperations;
    uint32_t _idealStateChunkSize;
    uint32_t _maxNodesPerMerge;

    std::string _garbageCollectionSelection;

    uint32_t _lastGarbageCollectionChange;
    uint32_t _garbageCollectionInterval;

    uint32_t _minPendingMaintenanceOps;
    uint32_t _maxPendingMaintenanceOps;

    vespalib::hash_set<vespalib::string> _blockedStateCheckers;

    uint32_t _maxVisitorsPerNodePerClientVisitor;
    uint32_t _minBucketsPerVisitor;

    MaintenancePriorities _maintenancePriorities;
    std::chrono::seconds _maxClusterClockSkew;
    std::chrono::seconds _inhibitMergeSendingOnBusyNodeDuration;
    std::chrono::milliseconds _simulated_db_pruning_latency;
    std::chrono::milliseconds _simulated_db_merging_latency;

    bool _doInlineSplit;
    bool _enableJoinForSiblingLessBuckets;
    bool _enableInconsistentJoin;
    bool _enableHostInfoReporting;
    bool _disableBucketActivation;
    bool _sequenceMutatingOperations;
    bool _allowStaleReadsDuringClusterStateTransitions;
    bool _update_fast_path_restart_enabled;

    DistrConfig::MinimumReplicaCountingMode _minimumReplicaCountingMode;
    
    friend struct distributor::DistributorTest;
    void configureMaintenancePriorities(
            const vespa::config::content::core::StorDistributormanagerConfig&);
};

}