aboutsummaryrefslogtreecommitdiffstats
path: root/storage/src/vespa/storage/config/distributorconfiguration.h
blob: 08d3e2b055fd0eeeefa0b1c08c833176447363ad (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
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
// Copyright Yahoo. 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 <vespa/vespalib/util/time.h>

namespace storage {

namespace distributor { struct LegacyDistributorTest; }

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 mergeGlobalBuckets {115};
        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);


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

    vespalib::duration getGarbageCollectionInterval() const {
        return _garbageCollectionInterval;
    }

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

    void setLastGarbageCollectionChangeTime(vespalib::steady_time 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; };

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

    const MaintenancePriorities& getMaintenancePriorities() const {
        return _maintenancePriorities;
    }

    uint8_t default_external_feed_priority() const noexcept { return 120; }
    
    /**
       @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;
    }

    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;

    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 merge_operations_disabled() const noexcept {
        return _merge_operations_disabled;
    }
    void set_merge_operations_disabled(bool disabled) noexcept {
        _merge_operations_disabled = disabled;
    }

    void set_use_weak_internal_read_consistency_for_client_gets(bool use_weak) noexcept {
        _use_weak_internal_read_consistency_for_client_gets = use_weak;
    }
    bool use_weak_internal_read_consistency_for_client_gets() const noexcept {
        return _use_weak_internal_read_consistency_for_client_gets;
    }

    void set_enable_metadata_only_fetch_phase_for_inconsistent_updates(bool enable) noexcept {
        _enable_metadata_only_fetch_phase_for_inconsistent_updates = enable;
    }
    bool enable_metadata_only_fetch_phase_for_inconsistent_updates() const noexcept {
        return _enable_metadata_only_fetch_phase_for_inconsistent_updates;
    }

    uint32_t max_consecutively_inhibited_maintenance_ticks() const noexcept {
        return _max_consecutively_inhibited_maintenance_ticks;
    }

    void set_prioritize_global_bucket_merges(bool prioritize) noexcept {
        _prioritize_global_bucket_merges = prioritize;
    }
    bool prioritize_global_bucket_merges() const noexcept {
        return _prioritize_global_bucket_merges;
    }

    void set_max_activation_inhibited_out_of_sync_groups(uint32_t max_groups) noexcept {
        _max_activation_inhibited_out_of_sync_groups = max_groups;
    }
    uint32_t max_activation_inhibited_out_of_sync_groups() const noexcept {
        return _max_activation_inhibited_out_of_sync_groups;
    }

    [[nodiscard]] bool implicitly_clear_priority_on_schedule() const noexcept {
        return _implicitly_clear_priority_on_schedule;
    }
    void set_use_unordered_merge_chaining(bool unordered) noexcept {
        _use_unordered_merge_chaining = unordered;
    }
    [[nodiscard]] bool use_unordered_merge_chaining() const noexcept {
        return _use_unordered_merge_chaining;
    }
    void set_inhibit_default_merges_when_global_merges_pending(bool inhibit) noexcept {
        _inhibit_default_merges_when_global_merges_pending = inhibit;
    }
    [[nodiscard]] bool inhibit_default_merges_when_global_merges_pending() const noexcept {
        return _inhibit_default_merges_when_global_merges_pending;
    }
    void set_enable_two_phase_garbage_collection(bool enable) noexcept {
        _enable_two_phase_garbage_collection = enable;
    }
    [[nodiscard]] bool enable_two_phase_garbage_collection() const noexcept {
        return _enable_two_phase_garbage_collection;
    }
    void set_enable_condition_probing(bool enable) noexcept {
        _enable_condition_probing = enable;
    }
    [[nodiscard]] bool enable_condition_probing() const noexcept {
        return _enable_condition_probing;
    }
    void set_enable_operation_cancellation(bool enable) noexcept {
        _enable_operation_cancellation = enable;
    }
    [[nodiscard]] bool enable_operation_cancellation() const noexcept {
        return _enable_operation_cancellation;
    }

    uint32_t num_distributor_stripes() const noexcept { return _num_distributor_stripes; }

    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;
    uint32_t _max_consecutively_inhibited_maintenance_ticks;
    uint32_t _max_activation_inhibited_out_of_sync_groups;

    std::string _garbageCollectionSelection;

    vespalib::steady_time _lastGarbageCollectionChange;
    vespalib::duration    _garbageCollectionInterval;

    uint32_t _minPendingMaintenanceOps;
    uint32_t _maxPendingMaintenanceOps;

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

    uint32_t _maxVisitorsPerNodePerClientVisitor;
    uint32_t _minBucketsPerVisitor;

    uint32_t _num_distributor_stripes;

    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;
    bool _merge_operations_disabled;
    bool _use_weak_internal_read_consistency_for_client_gets;
    bool _enable_metadata_only_fetch_phase_for_inconsistent_updates;
    bool _prioritize_global_bucket_merges;
    bool _implicitly_clear_priority_on_schedule;
    bool _use_unordered_merge_chaining;
    bool _inhibit_default_merges_when_global_merges_pending;
    bool _enable_two_phase_garbage_collection;
    bool _enable_condition_probing;
    bool _enable_operation_cancellation;

    DistrConfig::MinimumReplicaCountingMode _minimumReplicaCountingMode;

    friend struct distributor::LegacyDistributorTest;
    void configureMaintenancePriorities(
            const vespa::config::content::core::StorDistributormanagerConfig&);
};

}