setting tenant-level parameters at startup

This commit is contained in:
obdev
2023-05-25 03:41:55 +00:00
committed by ob-robot
parent f22b9232d8
commit b62b7b675a
4 changed files with 26 additions and 3 deletions

View File

@ -1523,7 +1523,7 @@ int ObServer::init_config()
config_.print(); config_.print();
// local_ip is a critical parameter, if if is set, then verify it; otherwise, set it via devname. // local_ip is a critical parameter, if it is set, then verify it; otherwise, set it via devname.
if (strlen(config_.local_ip) > 0) { if (strlen(config_.local_ip) > 0) {
char if_name[MAX_IFNAME_LENGTH] = { '\0' }; char if_name[MAX_IFNAME_LENGTH] = { '\0' };
if (0 != obsys::ObNetUtil::get_ifname_by_addr(config_.local_ip, if_name, sizeof(if_name))) { if (0 != obsys::ObNetUtil::get_ifname_by_addr(config_.local_ip, if_name, sizeof(if_name))) {
@ -1632,8 +1632,11 @@ int ObServer::init_config()
LOG_ERROR("config_mgr_ base_init failed", KR(ret)); LOG_ERROR("config_mgr_ base_init failed", KR(ret));
} else if (OB_FAIL(config_mgr_.init(sql_proxy_, self_addr_))) { } else if (OB_FAIL(config_mgr_.init(sql_proxy_, self_addr_))) {
LOG_ERROR("config_mgr_ init failed", K_(self_addr), KR(ret)); LOG_ERROR("config_mgr_ init failed", K_(self_addr), KR(ret));
} else if (OB_FAIL(tenant_config_mgr_.init(sql_proxy_, self_addr_, &config_mgr_, update_tenant_config_cb))) { } else if (OB_FAIL(tenant_config_mgr_.init(sql_proxy_, self_addr_,
&config_mgr_, update_tenant_config_cb))) {
LOG_ERROR("tenant_config_mgr_ init failed", K_(self_addr), KR(ret)); LOG_ERROR("tenant_config_mgr_ init failed", K_(self_addr), KR(ret));
} else if (OB_FAIL(tenant_config_mgr_.add_config_to_existing_tenant(opts_.optstr_))) {
LOG_ERROR("tenant_config_mgr_ add_config_to_existing_tenant failed", KR(ret));
} }
} }
} }

View File

@ -616,6 +616,25 @@ void ObTenantConfigMgr::notify_tenant_config_changed(uint64_t tenant_id)
update_tenant_config_cb_(tenant_id); update_tenant_config_cb_(tenant_id);
} }
int ObTenantConfigMgr::add_config_to_existing_tenant(const char *config_str)
{
int ret = OB_SUCCESS;
DRWLock::WRLockGuard guard(rwlock_);
if (!config_map_.empty() && nullptr != config_str) {
TenantConfigMap::const_iterator it = config_map_.begin();
for (; it != config_map_.end() && OB_SUCC(ret); ++it) {
if (OB_NOT_NULL(it->second)) {
int64_t version = ObTimeUtility::current_time();
if (OB_FAIL(it->second->add_extra_config(config_str, version))) {
LOG_WARN("add tenant extra config failed", "tenant_id", it->second->get_tenant_id(),
"config_str", config_str, KR(ret));
}
}
}
}
return ret;
}
int ObTenantConfigMgr::add_extra_config(const obrpc::ObTenantConfigArg &arg) int ObTenantConfigMgr::add_extra_config(const obrpc::ObTenantConfigArg &arg)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;

View File

@ -145,6 +145,7 @@ public:
int got_version(uint64_t tenant_id, int64_t version, const bool remove_repeat = true); int got_version(uint64_t tenant_id, int64_t version, const bool remove_repeat = true);
int update_local(uint64_t tenant_id, int64_t expected_version); int update_local(uint64_t tenant_id, int64_t expected_version);
void notify_tenant_config_changed(uint64_t tenatn_id); void notify_tenant_config_changed(uint64_t tenatn_id);
int add_config_to_existing_tenant(const char *config_str);
int add_extra_config(const obrpc::ObTenantConfigArg &arg); int add_extra_config(const obrpc::ObTenantConfigArg &arg);
int schedule(ObTenantConfig::TenantConfigUpdateTask &task, const int64_t delay); int schedule(ObTenantConfig::TenantConfigUpdateTask &task, const int64_t delay);
int cancel(const ObTenantConfig::TenantConfigUpdateTask &task); int cancel(const ObTenantConfig::TenantConfigUpdateTask &task);

View File

@ -343,7 +343,7 @@ int ObCommonConfig::add_extra_config(const char *config_str,
} else if (OB_ISNULL(pp_item = container_.get(ObConfigStringKey(name)))) { } else if (OB_ISNULL(pp_item = container_.get(ObConfigStringKey(name)))) {
/* make compatible with previous configuration */ /* make compatible with previous configuration */
ret = check_name ? OB_INVALID_CONFIG : OB_SUCCESS; ret = check_name ? OB_INVALID_CONFIG : OB_SUCCESS;
LOG_ERROR("Invalid config string, no such config item", K(name), K(value), K(ret)); LOG_WARN("Invalid config string, no such config item", K(name), K(value), K(ret));
} else if (external_kms_info_cfg.case_compare(name) == 0 } else if (external_kms_info_cfg.case_compare(name) == 0
|| ssl_external_kms_info_cfg.case_compare(name) == 0) { || ssl_external_kms_info_cfg.case_compare(name) == 0) {
if (OB_FAIL(common::hex_to_cstr(value, value_len, if (OB_FAIL(common::hex_to_cstr(value, value_len,