acelyc111 commented on code in PR #2103:
URL:
https://github.com/apache/incubator-pegasus/pull/2103#discussion_r1724706007
##########
src/common/duplication_common.cpp:
##########
@@ -103,6 +105,59 @@ class duplication_group_registry : public
utils::singleton<duplication_group_reg
}
const std::set<uint8_t> &get_distinct_cluster_id_set() { return
_distinct_cids; }
+ error_with<uint8_t> reload_duplication_config(std::string config_file)
+ {
+ if (config_file.length() == 0) {
Review Comment:
```suggestion
if (config_file.empty() ) {
```
##########
src/common/duplication_common.cpp:
##########
@@ -103,6 +105,59 @@ class duplication_group_registry : public
utils::singleton<duplication_group_reg
}
const std::set<uint8_t> &get_distinct_cluster_id_set() { return
_distinct_cids; }
+ error_with<uint8_t> reload_duplication_config(std::string config_file)
+ {
+ if (config_file.length() == 0) {
+ config_file = "config.ini";
+ }
+ const char *config_file_cstr = config_file.c_str();
+
+ std::map<std::string, uint8_t> new_group;
+ std::set<uint8_t> new_distinct_cids;
+ dsn::configuration old_config;
+
+ // reload default config.ini, user can point to another config file.
update g_config here
+ if (!dsn_config_reload(config_file_cstr, nullptr, &old_config)) {
+ LOG_ERROR("Fail to reload config file {} \n", config_file_cstr);
+ return error_s::make(
+ ERR_OBJECT_NOT_FOUND,
+ " new `duplication-group` configured can not be read. Check
your config.ini now");
+ ;
Review Comment:
```suggestion
```
##########
src/common/test/err-config-test.ini:
##########
@@ -0,0 +1,106 @@
+; The MIT License (MIT)
Review Comment:
Use Apache 2.0 license.
##########
src/common/duplication_common.cpp:
##########
@@ -103,6 +105,59 @@ class duplication_group_registry : public
utils::singleton<duplication_group_reg
}
const std::set<uint8_t> &get_distinct_cluster_id_set() { return
_distinct_cids; }
+ error_with<uint8_t> reload_duplication_config(std::string config_file)
+ {
+ if (config_file.length() == 0) {
+ config_file = "config.ini";
+ }
+ const char *config_file_cstr = config_file.c_str();
+
+ std::map<std::string, uint8_t> new_group;
+ std::set<uint8_t> new_distinct_cids;
+ dsn::configuration old_config;
+
+ // reload default config.ini, user can point to another config file.
update g_config here
+ if (!dsn_config_reload(config_file_cstr, nullptr, &old_config)) {
+ LOG_ERROR("Fail to reload config file {} \n", config_file_cstr);
Review Comment:
There are some format issues, please check them.
```suggestion
LOG_ERROR("Fail to reload config file {}", config_file_cstr);
```
##########
src/utils/config_api.cpp:
##########
@@ -39,6 +40,23 @@ bool dsn_config_load(const char *file, const char *arguments)
void dsn_config_dump(std::ostream &os) { g_config.dump(os); }
+bool dsn_config_reload(const char *file,
+ const char *arguments,
+ /*out*/ dsn::configuration *old_config)
+{
+ *old_config = g_config;
+ dsn::configuration temp_config;
+ if (!temp_config.load(file, arguments)) {
+ // todo gns: add some error log
Review Comment:
Use the standard TODO style.
##########
src/utils/configuration.h:
##########
@@ -43,11 +44,68 @@ namespace dsn {
class configuration
{
+private:
+ struct conf
+ {
+ std::string section;
+ std::string key;
+ std::string value;
+ int line;
+
+ bool present;
Review Comment:
Could you please add some comments when you happened to modify the code?
Thanks!
##########
src/utils/configuration.cpp:
##########
@@ -51,6 +51,20 @@ configuration::~configuration()
_configs.clear();
}
+void configuration::copy_configs(configuration &source_conf)
+{
+ source_conf._lock.lock();
Review Comment:
_configs should be empty before filling values, right? Please check it.
##########
src/utils/configuration.cpp:
##########
@@ -51,6 +51,20 @@ configuration::~configuration()
_configs.clear();
}
+void configuration::copy_configs(configuration &source_conf)
+{
+ source_conf._lock.lock();
+ for (auto §ion_kv : source_conf._configs) {
Review Comment:
Use C++ 17 style.
```
for (const auto [a, b] : xxx) {
...
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]