-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathpika_conf.h
More file actions
1263 lines (1191 loc) · 39.8 KB
/
pika_conf.h
File metadata and controls
1263 lines (1191 loc) · 39.8 KB
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
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright (c) 2015-present, Qihoo, Inc. All rights reserved.
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree. An additional grant
// of patent rights can be found in the PATENTS file in the same directory.
#ifndef PIKA_CONF_H_
#define PIKA_CONF_H_
#include <atomic>
#include <map>
#include <set>
#include <unordered_set>
#include "rocksdb/compression_type.h"
#include "pstd/include/base_conf.h"
#include "pstd/include/pstd_mutex.h"
#include "pstd/include/pstd_string.h"
#include "acl.h"
#include "cache/include/config.h"
#include "include/pika_define.h"
#include "rocksdb/compression_type.h"
#define kBinlogReadWinDefaultSize 9000
#define kBinlogReadWinMaxSize 90000
const uint32_t configRunIDSize = 40;
const uint32_t configReplicationIDSize = 50;
// global class, class members well initialized
class PikaConf : public pstd::BaseConf {
public:
enum CompactionStrategy {
NONE,
FullCompact,
OldestOrBestDeleteRatioSstCompact,
IncrementalCompact
};
PikaConf(const std::string& path);
~PikaConf() override = default;
// Getter
int port() {
std::shared_lock l(rwlock_);
return port_;
}
std::string slaveof() {
std::shared_lock l(rwlock_);
return slaveof_;
}
int slave_priority() {
std::shared_lock l(rwlock_);
return slave_priority_;
}
bool write_binlog() {
std::shared_lock l(rwlock_);
return write_binlog_;
}
int thread_num() {
std::shared_lock l(rwlock_);
return thread_num_;
}
int thread_pool_size() {
std::shared_lock l(rwlock_);
return thread_pool_size_;
}
int slow_cmd_thread_pool_size() {
std::shared_lock l(rwlock_);
return slow_cmd_thread_pool_size_;
}
int admin_thread_pool_size() {
std::shared_lock l(rwlock_);
return admin_thread_pool_size_;
}
int sync_thread_num() {
std::shared_lock l(rwlock_);
return sync_thread_num_;
}
int sync_binlog_thread_num() {
std::shared_lock l(rwlock_);
return sync_binlog_thread_num_;
}
std::string log_path() {
std::shared_lock l(rwlock_);
return log_path_;
}
int log_retention_time() {
std::shared_lock l(rwlock_);
return log_retention_time_;
}
bool log_net_activities() {
return log_net_activities_.load(std::memory_order::memory_order_relaxed);
}
std::string db_path() {
std::shared_lock l(rwlock_);
return db_path_;
}
int db_instance_num() {
return db_instance_num_;
}
uint64_t rocksdb_ttl_second() {
return rocksdb_ttl_second_.load();
}
uint64_t rocksdb_periodic_compaction_second() {
return rocksdb_periodic_second_.load();
}
std::string db_sync_path() {
std::shared_lock l(rwlock_);
return db_sync_path_;
}
int db_sync_speed() {
std::shared_lock l(rwlock_);
return db_sync_speed_;
}
std::string compact_cron() {
std::shared_lock l(rwlock_);
return compact_cron_;
}
std::string compact_interval() {
std::shared_lock l(rwlock_);
return compact_interval_;
}
int max_subcompactions() {
std::shared_lock l(rwlock_);
return max_subcompactions_;
}
int compact_every_num_of_files() {
std::shared_lock l(rwlock_);
return compact_every_num_of_files_;
}
int force_compact_file_age_seconds() {
std::shared_lock l(rwlock_);
return force_compact_file_age_seconds_;
}
int force_compact_min_delete_ratio() {
std::shared_lock l(rwlock_);
return force_compact_min_delete_ratio_;
}
int dont_compact_sst_created_in_seconds() {
std::shared_lock l(rwlock_);
return dont_compact_sst_created_in_seconds_;
}
int best_delete_min_ratio() {
std::shared_lock l(rwlock_);
return best_delete_min_ratio_;
}
CompactionStrategy compaction_strategy() {
std::shared_lock l(rwlock_);
return compaction_strategy_;
}
int incremental_compact_interval() {
std::shared_lock l(rwlock_);
return incremental_compact_interval_;
}
int incremental_compact_max_files() {
std::shared_lock l(rwlock_);
return incremental_compact_max_files_;
}
int incremental_compact_max_time_ms() {
std::shared_lock l(rwlock_);
return incremental_compact_max_time_ms_;
}
int incremental_compact_min_rate() {
std::shared_lock l(rwlock_);
return incremental_compact_min_rate_;
}
int incremental_compact_min_file_age() {
std::shared_lock l(rwlock_);
return incremental_compact_min_file_age_;
}
bool disable_auto_compactions() {
std::shared_lock l(rwlock_);
return disable_auto_compactions_;
}
int64_t least_resume_free_disk_size() {
std::shared_lock l(rwlock_);
return least_free_disk_to_resume_;
}
int64_t resume_interval() {
std::shared_lock l(rwlock_);
return resume_check_interval_;
}
double min_check_resume_ratio() {
std::shared_lock l(rwlock_);
return min_check_resume_ratio_;
}
int64_t write_buffer_size() {
std::shared_lock l(rwlock_);
return write_buffer_size_;
}
int64_t proto_max_bulk_len() {
std::shared_lock l(rwlock_);
return proto_max_bulk_len_;
}
int min_write_buffer_number_to_merge() {
std::shared_lock l(rwlock_);
return min_write_buffer_number_to_merge_;
}
int level0_stop_writes_trigger() {
std::shared_lock l(rwlock_);
return level0_stop_writes_trigger_;
}
int level0_slowdown_writes_trigger() {
std::shared_lock l(rwlock_);
return level0_slowdown_writes_trigger_;
}
int level0_file_num_compaction_trigger() {
std::shared_lock l(rwlock_);
return level0_file_num_compaction_trigger_;
}
int64_t arena_block_size() {
std::shared_lock l(rwlock_);
return arena_block_size_;
}
int64_t slotmigrate_thread_num() {
std::shared_lock l(rwlock_);
return slotmigrate_thread_num_;
}
int64_t thread_migrate_keys_num() {
std::shared_lock l(rwlock_);
return thread_migrate_keys_num_;
}
int64_t max_write_buffer_size() {
std::shared_lock l(rwlock_);
return max_write_buffer_size_;
}
int max_write_buffer_number() {
std::shared_lock l(rwlock_);
return max_write_buffer_num_;
}
uint64_t MaxTotalWalSize() {
std::shared_lock l(rwlock_);
return max_total_wal_size_;
}
bool enable_db_statistics() {
return enable_db_statistics_;
}
int db_statistics_level() {
std::shared_lock l(rwlock_);
return db_statistics_level_;
}
int64_t max_client_response_size() {
std::shared_lock l(rwlock_);
return max_client_response_size_;
}
int timeout() {
std::shared_lock l(rwlock_);
return timeout_;
}
int binlog_writer_num() {
std::shared_lock l(rwlock_);
return binlog_writer_num_;
}
bool slotmigrate() {
std::shared_lock l(rwlock_);
return slotmigrate_;
}
bool slow_cmd_pool() {
std::shared_lock l(rwlock_);
return slow_cmd_pool_;
}
std::string server_id() {
std::shared_lock l(rwlock_);
return server_id_;
}
std::string run_id() {
std::shared_lock l(rwlock_);
return run_id_;
}
std::string replication_id() {
std::shared_lock l(rwlock_);
return replication_id_;
}
std::string requirepass() {
std::shared_lock l(rwlock_);
return requirepass_;
}
std::string masterauth() {
std::shared_lock l(rwlock_);
return masterauth_;
}
std::string userpass() {
std::shared_lock l(rwlock_);
return userpass_;
}
std::string bgsave_path() {
std::shared_lock l(rwlock_);
return bgsave_path_;
}
int expire_dump_days() {
std::shared_lock l(rwlock_);
return expire_dump_days_;
}
std::string bgsave_prefix() {
std::shared_lock l(rwlock_);
return bgsave_prefix_;
}
std::string user_blacklist_string() {
std::shared_lock l(rwlock_);
return pstd::StringConcat(user_blacklist_, COMMA);
}
const std::vector<std::string>& user_blacklist_vector() {
std::shared_lock l(rwlock_);
return user_blacklist_;
}
bool classic_mode() { return classic_mode_.load(); }
int databases() {
std::shared_lock l(rwlock_);
return databases_;
}
int default_slot_num() {
std::shared_lock l(rwlock_);
return default_slot_num_;
}
const std::vector<DBStruct>& db_structs() {
std::shared_lock l(rwlock_);
return db_structs_;
}
std::string default_db() {
std::shared_lock l(rwlock_);
return default_db_;
}
std::string compression() {
std::shared_lock l(rwlock_);
return compression_;
}
int64_t target_file_size_base() {
std::shared_lock l(rwlock_);
return target_file_size_base_;
}
uint64_t max_compaction_bytes() {
std::shared_lock l(rwlock_);
return static_cast<uint64_t>(max_compaction_bytes_);
}
int max_cache_statistic_keys() {
std::shared_lock l(rwlock_);
return max_cache_statistic_keys_;
}
int small_compaction_threshold() {
std::shared_lock l(rwlock_);
return small_compaction_threshold_;
}
int small_compaction_duration_threshold() {
std::shared_lock l(rwlock_);
return small_compaction_duration_threshold_;
}
int max_background_flushes() {
std::shared_lock l(rwlock_);
return max_background_flushes_;
}
int max_background_compactions() {
std::shared_lock l(rwlock_);
return max_background_compactions_;
}
int max_background_jobs() {
std::shared_lock l(rwlock_);
return max_background_jobs_;
}
uint64_t delayed_write_rate(){
std::shared_lock l(rwlock_);
return static_cast<uint64_t>(delayed_write_rate_);
}
int max_cache_files() {
std::shared_lock l(rwlock_);
return max_cache_files_;
}
int max_bytes_for_level_multiplier() {
std::shared_lock l(rwlock_);
return max_bytes_for_level_multiplier_;
}
int64_t block_size() {
std::shared_lock l(rwlock_);
return block_size_;
}
int64_t block_cache() {
std::shared_lock l(rwlock_);
return block_cache_;
}
int64_t num_shard_bits() {
std::shared_lock l(rwlock_);
return num_shard_bits_;
}
bool share_block_cache() {
std::shared_lock l(rwlock_);
return share_block_cache_;
}
bool wash_data() {
std::shared_lock l(rwlock_);
return wash_data_;
}
bool enable_partitioned_index_filters() {
std::shared_lock l(rwlock_);
return enable_partitioned_index_filters_;
}
bool cache_index_and_filter_blocks() {
std::shared_lock l(rwlock_);
return cache_index_and_filter_blocks_;
}
bool pin_l0_filter_and_index_blocks_in_cache() {
std::shared_lock l(rwlock_);
return pin_l0_filter_and_index_blocks_in_cache_;
}
bool optimize_filters_for_hits() {
std::shared_lock l(rwlock_);
return optimize_filters_for_hits_;
}
bool level_compaction_dynamic_level_bytes() {
std::shared_lock l(rwlock_);
return level_compaction_dynamic_level_bytes_;
}
int expire_logs_nums() {
std::shared_lock l(rwlock_);
return expire_logs_nums_;
}
int expire_logs_days() {
std::shared_lock l(rwlock_);
return expire_logs_days_;
}
std::string conf_path() {
std::shared_lock l(rwlock_);
return conf_path_;
}
bool slave_read_only() {
std::shared_lock l(rwlock_);
return slave_read_only_;
}
int maxclients() {
std::shared_lock l(rwlock_);
return maxclients_;
}
int root_connection_num() {
std::shared_lock l(rwlock_);
return root_connection_num_;
}
bool slowlog_write_errorlog() { return slowlog_write_errorlog_.load(); }
int slowlog_slower_than() { return slowlog_log_slower_than_.load(); }
int slowlog_max_len() {
std::shared_lock l(rwlock_);
return slowlog_max_len_;
}
std::string network_interface() {
std::shared_lock l(rwlock_);
return network_interface_;
}
int cache_mode() { return cache_mode_; }
int sync_window_size() { return sync_window_size_.load(); }
int max_conn_rbuf_size() { return max_conn_rbuf_size_.load(); }
int consensus_level() { return consensus_level_.load(); }
int replication_num() { return replication_num_.load(); }
int rate_limiter_mode() {
std::shared_lock l(rwlock_);
return rate_limiter_mode_;
}
int64_t rate_limiter_bandwidth() {
std::shared_lock l(rwlock_);
return rate_limiter_bandwidth_;
}
int64_t rate_limiter_refill_period_us() {
std::shared_lock l(rwlock_);
return rate_limiter_refill_period_us_;
}
int64_t rate_limiter_fairness() {
std::shared_lock l(rwlock_);
return rate_limiter_fairness_;
}
bool rate_limiter_auto_tuned() {
std::shared_lock l(rwlock_);
return rate_limiter_auto_tuned_;
}
bool IsCacheDisabledTemporarily() { return tmp_cache_disable_flag_; }
int GetCacheString() { return cache_string_; }
int GetCacheSet() { return cache_set_; }
int GetCacheZset() { return cache_zset_; }
int GetCacheHash() { return cache_hash_; }
int GetCacheList() { return cache_list_; }
int GetCacheBit() { return cache_bit_; }
int GetCacheNum() { return cache_num_; }
void SetCacheNum(const int value) { cache_num_ = value; }
void SetCacheMode(const int value) { cache_mode_ = value; }
void SetCacheStartDirection(const int value) { zset_cache_start_direction_ = value; }
void SetCacheItemsPerKey(const int value) { zset_cache_field_num_per_key_ = value; }
void SetCacheMaxKeySize(const int value) { max_key_size_in_cache_ = value; }
void SetCacheMaxmemory(const int64_t value) { cache_maxmemory_ = value; }
void SetCacheMaxmemoryPolicy(const int value) { cache_maxmemory_policy_ = value; }
void SetCacheMaxmemorySamples(const int value) { cache_maxmemory_samples_ = value; }
void SetCacheLFUDecayTime(const int value) { cache_lfu_decay_time_ = value; }
void UnsetCacheDisableFlag() { tmp_cache_disable_flag_ = false; }
bool enable_blob_files() { return enable_blob_files_; }
int64_t min_blob_size() { return min_blob_size_; }
int64_t blob_file_size() { return blob_file_size_; }
std::string blob_compression_type() { return blob_compression_type_; }
bool enable_blob_garbage_collection() { return enable_blob_garbage_collection_; }
double blob_garbage_collection_age_cutoff() { return blob_garbage_collection_age_cutoff_; }
double blob_garbage_collection_force_threshold() { return blob_garbage_collection_force_threshold_; }
int64_t blob_cache() { return blob_cache_; }
int64_t blob_num_shard_bits() { return blob_num_shard_bits_; }
// Rsync Rate limiting configuration
int throttle_bytes_per_second() {
std::shared_lock l(rwlock_);
return throttle_bytes_per_second_;
}
int max_rsync_parallel_num() {
std::shared_lock l(rwlock_);
return max_rsync_parallel_num_;
}
int64_t rsync_timeout_ms() {
return rsync_timeout_ms_.load(std::memory_order::memory_order_relaxed);
}
// Slow Commands configuration
const std::string GetSlowCmd() {
std::shared_lock l(rwlock_);
return pstd::Set2String(slow_cmd_set_, ',');
}
// Admin Commands configuration
const std::string GetAdminCmd() {
std::shared_lock l(rwlock_);
return pstd::Set2String(admin_cmd_set_, ',');
}
const std::string GetUserBlackList() {
std::shared_lock l(rwlock_);
return userblacklist_;
}
bool is_slow_cmd(const std::string& cmd) {
std::shared_lock l(rwlock_);
return slow_cmd_set_.find(cmd) != slow_cmd_set_.end();
}
bool is_admin_cmd(const std::string& cmd) {
return admin_cmd_set_.find(cmd) != admin_cmd_set_.end();
}
// Immutable config items, we don't use lock.
bool daemonize() { return daemonize_; }
bool rtc_cache_read_enabled() { return rtc_cache_read_enabled_; }
std::string pidfile() { return pidfile_; }
int binlog_file_size() { return binlog_file_size_; }
std::vector<rocksdb::CompressionType> compression_per_level();
std::string compression_all_levels() const { return compression_per_level_; };
static rocksdb::CompressionType GetCompression(const std::string& value);
std::vector<std::string>& users() { return users_; };
std::string acl_file() { return aclFile_; };
uint32_t acl_pubsub_default() { return acl_pubsub_default_.load(); }
uint32_t acl_log_max_len() { return acl_Log_max_len_.load(); }
// Setter
void SetPort(const int value) {
std::lock_guard l(rwlock_);
port_ = value;
}
void SetThreadNum(const int value) {
std::lock_guard l(rwlock_);
thread_num_ = value;
}
void SetTimeout(const int value) {
std::lock_guard l(rwlock_);
TryPushDiffCommands("timeout", std::to_string(value));
timeout_ = value;
}
void SetThreadPoolSize(const int value) {
std::lock_guard l(rwlock_);
thread_pool_size_ = value;
}
void SetLowLevelThreadPoolSize(const int value) {
std::lock_guard l(rwlock_);
slow_cmd_thread_pool_size_ = value;
}
void SetAdminThreadPoolSize(const int value) {
std::lock_guard l(rwlock_);
admin_thread_pool_size_ = value;
}
void SetSlaveof(const std::string& value) {
std::lock_guard l(rwlock_);
TryPushDiffCommands("slaveof", value);
slaveof_ = value;
}
void SetRocksdbTTLSecond(uint64_t ttl) {
rocksdb_ttl_second_.store(ttl);
}
void SetRocksdbPeriodicSecond(uint64_t value) {
rocksdb_periodic_second_.store(value);
}
void SetReplicationID(const std::string& value) {
std::lock_guard l(rwlock_);
TryPushDiffCommands("replication-id", value);
replication_id_ = value;
}
void SetSlavePriority(const int value) {
std::lock_guard l(rwlock_);
TryPushDiffCommands("slave-priority", std::to_string(value));
slave_priority_ = value;
}
void SetWriteBinlog(const std::string& value) {
std::lock_guard l(rwlock_);
TryPushDiffCommands("write-binlog", value);
write_binlog_ = value == "yes";
}
void SetMaxCacheStatisticKeys(const int value) {
std::lock_guard l(rwlock_);
TryPushDiffCommands("max-cache-statistic-keys", std::to_string(value));
max_cache_statistic_keys_ = value;
}
void SetSmallCompactionThreshold(const int value) {
std::lock_guard l(rwlock_);
TryPushDiffCommands("small-compaction-threshold", std::to_string(value));
small_compaction_threshold_ = value;
}
void SetSmallCompactionDurationThreshold(const int value) {
std::lock_guard l(rwlock_);
TryPushDiffCommands("small-compaction-duration-threshold", std::to_string(value));
small_compaction_duration_threshold_ = value;
}
void SetMaxClientResponseSize(const int value) {
std::lock_guard l(rwlock_);
TryPushDiffCommands("max-client-response-size", std::to_string(value));
max_client_response_size_ = value;
}
void SetBgsavePath(const std::string& value) {
std::lock_guard l(rwlock_);
bgsave_path_ = value;
if (value[value.length() - 1] != '/') {
bgsave_path_ += "/";
}
}
void SetExpireDumpDays(const int value) {
std::lock_guard l(rwlock_);
TryPushDiffCommands("dump-expire", std::to_string(value));
expire_dump_days_ = value;
}
void SetBgsavePrefix(const std::string& value) {
std::lock_guard l(rwlock_);
TryPushDiffCommands("dump-prefix", value);
bgsave_prefix_ = value;
}
void SetRunID(const std::string& value) {
std::lock_guard l(rwlock_);
TryPushDiffCommands("run-id", value);
run_id_ = value;
}
void SetRequirePass(const std::string& value) {
std::lock_guard l(rwlock_);
TryPushDiffCommands("requirepass", value);
requirepass_ = value;
}
void SetMasterAuth(const std::string& value) {
std::lock_guard l(rwlock_);
TryPushDiffCommands("masterauth", value);
masterauth_ = value;
}
void SetUserPass(const std::string& value) {
std::lock_guard l(rwlock_);
TryPushDiffCommands("userpass", value);
userpass_ = value;
}
void SetUserBlackList(const std::string& value) {
std::lock_guard l(rwlock_);
TryPushDiffCommands("userblacklist", value);
pstd::StringSplit(value, COMMA, user_blacklist_);
for (auto& item : user_blacklist_) {
pstd::StringToLower(item);
}
}
void SetSlotMigrate(const bool value) {
std::lock_guard l(rwlock_);
TryPushDiffCommands("slotmigrate", value ? "yes" : "no");
slotmigrate_.store(value);
}
void SetSlowCmdPool(const bool value) {
std::lock_guard l(rwlock_);
TryPushDiffCommands("slow-cmd-pool", value ? "yes" : "no");
slow_cmd_pool_.store(value);
}
void SetSlotMigrateThreadNum(const int value) {
std::lock_guard l(rwlock_);
TryPushDiffCommands("slotmigrate-thread-num", std::to_string(value));
slotmigrate_thread_num_ = value;
}
void SetThreadMigrateKeysNum(const int value) {
std::lock_guard l(rwlock_);
TryPushDiffCommands("thread-migrate-keys-num", std::to_string(value));
thread_migrate_keys_num_ = value;
}
void SetExpireLogsNums(const int value) {
std::lock_guard l(rwlock_);
TryPushDiffCommands("expire-logs-nums", std::to_string(value));
expire_logs_nums_ = value;
}
void SetExpireLogsDays(const int value) {
std::lock_guard l(rwlock_);
TryPushDiffCommands("expire-logs-days", std::to_string(value));
expire_logs_days_ = value;
}
void SetMaxConnection(const int value) {
std::lock_guard l(rwlock_);
TryPushDiffCommands("maxclients", std::to_string(value));
maxclients_ = value;
}
void SetRootConnectionNum(const int value) {
std::lock_guard l(rwlock_);
TryPushDiffCommands("root-connection-num", std::to_string(value));
root_connection_num_ = value;
}
void SetSlowlogWriteErrorlog(const bool value) {
std::lock_guard l(rwlock_);
TryPushDiffCommands("slowlog-write-errorlog", value ? "yes" : "no");
slowlog_write_errorlog_.store(value);
}
void SetSlowlogSlowerThan(const int value) {
std::lock_guard l(rwlock_);
TryPushDiffCommands("slowlog-log-slower-than", std::to_string(value));
slowlog_log_slower_than_.store(value);
}
void SetSlowlogMaxLen(const int value) {
std::lock_guard l(rwlock_);
TryPushDiffCommands("slowlog-max-len", std::to_string(value));
slowlog_max_len_ = value;
}
void SetDbSyncSpeed(const int value) {
std::lock_guard l(rwlock_);
TryPushDiffCommands("db-sync-speed", std::to_string(value));
db_sync_speed_ = value;
}
void SetCompactCron(const std::string& value) {
std::lock_guard l(rwlock_);
TryPushDiffCommands("compact-cron", value);
compact_cron_ = value;
}
void SetCompactInterval(const std::string& value) {
std::lock_guard l(rwlock_);
TryPushDiffCommands("compact-interval", value);
compact_interval_ = value;
}
void SetDisableAutoCompaction(const std::string& value) {
std::lock_guard l(rwlock_);
TryPushDiffCommands("disable_auto_compactions", value);
disable_auto_compactions_ = value == "true";
}
void SetIncrementalCompactInterval(const int value) {
std::lock_guard l(rwlock_);
TryPushDiffCommands("incremental-compact-interval", std::to_string(value));
incremental_compact_interval_ = value;
}
void SetIncrementalCompactMaxFiles(const int value) {
std::lock_guard l(rwlock_);
TryPushDiffCommands("incremental-compact-max-files", std::to_string(value));
incremental_compact_max_files_ = value;
}
void SetIncrementalCompactMaxTimeMs(const int value) {
std::lock_guard l(rwlock_);
TryPushDiffCommands("incremental-compact-max-time-ms", std::to_string(value));
incremental_compact_max_time_ms_ = value;
}
void SetIncrementalCompactMinRate(const int value) {
std::lock_guard l(rwlock_);
TryPushDiffCommands("incremental-compact-min-rate", std::to_string(value));
incremental_compact_min_rate_ = value;
}
void SetIncrementalCompactMinFileAge(const int value) {
std::lock_guard l(rwlock_);
TryPushDiffCommands("incremental-compact-min-file-age", std::to_string(value));
incremental_compact_min_file_age_ = value;
}
void SetMaxSubcompactions(const int& value) {
std::lock_guard l(rwlock_);
TryPushDiffCommands("max-subcompactions", std::to_string(value));
max_subcompactions_ = value;
}
void SetLeastResumeFreeDiskSize(const int64_t& value) {
std::lock_guard l(rwlock_);
TryPushDiffCommands("least-free-disk-resume-size", std::to_string(value));
least_free_disk_to_resume_ = value;
}
void SetResumeInterval(const int64_t& value) {
std::lock_guard l(rwlock_);
TryPushDiffCommands("manually-resume-interval", std::to_string(value));
resume_check_interval_ = value;
}
void SetMinCheckResumeRatio(const double& value) {
std::lock_guard l(rwlock_);
TryPushDiffCommands("min-check-resume-ratio", std::to_string(value));
min_check_resume_ratio_ = value;
}
void SetSyncWindowSize(const int& value) {
TryPushDiffCommands("sync-window-size", std::to_string(value));
sync_window_size_.store(value);
}
void SetMaxConnRbufSize(const int& value) {
TryPushDiffCommands("max-conn-rbuf-size", std::to_string(value));
max_conn_rbuf_size_.store(value);
}
void SetMaxCacheFiles(const int& value) {
std::lock_guard l(rwlock_);
TryPushDiffCommands("max-cache-files", std::to_string(value));
max_cache_files_ = value;
}
void SetMaxBackgroudCompactions(const int& value) {
std::lock_guard l(rwlock_);
TryPushDiffCommands("max-background-compactions", std::to_string(value));
max_background_compactions_ = value;
}
void SetMaxBackgroudJobs(const int& value) {
std::lock_guard l(rwlock_);
TryPushDiffCommands("max-background-jobs", std::to_string(value));
max_background_jobs_ = value;
}
void SetWriteBufferSize(int64_t value) {
std::lock_guard l(rwlock_);
TryPushDiffCommands("write-buffer-size", std::to_string(value));
write_buffer_size_ = value;
}
void SetLogRetentionTime(const int& value) {
std::lock_guard l(rwlock_);
TryPushDiffCommands("log-retention-time", std::to_string(value));
log_retention_time_ = value;
}
void SetMinWriteBufferNumberToMerge(const int& value) {
std::lock_guard l(rwlock_);
TryPushDiffCommands("min-write-buffer-number-to-merge", std::to_string(value));
min_write_buffer_number_to_merge_ = value;
}
void SetLevel0StopWritesTrigger(const int& value) {
std::lock_guard l(rwlock_);
TryPushDiffCommands("level0-stop-writes-trigger", std::to_string(value));
level0_stop_writes_trigger_ = value;
}
void SetLevel0SlowdownWritesTrigger(const int& value) {
std::lock_guard l(rwlock_);
TryPushDiffCommands("level0-slowdown-writes-trigger", std::to_string(value));
level0_slowdown_writes_trigger_ = value;
}
void SetLevel0FileNumCompactionTrigger(const int& value) {
std::lock_guard l(rwlock_);
TryPushDiffCommands("level0-file-num-compaction-trigger", std::to_string(value));
level0_file_num_compaction_trigger_ = value;
}
void SetMaxWriteBufferNumber(const int& value) {
std::lock_guard l(rwlock_);
TryPushDiffCommands("max-write-buffer-num", std::to_string(value));
max_write_buffer_num_ = value;
}
void SetMaxTotalWalSize(uint64_t value) {
std::lock_guard l(rwlock_);
TryPushDiffCommands("max-total-wal-size", std::to_string(value));
max_total_wal_size_ = value;
}
void SetArenaBlockSize(const int& value) {
std::lock_guard l(rwlock_);
TryPushDiffCommands("arena-block-size", std::to_string(value));
arena_block_size_ = value;
}
void SetRateLmiterBandwidth(int64_t value) {
std::lock_guard l(rwlock_);
TryPushDiffCommands("rate-limiter-bandwidth", std::to_string(value));
rate_limiter_bandwidth_ = value;
}
void SetDelayedWriteRate(int64_t value) {
std::lock_guard l(rwlock_);
TryPushDiffCommands("delayed-write-rate", std::to_string(value));
delayed_write_rate_ = value;
}
void SetMaxCompactionBytes(int64_t value) {
std::lock_guard l(rwlock_);
TryPushDiffCommands("max-compaction-bytes", std::to_string(value));
max_compaction_bytes_ = value;
}
void SetLogNetActivities(std::string& value) {
TryPushDiffCommands("log-net-activities", value);
if (value == "yes") {
log_net_activities_.store(true);
} else {
log_net_activities_.store(false);
}
}
// Rsync Rate limiting configuration
void SetThrottleBytesPerSecond(const int value) {
std::lock_guard l(rwlock_);
TryPushDiffCommands("throttle-bytes-per-second", std::to_string(value));
throttle_bytes_per_second_ = value;
}
void SetMaxRsyncParallelNum(const int value) {
std::lock_guard l(rwlock_);
TryPushDiffCommands("max-rsync-parallel-num", std::to_string(value));
max_rsync_parallel_num_ = value;
}
void SetRsyncTimeoutMs(int64_t value){
std::lock_guard l(rwlock_);
TryPushDiffCommands("rsync-timeout-ms", std::to_string(value));
rsync_timeout_ms_.store(value);
}
void SetProtoMaxBulkLen(const int64_t value) {
std::lock_guard l(rwlock_);
TryPushDiffCommands("proto-max-bulk-len", std::to_string(value));
proto_max_bulk_len_ = value;
}
int RocksDBPerfLevel() const {
return rocksdb_perf_level_.load();
}
int CacheValueItemMaxSize() const {
return cache_value_item_max_size_.load();
}
bool UpdateCacheValueItemMaxSize(int size) {
if (size > MAX_CACHE_ITEMS_SIZE || size <= 0) {
return false;
}
cache_value_item_max_size_.store(size);
return true;
}
size_t MaxKeySizeInCache() const {
return max_key_size_in_cache_.load();
}
bool UpdateMaxKeySizeInCache(size_t size) {
if (size > MAX_CACHE_MAX_KEY_SIZE || size <= 0) {
return false;
}
max_key_size_in_cache_.store(size);
return true;
}
bool UpdateRocksDBPerfLevel(int perf_level) {
if (perf_level >= 6 || perf_level < 0) {
return false;
}
rocksdb_perf_level_.store(perf_level);
return true;
}
int RocksDBPerfPercent() const {
return rocksdb_perf_percent_.load();
}
bool UpdateRocksDBPerfPercent(int percent) {
if (percent > 100 || percent < 0) {
return false;
}
rocksdb_perf_percent_.store(percent);
return true;
}
void SetAclPubsubDefault(const std::string& value) {
std::lock_guard l(rwlock_);
TryPushDiffCommands("acl-pubsub-default", value);
if (value == "resetchannels") {
acl_pubsub_default_ = 0;
} else {
acl_pubsub_default_ = static_cast<uint32_t>(AclSelectorFlag::ALL_CHANNELS);
}
}
void SetAclLogMaxLen(const int value) {
std::lock_guard l(rwlock_);
TryPushDiffCommands("acllog-max-len", std::to_string(value));
acl_Log_max_len_ = value;
}
const std::string scache_type() {
std::shared_lock l(rwlock_);
return pstd::StringConcat(cache_type_, COMMA);
}
int64_t cache_maxmemory() { return cache_maxmemory_; }
void SetSlowCmd(const std::string& value) {
std::lock_guard l(rwlock_);
std::string lower_value = value;
pstd::StringToLower(lower_value);
TryPushDiffCommands("slow-cmd-list", lower_value);
pstd::StringSplit2Set(lower_value, ',', slow_cmd_set_);
}
void SetAdminCmd(const std::string& value) {
std::lock_guard l(rwlock_);
std::string lower_value = value;
pstd::StringToLower(lower_value);
TryPushDiffCommands("admin-cmd-list", lower_value);
pstd::StringSplit2Set(lower_value, ',', admin_cmd_set_);