|
32 | 32 |
|
33 | 33 | namespace doris::cloud::config {
|
34 | 34 |
|
35 |
| -std::string g_conf_path {}; |
36 |
| - |
37 | 35 | std::map<std::string, Register::Field>* Register::_s_field_map = nullptr;
|
38 | 36 | std::map<std::string, std::function<bool()>>* RegisterConfValidator::_s_field_validator = nullptr;
|
39 | 37 | std::map<std::string, std::string>* full_conf_map = nullptr;
|
@@ -412,26 +410,35 @@ bool do_set_config(const Register::Field& feild, const std::string& value, bool
|
412 | 410 | return false;
|
413 | 411 | }
|
414 | 412 |
|
415 |
| -bool set_config(const std::string& field, const std::string& value, bool need_persist) { |
| 413 | +bool set_config(const std::string& field, const std::string& value, bool need_persist, |
| 414 | + const std::string& custom_conf_path) { |
416 | 415 | auto it = Register::_s_field_map->find(field);
|
417 | 416 | if (it == Register::_s_field_map->end()) {
|
418 | 417 | return false;
|
419 | 418 | }
|
420 | 419 | if (!it->second.valmutable) {
|
421 | 420 | return false;
|
422 | 421 | }
|
| 422 | + |
423 | 423 | Properties props;
|
424 |
| - if (!do_set_config(it->second, value, need_persist, props)) { |
425 |
| - std::cerr << "not supported to modify: " << field << "=" << value << std::endl; |
426 |
| - return false; |
427 |
| - } |
| 424 | + auto set_conf_func = [&]() { |
| 425 | + if (!do_set_config(it->second, value, need_persist, props)) { |
| 426 | + std::cerr << "not supported to modify: " << field << "=" << value << std::endl; |
| 427 | + return false; |
| 428 | + } |
| 429 | + return true; |
| 430 | + }; |
428 | 431 |
|
429 | 432 | if (need_persist) {
|
430 | 433 | // lock to make sure only one thread can modify the be_custom.conf
|
431 | 434 | std::lock_guard<std::mutex> l(conf_persist_lock);
|
432 |
| - return props.dump(config::g_conf_path.data()); |
| 435 | + if (!set_conf_func()) { |
| 436 | + return false; |
| 437 | + } |
| 438 | + return props.dump(custom_conf_path); |
433 | 439 | }
|
434 |
| - return true; |
| 440 | + |
| 441 | + return set_conf_func(); |
435 | 442 | }
|
436 | 443 |
|
437 | 444 | } // namespace doris::cloud::config
|
0 commit comments