Skip to content

Commit 7cc9ef2

Browse files
branch-4.1: [feat](http) Support update and show config for recycler and meta-service #60816 (#61479)
Cherry-picked from #60816 Co-authored-by: Yixuan Wang <wangyixuan@selectdb.com>
1 parent d462fae commit 7cc9ef2

6 files changed

Lines changed: 375 additions & 179 deletions

File tree

cloud/src/meta-service/meta_service_http.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,38 @@ static HttpResponse process_query_rate_limit(MetaServiceImpl* service, brpc::Con
460460
return http_json_reply(MetaServiceCode::OK, "", sb.GetString());
461461
}
462462

463+
static HttpResponse process_show_config(MetaServiceImpl*, brpc::Controller* cntl) {
464+
auto& uri = cntl->http_request().uri();
465+
std::string_view conf_name = http_query(uri, "conf_key");
466+
467+
if (config::full_conf_map == nullptr) {
468+
return http_json_reply(MetaServiceCode::UNDEFINED_ERR, "config map not initialized");
469+
}
470+
471+
rapidjson::Document d;
472+
d.SetArray();
473+
474+
for (auto& [name, field] : *config::Register::_s_field_map) {
475+
if (!conf_name.empty() && name != conf_name) {
476+
continue;
477+
}
478+
auto it = config::full_conf_map->find(name);
479+
std::string value = (it != config::full_conf_map->end()) ? it->second : "";
480+
481+
rapidjson::Value entry(rapidjson::kArrayType);
482+
entry.PushBack(rapidjson::Value(name.c_str(), d.GetAllocator()), d.GetAllocator());
483+
entry.PushBack(rapidjson::Value(field.type, d.GetAllocator()), d.GetAllocator());
484+
entry.PushBack(rapidjson::Value(value.c_str(), d.GetAllocator()), d.GetAllocator());
485+
entry.PushBack(rapidjson::Value(field.valmutable), d.GetAllocator());
486+
d.PushBack(entry, d.GetAllocator());
487+
}
488+
489+
rapidjson::StringBuffer sb;
490+
rapidjson::PrettyWriter<rapidjson::StringBuffer> writer(sb);
491+
d.Accept(writer);
492+
return http_json_reply(MetaServiceCode::OK, "", sb.GetString());
493+
}
494+
463495
static HttpResponse process_update_config(MetaServiceImpl* service, brpc::Controller* cntl) {
464496
const auto& uri = cntl->http_request().uri();
465497
bool persist = (http_query(uri, "persist") == "true");
@@ -948,13 +980,15 @@ void MetaServiceImpl::http(::google::protobuf::RpcController* controller,
948980
{"adjust_rate_limit", process_adjust_rate_limit},
949981
{"list_rate_limit", process_query_rate_limit},
950982
{"update_config", process_update_config},
983+
{"show_config", process_show_config},
951984
{"v1/abort_txn", process_abort_txn},
952985
{"v1/abort_tablet_job", process_abort_tablet_job},
953986
{"v1/alter_ram_user", process_alter_ram_user},
954987
{"v1/alter_iam", process_alter_iam},
955988
{"v1/adjust_rate_limit", process_adjust_rate_limit},
956989
{"v1/list_rate_limit", process_query_rate_limit},
957990
{"v1/update_config", process_update_config},
991+
{"v1/show_config", process_show_config},
958992
};
959993

960994
auto* cntl = static_cast<brpc::Controller*>(controller);

cloud/src/recycler/recycler.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ class Recycler {
8888

8989
bool stopped() const { return stopped_.load(std::memory_order_acquire); }
9090

91+
RecyclerThreadPoolGroup& thread_pool_group() { return _thread_pool_group; }
92+
9193
private:
9294
void recycle_callback();
9395

0 commit comments

Comments
 (0)