MCPcopy Create free account
hub / github.com/Tencent/phxsql / ReadConfig

Method ReadConfig

phxsqlproxy/plugin/requestfilter/freqctrlconfig.cpp:111–143  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

109}
110
111void FreqCtrlConfig::ReadConfig() {
112 for (auto & itr : db_bucket_) {
113 delete itr.second, itr.second = NULL;
114 }
115 db_bucket_.clear();
116
117 int db_count = 0;
118 db_count = GetInteger("General", "DBCount", 0);
119 for (int i = 0; i < db_count; ++i) {
120 char section[64] = { 0 };
121 snprintf(section, sizeof(section), "DB%d", i);
122
123 std::string db_name = "";
124 FreqCtrlBucket::DBToken_t token;
125
126 db_name = Get(section, "DBName", "");
127 token.read_token = GetInteger(section, "ReadToken", INT_MAX);
128 token.write_token = GetInteger(section, "WriteToken", INT_MAX);
129 token.period = GetInteger(section, "Period", 60); //in second
130
131 if (db_name == "")
132 continue;
133
134 FreqCtrlBucket * bucket = new FreqCtrlBucket();
135 bucket->Sedb_token(token);
136
137 db_bucket_[db_name] = bucket;
138
139 LogWarning("%s:%d read %dth db [%s] readtoken [%d] writetoken [%d] period [%d]", __func__, __LINE__, i,
140 db_name.c_str(), token.read_token, token.write_token, token.period);
141 }
142 return;
143}
144
145bool FreqCtrlConfig::Apply(const std::string & db_name, bool is_write_query) {
146 auto itr = db_bucket_.find(db_name);

Callers 1

mainFunction · 0.45

Calls 2

LogWarningFunction · 0.85
Sedb_tokenMethod · 0.80

Tested by 1

mainFunction · 0.36