forked from apache/kvrocks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.h
166 lines (150 loc) · 4.34 KB
/
config.h
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
#pragma once
#include <sys/resource.h>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <rocksdb/options.h>
#include "config_type.h"
#include "status.h"
#include "cron.h"
// forward declaration
class Server;
namespace Engine {
class Storage;
}
#define SUPERVISED_NONE 0
#define SUPERVISED_AUTODETECT 1
#define SUPERVISED_SYSTEMD 2
#define SUPERVISED_UPSTART 3
const size_t KiB = 1024L;
const size_t MiB = 1024L * KiB;
const size_t GiB = 1024L * MiB;
extern const char *kDefaultNamespace;
struct CompactionCheckerRange {
public:
int Start;
int Stop;
bool Enabled() {
return Start != -1 || Stop != -1;
}
};
struct Config{
public:
Config();
~Config();
int port = 6666;
int workers = 0;
int timeout = 0;
int loglevel = 0;
int backlog = 511;
int maxclients = 10000;
int max_backup_to_keep = 1;
int max_backup_keep_hours = 24;
int slowlog_log_slower_than = 100000;
int slowlog_max_len = 128;
bool daemonize = false;
int supervised_mode = SUPERVISED_NONE;
bool slave_readonly = true;
bool slave_serve_stale_data = true;
bool slave_empty_db_before_fullsync = false;
int slave_priority = 100;
int max_db_size = 0;
int max_replication_mb = 0;
int max_io_mb = 0;
int max_bitmap_to_string_mb = 16;
bool master_use_repl_port = false;
bool purge_backup_on_fullsync = false;
bool auto_resize_block_and_sst = true;
int fullsync_recv_file_delay = 0;
std::vector<std::string> binds;
std::string dir;
std::string db_dir;
std::string backup_dir;
std::string backup_sync_dir;
std::string checkpoint_dir;
std::string sync_checkpoint_dir;
std::string log_dir;
std::string pidfile;
std::string db_name;
std::string masterauth;
std::string requirepass;
std::string master_host;
int master_port = 0;
Cron compact_cron;
Cron bgsave_cron;
CompactionCheckerRange compaction_checker_range{-1, -1};
std::map<std::string, std::string> tokens;
bool slot_id_encoded = false;
bool cluster_enabled = false;
int migrate_speed;
int pipeline_size;
int sequence_gap;
// profiling
int profiling_sample_ratio = 0;
int profiling_sample_record_threshold_ms = 0;
int profiling_sample_record_max_len = 128;
std::set<std::string> profiling_sample_commands;
bool profiling_sample_all_commands = false;
struct {
int block_size;
bool cache_index_and_filter_blocks;
int metadata_block_cache_size;
int subkey_block_cache_size;
bool share_metadata_and_subkey_block_cache;
int row_cache_size;
int max_open_files;
int write_buffer_size;
int max_write_buffer_number;
int max_background_compactions;
int max_background_flushes;
int max_sub_compactions;
int stats_dump_period_sec;
bool enable_pipelined_write;
int64_t delayed_write_rate;
int compaction_readahead_size;
int target_file_size_base;
int WAL_ttl_seconds;
int WAL_size_limit_MB;
int max_total_wal_size;
int level0_slowdown_writes_trigger;
int level0_stop_writes_trigger;
int level0_file_num_compaction_trigger;
int compression;
bool disable_auto_compactions;
bool enable_blob_files;
int min_blob_size;
int blob_file_size;
bool enable_blob_garbage_collection;
int blob_garbage_collection_age_cutoff;
int max_bytes_for_level_base;
int max_bytes_for_level_multiplier;
bool level_compaction_dynamic_level_bytes;
} RocksDB;
public:
Status Rewrite();
Status Load(const std::string &path);
void Get(std::string key, std::vector<std::string> *values);
Status Set(Server *svr, std::string key, const std::string &value);
void SetMaster(const std::string &host, int port);
void ClearMaster();
Status GetNamespace(const std::string &ns, std::string *token);
Status AddNamespace(const std::string &ns, const std::string &token);
Status SetNamespace(const std::string &ns, const std::string &token);
Status DelNamespace(const std::string &ns);
private:
std::string path_;
std::string binds_;
std::string slaveof_;
std::string compact_cron_;
std::string bgsave_cron_;
std::string compaction_checker_range_;
std::string profiling_sample_commands_;
std::map<std::string, ConfigField*> fields_;
std::string rename_command_;
void initFieldValidator();
void initFieldCallback();
Status parseConfigFromString(std::string input, int line_number);
Status finish();
Status isNamespaceLegal(const std::string &ns);
};